Vector stores, reranking, and persistent indexing

Graduate from keyword search to semantic vector retrieval

KeywordIndex misses synonyms ('cancel plan' vs 'terminate subscription'). Vector stores embed meaning into dense vectors so semantically related passages match even with zero shared keywords — and rerank=True re-scores top hits for maximum precision.

Example

from praisonai import KnowledgeConfig

local_chroma = KnowledgeConfig(
    sources=['docs/policies.md', 'docs/faq.pdf'],
    vector_store='chroma',
    retrieval_k=5,
    retrieval_threshold=0.7,
    rerank=True,
)
print('Sources:', local_chroma.sources)
print('Vector store:', local_chroma.vector_store, '| Rerank:', local_chroma.rerank, '| Threshold:', local_chroma.retrieval_threshold)

Try it Yourself

Example explained

  • vector_store='chroma' — Persists embeddings locally on disk so you don't re-embed documents on every script restart.
  • retrieval_threshold=0.7 — Drops weak low-similarity matches before they pollute the agent's context.
  • rerank=True — Re-orders candidate chunks by exact relevance to the question.

Picking the right backend for your scale

Under 500 notes: KeywordIndex or local ChromaDB. 1k–100k docs in a team service: Qdrant or pgvector. User-personalized memory + facts: Mem0. Never spin up a distributed cluster for 20 markdown files.

Common pitfall: re-embedding every PDF on every user request

Indexing is a build/ingestion job, not a per-query operation. Persist your vector store directory once and only re-index files whose hash changed.

Reference: documentation