跳转至

FalkorDB Updated PS and TS for The Companion

Here is the updated Product Statement and Technical Stack for your Personal AI Companion, "The Constant."

This version eliminates the separate Vector Database (ChromaDB) entirely, relying on FalkorDB’s unified Graph+Vector engine to handle both "Facts" and "Vibes" in a single, ultra-fast RAM-based system.


1. Product Statement

For privacy-conscious individuals seeking a digital companion with absolute narrative continuity, "The Constant" is a Local-First, Unified-Memory AI That evolves its personality and knowledge base in real-time, operating entirely on your own hardware. Unlike fragmented architectures that split "search" and "knowledge," or cloud apps that suffer from "amnesia," "The Constant" utilizes FalkorDB as a single, unified brain. It seamlessly blends Vector Search (for recalling the feeling and exact phrasing of past conversations) with Graph Logic (for maintaining rigorous biographical facts and relationships). Guaranteed to provide the emotional depth of a 70B parameter model with the instant, razor-sharp memory of a high-speed transactional database—zero latency, zero data leaks.


2. Core Pillars

  1. Unified Memory Architecture: By storing Chat Logs (Vectors) as nodes inside the Knowledge Graph, the AI possesses "Contextual Recall." It doesn't just find keywords; it can find "Things I said about my mother (Graph Link) that were sad (Vector Sentiment) in 2024 (Time Link)."
  2. The "Living" World Model: Memory is not a nightly batch job. As you speak, a background process actively listens, extracting new entities (People, Places) and updating their status in the graph instantly. If you change your mind, the graph changes with you.
  3. Latency Masking: The system utilizes the M1 Max's concurrency to perform complex memory operations in the background while the "Reflex" model keeps the conversation flowing, ensuring the user never feels the "compute wait."

3. The Technical Stack (Unified FalkorDB Edition)

Hardware Target: MacBook Pro M1 Max (64GB RAM) Environment: Docker (FalkorDB), Python 3.11, Ollama.

A. The Database (The "Single Source of Truth")

  • Engine: FalkorDB (Docker Container).
  • Configuration:
    • Running in-memory (uses ~2-4GB RAM for large history).
    • Native Vector Indexing: Enabled on Message nodes.
  • Data Model:
    • Nodes: User, Persona, Entity (Person/Place/Topic), Message (The Chat Log).
    • Edges: (:User)-[:SENT]->(:Message), (:Message)-[:MENTIONS]->(:Entity).

B. The Intelligence Layer (Tri-Model Setup)

  • 1. The Persona (The Mouth): Llama-3.1-70B-Instruct (4-bit).
    • Role: Deep conversational synthesis. It receives the combined context from the Graph and Vector search to generate the final reply.
  • 2. The Scribe (The Logical Brain): Llama-3.2-3B-Instruct.
    • Role: Runs in the background. Transforms User Text -> Cypher Queries. (e.g., "Create a node for 'Sarah', link to User").
  • 3. The Embedder (The Vibe): nomic-embed-text-v1.5.
    • Role: Converts every incoming message into a vector float array for FalkorDB storage.

C. The Sensory Layer

  • Input: Whisper (Large-v3) (CoreML optimized).
  • Output: Coqui XTTS_v2 (Streaming Mode).

4. The Mechanism (The Workflow)

This loop executes every time the user speaks.

Phase 1: Ingestion & Retrieval (The "Read" Loop)

  • User Audio: "I'm worried about the presentation tomorrow."
  • Whisper: Transcribes to text.
  • Embedder: Converts text to Vector [0.1, 0.5, ...].
  • FalkorDB Query (Hybrid):
    // 1. Vector Search: Find similar past worries
    CALL db.idx.vector.queryNodes('Message', 'embedding', 3, $vec) YIELD node AS vibe_memory
    
    // 2. Graph Search: Find facts about "Presentation" or "Tomorrow"
    MATCH (u:User)-[:HAS_EVENT]->(e:Event) 
    WHERE e.date = date('tomorrow')
    RETURN vibe_memory.text, e.description
    
  • Result: Retrieves "User was nervous last month" (Vector) AND "Event: Q4 Board Meeting" (Graph).

Phase 2: Generation (The "Speak" Loop)

  • Llama-70B: Receives the context.
  • Output: "Is this about the Q4 Board Meeting? You felt this way last month too, but you crushed it."
  • TTS: Audio streams to user.

Phase 3: Evolution (The "Write" Loop - Background)

  • While the AI is speaking...
  • Llama-3B (Scribe): Analyzes the input "I'm worried about the presentation tomorrow."
  • Action: It realizes "Presentation" implies a future event.
  • Cypher Execution:
    MATCH (u:User)
    MERGE (e:Event {name: 'Presentation', date: date() + duration('P1D')})
    MERGE (u)-[:HAS_EVENT]->(e)
    MERGE (u)-[:FEELING {sentiment: 'anxious'}]->(e)
    
    // Create the Message Node for history
    CREATE (m:Message {text: $text, embedding: $vec, role: 'user'})
    CREATE (u)-[:SENT]->(m)
    

5. Development Roadmap

  1. Week 1: The Falkor Foundation

    • Set up FalkorDB in Docker.
    • Write a Python script to define the Schema (Indexes for Vectors and Names).
    • Test storing a "Message" node with a vector embedding.
  2. Week 2: The Scribe Logic

    • Build the "Text-to-Cypher" pipeline using Llama-3B.
    • Test it: Type "My dog is sick" -> Verify a Dog node appears in the graph with property status: sick.
  3. Week 3: The Hybrid Retrieval

    • Write the Python function that queries FalkorDB for both nearest neighbors (Vector) and direct relationships (Graph) simultaneously.
    • Feed this context into the 70B model.
  4. Week 4: The Senses

    • Hook up Whisper and Coqui TTS.
    • Optimize latency (ensure the Graph writing happens asynchronously so it doesn't block the voice response).