Skip to main content
Vector search excels at semantic similarity — understanding that “package manager” and “npm” are related. It struggles with:
  • Exact project names (e.g. “carq”, “memcontext”)
  • Company and product names
  • Acronyms (e.g. “PNPM”, “JWT”)
  • Concrete technical decisions (e.g. “chose PostgreSQL over MySQL”)
For memory retrieval, both semantic and exact-match queries need to work reliably.

MemContext’s approach

MemContext combines two retrieval methods and merges their results:
MethodStrengthsRuns on
Vector searchSemantic similarity, paraphrased queriespgvector embeddings (1536 dimensions)
Full-text searchExact matches, keywords, namesPostgreSQL tsvector index
Both searches run in parallel, so there is almost no added latency. Results are merged using Reciprocal Rank Fusion (RRF), which combines rankings from both methods into a single ordered list.

Query variants

Before searching, MemContext generates alternative phrasings of your query using an LLM. For example:
  • Original: “What database does the project use?”
  • Variant: “database technology PostgreSQL MySQL choice”
  • Variant: “which database was selected for this project”
All variants are embedded and searched in parallel, improving recall without degrading precision.

Configuring search precision

The threshold parameter controls how strict the vector search is:
ThresholdBehaviorUse case
0.2 - 0.4Strict matching, fewer resultsHigh-precision lookups for specific facts
0.6Default balanceGeneral-purpose retrieval
0.7 - 0.8Broad matching, more resultsExploratory searches, gathering related context
The threshold represents maximum vector distance — higher values include more distant (less similar) results.