Skip to content

Living Dossier & Hybrid RAG Retrieval ​

This specification details the 2-hour session chunking algorithm, living dossier summarization, and Hybrid Reciprocal Rank Fusion (RRF) search mechanics.


1. 2-Hour Inactivity Session Chunking (DB-03) ​

Conversation streams are partitioned into coherent sessions using a 2-hour inactivity threshold:

Session Enrichment ​

Each completed session chunk triggers an LLM background summarization:

  • Title Generation: Short 3-6 word semantic topic (e.g. Lunch Meeting & Reservation).
  • Summary: Concise bullet points capturing action items, decisions, and context.
  • Dense Embedding: Generates a 1536-dimensional vector using text-embedding-3-small (or configured embedding model) stored as halfvec(1536) in PostgreSQL.

2. Living Dossiers (DB-04, DB-05) ​

A Living Dossier is an evolving Markdown document maintained for each tracked contact. It synthesizes cross-session knowledge over time:

Dossier Structure ​

markdown
# Dossier: Jane Doe (+15551234567)
*Last Updated: 2026-11-02 08:30 UTC*

## Profile & Key Context
- Close colleague from engineering infrastructure team.
- Prefers communication via RCS / Signal.

## Ongoing Projects & Commitments
- Migration to pgvector 17 (Target: Q4).
- Weekly architecture reviews every Thursday at 10 AM.

## Communication Patterns
- Highly active weekday mornings.
- Frequently exchanges code snippets and architectural diagrams.

Self-Updating Workflow ​

When new sessions are chunked, the system retrieves the previous dossier, feeds it alongside the new session summaries to the LLM (DOSSIER_MODEL), and generates an updated document atomically persisted to PostgreSQL and spooled to /data/dossiers/<contact_id>.md.


3. Hybrid Reciprocal Rank Fusion (RRF) ​

To maximize retrieval recall and precision across complex personal messaging histories, gmessages-rag combines dense vector similarity with lexical Full-Text Search (BM25) using Reciprocal Rank Fusion:

Where:

  • is the smoothing constant (default , configurable via /api/v1/tuner).
  • is the 1-based rank of document within ranking method .

Advantages of Hybrid RRF ​

  • Keyword Exact Match: Captures exact phone numbers, flight confirmation codes, addresses, and timestamps where semantic embeddings often fail.
  • Conceptual Match: Captures broad intent (e.g., "recommendations for dinner") even when words like "restaurant" or "food" were not explicitly mentioned.

Released under AGPL-3.0 License.