Production-grade Retrieval-Augmented Generation engine with hybrid search, cross-encoder reranking, and automatic chunk optimization.
- Hybrid Search: BM25 + dense vector search with learned fusion weights
- Cross-Encoder Reranking: BGE reranker for precision retrieval
- Chunk Optimization: Automatic splitting with overlap tuning
- Multi-format Ingestion: PDF, DOCX, HTML, Markdown, code files
- Citation Tracking: Every answer linked to source documents
- Streaming Responses: Real-time token streaming with context injection
- Eval Framework: Built-in RAGAS evaluation metrics
| Dataset | Precision@5 | Recall@5 | F1 | Faithfulness |
|---|---|---|---|---|
| Natural Questions | 0.82 | 0.78 | 0.80 | 0.91 |
| HotpotQA | 0.76 | 0.83 | 0.79 | 0.88 |
| MS MARCO | 0.85 | 0.81 | 0.83 | 0.93 |
pip install rag-enginefrom rag_engine import RAGEngine
engine = RAGEngine(
embedding_model="BAAI/bge-large-en-v1.5",
reranker="BAAI/bge-reranker-v2-m3",
chunk_size=512,
)
# Ingest documents
engine.ingest("./docs/", format="auto")
# Query
result = engine.query("What is the architecture of the system?", top_k=5)
print(result.answer)
print(f"Sources: {result.citations}")pip install rag-engine[all]
# Minimal
pip install rag-engine[core]MIT License