Skip to content

ALI-AL-MARJANI/Neural-Rerank-Engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neural Rerank Engine

PyTorch HuggingFace FAISS


Overview

Standard Vector Search (RAG) often suffers from a "precision" problem: it retrieves documents that are semantically similar but factually irrelevant. Keyword search (BM25) is precise but misses context.

Neural-Rerank-Engine solves this by implementing a standard Retrieve & Rerank architecture:

  1. Stage 1 (Retrieval): Fast retrieval of the top 50 candidates using a Hybrid approach (Sparse BM25 + Dense Bi-Encoder Embeddings).
  2. Stage 2 (Reranking): A heavy Cross-Encoder (BERT) inspects the query-document pairs to re-order results with high semantic understanding.

Key Objectives

  • Maximize Recall: Use Hybrid Search to ensure the correct answer is somewhere in the top candidates.
  • Maximize Precision: Use Reranking to push the best answer to the top 1.
  • Latency Optimization: Balance the speed of FAISS with the accuracy of BERT.

Architecture

Architecture

Performance Benchmarks

We evaluated the system on a subset of the MS MARCO dataset. The results demonstrate a significant precision boost using the hybrid approach:

Method MRR@10 (Accuracy) Avg Latency
BM25 (Sparse) 0.5594 ~7 ms
FAISS (Dense) 0.7977 ~64 ms
Hybrid + Rerank 0.8282 ~165 ms

Future Work & State of the Art

While this project implements the current industry standard (Bi-Encoder + Cross-Encoder), research in Neural Information Retrieval is moving fast.

Research Insight (2025): Listwise Reranking with LLMs :

A promising direction to reduce the computational cost of Cross-Encoders is explored in the paper "LLMs can reason over BM25 scores to Improve Listwise Reranking" (https://arxiv.org/pdf/2506.14086).

The paper suggests that instead of feeding full document text to a heavy model, we can feed retrieval scores and metadata to a lightweight LLM. The LLM can "reason" about the distribution of scores to re-rank documents efficiently.


Project Structure

Neural-Rerank-Engine/
├── data/                
├── notebooks/
│   └── demo.ipynb      
├── src/
│   ├── retrievers/      # Sparse (BM25), Dense (FAISS), & Hybrid Logic
│   ├── rerankers/       # BERT Cross-Encoder 
│   ├── benchmark.py     # Script to calculate MRR & Latency
│   └── build_indices.py # Pipeline to ingest data & build indices
└── requirements.txt










About

Advanced Two-Stage Retrieval Engine with Hybrid Search & Cross-Encoder Reranking

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors