How it works
1
Indexing
Each document’s text is embedded using
HuggingFaceEmbeddings (created via EmbedderHelper.create_embedder(config)). The resulting float vector and document metadata are stored in the target backend through the backend’s LangChain integration.2
Query embedding
At search time, the same embedder model embeds the query string via
EmbedderHelper.embed_query(embedder, query).3
Nearest-neighbor retrieval
The LangChain retriever performs approximate nearest-neighbor search and returns the top-k most similar documents.
4
Optional generation
If
rag.enabled: true, retrieved documents are formatted into a prompt using RAGHelper.format_prompt() and passed to a ChatGroq LLM for answer generation.Pipeline implementation
The semantic search pipeline is implemented as two classes per backend: one for indexing and one for search.Indexing pipeline
src/vectordb/langchain/semantic_search/indexing/chroma.py
Search pipeline
src/vectordb/langchain/semantic_search/search/chroma.py
Configuration
Embedding helper
TheEmbedderHelper provides static methods for creating and using HuggingFace embedding models:
src/vectordb/langchain/utils/embeddings.py
RAG helper
TheRAGHelper creates LLMs and formats prompts for answer generation:
src/vectordb/langchain/utils/rag.py
When to use it
- Natural-language questions where query phrasing differs from document vocabulary
- General-purpose RAG baseline before specializing with advanced features
- Any corpus where exact keyword overlap between query and documents is unreliable
When not to use it
Tradeoffs
Settings to tune first
The primary quality lever; the model determines how semantically meaningful similarity scores are.Common choices:
sentence-transformers/all-MiniLM-L6-v2: Fast, 384-dimensionalsentence-transformers/all-mpnet-base-v2: Higher quality, 768-dimensionalBAAI/bge-small-en-v1.5: Strong retrieval performance
Controls the number of returned candidates; too small misses evidence, too large increases downstream cost.
Corpus size for experiments; start small to validate pipeline, then scale up.
Common pitfalls
Backends supported
Chroma, Milvus, Pinecone, Qdrant, Weaviate.Next steps
Add reranking
Add two-stage retrieval for better final-result precision
Hybrid search
Switch to hybrid indexing if queries mix natural language with domain keywords
Metadata filtering
Add metadata filtering if the corpus has reliable structured attributes
Components
Explore reusable components for query enhancement and compression