A modular hybrid retrieval system for enterprise-scale document search, combining dense semantic retrieval and sparse keyword retrieval with multi-stage reranking pipelines.
Hybrid Search Engine is a retrieval-focused search infrastructure project designed to efficiently search large document collections using modern information retrieval techniques. The system combines semantic vector-based retrieval with traditional sparse keyword retrieval to improve both retrieval robustness and ranking quality.
The architecture implements:
- Dense semantic retrieval using SentenceTransformer embeddings and FAISS vector indexing
- Sparse keyword retrieval using BM25
- Hybrid retrieval using Reciprocal Rank Fusion (RRF)
- Multi-stage retrieval pipelines with CrossEncoder reranking
- Metadata-aware filtering for enterprise-style document retrieval
- Modular ingestion and retrieval orchestration
The project focuses on retrieval systems engineering and ranking pipelines rather than frontend application development.
Documents
↓
Chunking Pipeline
↓
SentenceTransformer Bi-Encoder Embeddings
↓
FAISS Dense Vector Index
Documents
↓
BM25 Sparse Index
User Query
↓
Dense Retrieval + Sparse Retrieval
↓
Reciprocal Rank Fusion (RRF)
↓
Candidate Generation
↓
CrossEncoder Reranking
↓
Final Ranked Results
- SentenceTransformer-based semantic embeddings
- FAISS vector indexing using
IndexFlatIP - Cosine similarity-based nearest neighbor retrieval
- Embedding normalization for semantic similarity search
- BM25 ranking for exact keyword-based retrieval
- Frequency-aware term scoring
- Improved retrieval robustness for keyword-heavy queries
- Combines dense and sparse retrieval pipelines
- Reciprocal Rank Fusion (RRF) for hybrid ranking
- Improved recall and ranking stability
- Multi-stage retrieval architecture
- Transformer-based reranking for improved precision
- Joint query-document relevance modeling
- Candidate reranking after hybrid retrieval
Supports filtering by:
- Category
- Source
- Document metadata
- Modular ingestion pipeline
- Extensible retrieval orchestration
- Separated indexing and retrieval components
- Easy integration of additional retrieval strategies
Hybrid-Search-Engine/
│
├── data/
│ └── raw_docs/
│
├── ingest/
│ ├── chunker.py
│ ├── embedder.py
│ └── loader.py
│
├── search/
│ ├── bm25_index.py
│ ├── reranker.py
│ ├── retriever.py
│ └── vector_index.py
│
├── test_retrieval.py
├── requirements.txt
└── README.md
Splits large documents into overlapping chunks to improve retrieval granularity and semantic coverage.
Generates semantic embeddings using SentenceTransformer bi-encoder models.
Loads documents, applies chunking, generates embeddings, and constructs retrieval records.
Implements dense vector indexing and nearest neighbor search using FAISS.
Implements sparse retrieval using BM25 ranking.
Implements:
- Dense retrieval
- Sparse retrieval
- Hybrid retrieval
- Reciprocal Rank Fusion
- Metadata filtering
- CrossEncoder reranking pipelines
Implements transformer-based CrossEncoder reranking for final ranking refinement.
- Python
- SentenceTransformers
- FAISS
- BM25
- NumPy
- CrossEncoder models
git clone <repository-url>
cd Hybrid-Search-Enginepython -m venv venvvenv\Scripts\activatesource venv/bin/activatepip install -r requirements.txtPlace .txt documents inside:
data/raw_docs/
Run:
python test_retrieval.pyThe system will:
- Load and preprocess documents
- Chunk documents
- Generate semantic embeddings
- Build FAISS vector index
- Build BM25 sparse index
- Perform hybrid retrieval
- Apply CrossEncoder reranking
- Return final ranked search results
semantic search systems
- Query embedding generation
- Dense semantic retrieval using FAISS
- Sparse keyword retrieval using BM25
- Hybrid fusion using RRF
- Candidate reranking using CrossEncoder
- Final ranked output generation
Dense semantic retrieval improves semantic understanding, while sparse retrieval improves exact keyword matching. Combining both improves retrieval robustness and recall.
RRF provides a lightweight and effective way to combine rankings from heterogeneous retrieval systems without requiring score normalization.
Bi-encoder retrieval is scalable but less precise because queries and documents are encoded independently. CrossEncoders jointly model query-document interactions, significantly improving ranking precision.
CrossEncoder inference is computationally expensive. Therefore, the system first retrieves a smaller high-recall candidate set using efficient retrieval methods before applying expensive reranking.
Potential future extensions include:
- Persistent vector indexes
- PDF and DOCX ingestion
- ANN indexing strategies (IVF, HNSW)
- Retrieval evaluation metrics
- REST API integration
- Distributed vector storage
This project explores core concepts in:
- Information Retrieval (IR)
- Semantic Search
- Dense and Sparse Retrieval
- Vector Databases
- Ranking Systems
- Retrieval Pip