Spaces:
Running
Running
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,26 +1,37 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: blue
|
| 5 |
-
colorTo:
|
| 6 |
-
sdk:
|
|
|
|
|
|
|
| 7 |
pinned: true
|
| 8 |
-
tags:
|
| 9 |
-
- rag
|
| 10 |
-
- biomedicine
|
| 11 |
-
- oncology
|
| 12 |
-
- clinical-trials
|
| 13 |
-
- hybrid-search
|
| 14 |
---
|
| 15 |
|
| 16 |
-
#
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
##
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: RAG Engine
|
| 3 |
+
emoji: 🧠
|
| 4 |
colorFrom: blue
|
| 5 |
+
colorTo: indigo
|
| 6 |
+
sdk: streamlit
|
| 7 |
+
sdk_version: 1.36.0
|
| 8 |
+
app_file: app.py
|
| 9 |
pinned: true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# RAG Engine 🧠
|
| 13 |
|
| 14 |
+
A modular, educational **Retrieval-Augmented Generation (RAG)** system built to demonstrate core RAG principles:
|
| 15 |
+
1. **Document Ingestion & Chunking** (sliding window with overlap)
|
| 16 |
+
2. **Dense Vector Embeddings** (cosine similarity search)
|
| 17 |
+
3. **Sparse BM25 Keyword Search** (lexical matching for exact terms)
|
| 18 |
+
4. **Hybrid Retrieval with Reciprocal Rank Fusion (RRF)**
|
| 19 |
+
5. **Context-Augmented Generation** with source citations
|
| 20 |
|
| 21 |
+
### 💻 Live Interactive Demo
|
| 22 |
+
Use the tabs on the left to:
|
| 23 |
+
- **💬 Ask Question**: Query the knowledge base with real-time source grounding and faithfulness scoring.
|
| 24 |
+
- **🔬 Pipeline Inspector**: Directly observe the raw output of Vector Search vs. BM25 Search vs. RRF Rank Fusion.
|
| 25 |
+
- **📚 Knowledge Base**: Inspect loaded documents or upload custom text/PDF files to index them immediately.
|
| 26 |
|
| 27 |
+
### 📐 Architecture
|
| 28 |
+
- **Chunking**: ~400-word passages with 50-word overlap to balance semantic focus and boundary continuity.
|
| 29 |
+
- **Embeddings**: Deterministic token hash embeddings by default (100% offline, zero-dependency), compatible with HuggingFace SentenceTransformers.
|
| 30 |
+
- **Hybrid Fusion**: Merges dense and sparse ranks via Reciprocal Rank Fusion:
|
| 31 |
+
RRF(d) = \sum_{m} \frac{w_m}{60 + \text{rank}_m(d)}
|
| 32 |
+
- **Generation**: Formats grounded context into system prompts. Provides extractive summaries on CPU or full LLM generation when an API key is provided.
|
| 33 |
+
|
| 34 |
+
### 🛠️ Transparency & Code
|
| 35 |
+
- **Author**: Jayan Gupta
|
| 36 |
+
- **Source Code & Unit Tests**: [GitHub Repository](https://github.com/JayanGupta/RAG-Engine)
|
| 37 |
+
- **Design Philosophy**: Simple, clean Python without heavy abstraction layers or type boilerplate.
|