Last updated

Memory Model

The Memory Model is the foundation of Papr Memory, defining how information is structured, stored, and retrieved. It combines vector embeddings with graph relationships to create a rich, contextual memory system.

Core Components

Memory Item

A memory item is the basic unit of information in Papr Memory. It consists of:

{
  "id": "mem_abc123",
  "content": "Meeting notes from our product roadmap session",
  "type": "text",
  "metadata": {
    "topics": "product, planning, roadmap",
    "hierarchical_structures": "Business/Planning/Product",
    "conversationId": "conv-123",
    "sourceUrl": "https://meeting-notes.example.com/123",
    "workspaceId": "ws_456",
    "userId": "user_789",
    "createdAt": "2024-03-20T10:00:00Z"
  }
}

Content Types

Papr Memory supports the following content types as defined in the API specification:

  1. Text (text):

    • Standard text content
    • Meeting notes
    • Chat conversations
    • Notes and summaries
    • JSON
    • Other
  2. Code Snippets (code_snippet):

    • Programming code
    • Scripts
    • Configuration files
    • Technical documentation with code examples
    • Other
  3. Documents (document):

    • PDF files
    • Word documents
    • Markdown documents
    • Text documents

Processing Pipeline

Papr Memory handles all the complex processing for you behind the scenes. As a developer, you simply need to:

  1. Add Memories: Use the /v1/memory API to save content to your knowledge base
  2. Search Memories: Use the /v1/memory/search API to retrieve relevant information

What happens automatically:

Adding Content to Memory

Your Content
Memory API
Process & Chunk
Vector & Graph

Retrieving Content from Memory

Search API
Semantic + Relational Retrieval
Ranking
Results

What Papr Handles For You:

1. Content Processing

  • Automatic chunking and segmentation
  • Format conversion
  • Metadata extraction

2. Knowledge Representation

  • State-of-the-art vector embeddings
  • Automatic relationship discovery
  • Context preservation

3. Storage & Indexing

  • Optimized vector indexing
  • Graph database organization
  • Fast retrieval structures

4. Intelligent Search

  • Semantic similarity matching
  • Multi-hop graph traversal
  • Dynamic result reranking

Memory Organization

Vector Storage

Memory items are transformed into high-dimensional vector embeddings, allowing for semantic similarity search. This means you can find relevant information even when exact keywords don't match.

Graph Structure

Memory items are also organized in a knowledge graph with:

  • Explicit relationships between memories
  • Contextual connections
  • Temporal sequencing
  • Hierarchical organization

Memory Operations

Creating Memories

# Simple memory creation
memory = client.memory.add(
    content="Meeting notes from project kickoff",
    type="text"
)

# Memory with rich metadata
memory = client.memory.add(
    content="Meeting notes from project kickoff",
    type="text",
    metadata={
        "topics": "project, planning, kickoff",
        "hierarchical_structures": "Projects/Atlas/Meetings",
        "conversationId": "conv-123",
        "sourceUrl": "https://meeting-notes.example.com/123",
        "workspaceId": "ws_456",
        "userId": "user_789"
    }
)

Searching Memories

# Simple search with detailed query
results = client.memory.search(
    query="Find the detailed discussion about API rate limiting from our technical design meetings last month. I need information about the proposed limits and any concerns raised by the team."
)

# Advanced search with parameters
results = client.memory.search(
    query="Find all project kickoff meeting notes with action items assigned to the marketing team. Focus on items related to the Q2 product launch.",
    max_memories=15,
    max_nodes=10,
    rank_results=True
)

Best Practices

  1. Provide Detailed Content

    • Be specific and descriptive
    • Include relevant context
    • Use clear, structured formats
  2. Use Rich Metadata

    • Add topics and hierarchical structures
    • Include temporal and location information
    • Use consistent categorization
  3. Write Detailed Search Queries

    • Use 2-3 sentence queries with specific details
    • Include context about why you need the information
    • Specify time frames when relevant
  4. Enable Response Compression

    • Include the Accept-Encoding: gzip header
    • Improves performance with large responses

Next Steps