Querying
Remem offers two query modes optimized for different use cases: Fast for low-latency retrieval and Rich for comprehensive LLM-powered answers.Query Modes Overview
Fast Mode
Target:
<100ms
Best for: Agent context injection, real-time lookups, high-volume automationReturns raw ranked results using hybrid BM25 + vector search with no LLM overhead.Rich Mode
Target:
<2s (budget-aware)
Best for: User-facing Q&A, research queries, complex questionsAdds query expansion, reranking, and optional LLM synthesis with citations.Tradeoff: Fast mode prioritizes speed for high-volume agent queries. Rich mode sacrifices latency for deeper understanding and synthesis, ideal for interactive use.
POST /v1/query
The primary query endpoint supports both modes.Minimal Fast Query
Rich Query with Synthesis
Request Parameters
GET /v1/search
Convenience endpoint for fast-mode search via query parameters.Query Parameters
This endpoint is equivalent to
POST /v1/query with mode: "fast" and no filters. Use it for simple integrations.Namespace Scope
Querying is namespace-aware.
Namespace scope is applied before results are returned. Sensitivity scope is still enforced on top of that.
Query one namespace
Query several namespaces
Query all readable namespaces explicitly
How Fast Mode Works
Fast mode uses hybrid retrieval to combine lexical and semantic search.1
Embed Query
User query → voyage-3.5-lite embedding (cached for 30 min)
2
Parallel Retrieval
- Vector Search: Qdrant cosine similarity on embeddings
- BM25 Keyword Search: PostgreSQL full-text search on
tsvectorindex
3
Reciprocal Rank Fusion (RRF)
Merge results from both systems using weighted RRF:This balances semantic understanding (vector) with exact keyword matches (BM25).
4
Decrypt & Return
Fetch top-ranked chunks from PostgreSQL, decrypt content, and return results with scores.
PageIndex is not used in fast mode. It is only blended into rich mode to enhance long-document retrieval.
How Rich Mode Works
Rich mode extends fast mode with query understanding and LLM synthesis.1
Query Expansion (Grok)
Generates 2 variant queries to catch different phrasings:
- Original: “What are our Q1 priorities?”
- Variant 1: “first quarter objectives 2026”
- Variant 2: “goals for January through March”
2
Parallel Retrieval
Runs hybrid search for original + expanded queries concurrently.
3
RRF Multi-Fusion
Merges all result lists:
- Original query results weighted 2x
- Expansion variants weighted 1x each
4
LLM Reranking (Grok)
Rescores top 30 candidates by semantic relevance to the original query.
5
PageIndex Node Selection (Optional)
For long PDFs and Markdown files that have a PageIndex tree, Remem reranks the node summaries and
attaches the top nodes (default: 2 per document) to the candidate set. This helps synthesis cite
the most relevant sections in very long documents.
6
LLM Synthesis (Grok, optional)
If
synthesize: true, writes a concise answer with [1], [2] source citations.7
Budget-Aware Cutoff
If time budget is exhausted, skips rerank/synthesis and returns fast results.
Caching: Expansion and rerank results are cached in Redis for 15 minutes. Repeated queries on similar topics are ~3x faster (~3s vs ~8s cold start).
Filters
Filters narrow search scope using document metadata assigned during classification.Available Filters
Dynamic categories and tags: Unlike traditional systems, Remem doesn’t use predefined categories. The LLM classifier assigns categories and tags based on content, so they vary by document.
Filtered Query Example
Filter to meeting notes from the last week:Combining Filters
Filters are applied with AND logic. Example: confidential invoices from Amazon in Q4 2025:Session-Memory Filter Example
Retrieve only one coding session’s checkpoints:Response Structure
Fast Mode Response
Rich Mode Response with Synthesis
Response Fields
Querying with Facts
When the Memory Layer is enabled, queries can return extracted facts alongside document chunks.Request Parameters
Example: Query with Facts
Response with Facts
The response includes afacts array and fact_count alongside the normal results:
Fact Response Fields
Entity and Fact Browsing Endpoints
In addition to querying, you can browse entities and their facts directly:Sensitivity Scoping
API keys have a maximum sensitivity level that automatically filters query results.Sensitivity Hierarchy
How It Works
- Automatic filtering: A key with
internalmax sensitivity will never seeconfidentialorpersonaldocuments, even if explicitly requested via filters. - The
sensitivityfilter further narrows within the key’s allowed scope. - Example: A key with
internalmax can filter to["public"]or["public", "internal"], but not["confidential"].
Example: public-only key
Example: public-only key
Key created with This key can only access documents classified as
max_sensitivity: "public":public. All queries automatically filter to sensitivity: ["public"].Example: internal key querying public docs
Example: internal key querying public docs
Key with This returns only public documents, even though the key could access internal docs.
max_sensitivity: "internal" can explicitly request public docs:Tips and Best Practices
Use Fast Mode for Agents
Fast mode’s
<500ms latency makes it ideal for:- Agent context injection (MCP, tool calls)
- Real-time autocomplete
- High-volume background jobs
Use Rich Mode for Humans
Rich mode with synthesis is perfect for:
- User-facing Q&A interfaces
- Research and deep dives
- Complex multi-part questions
Query Design
Troubleshooting Empty Results
Is the document processed yet?
Is the document processed yet?
Documents are ingested asynchronously. Check the job status or wait a few seconds after ingestion before querying.
Does your API key's sensitivity scope cover the document?
Does your API key's sensitivity scope cover the document?
If your key has
max_sensitivity: "internal", it can’t see confidential or personal docs. Check the key’s scoping.Are your filters too restrictive?
Are your filters too restrictive?
Try removing filters one by one to see which is excluding results. Categories and tags are LLM-assigned and may not match your expectations.
Is the query too broad or too narrow?
Is the query too broad or too narrow?
Very broad queries (“meetings”) may return low scores. Very narrow queries (“invoice #12345 from Amazon on Jan 15”) may miss documents if metadata doesn’t match exactly.