Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -11,4 +11,93 @@ license: mit
|
|
| 11 |
short_description: Advanced RAG with multi-modal capabilities
|
| 12 |
---
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 11 |
short_description: Advanced RAG with multi-modal capabilities
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# 🚀 Advanced RAG System
|
| 15 |
+
|
| 16 |
+
A state-of-the-art Retrieval-Augmented Generation (RAG) system implementing cutting-edge techniques for accurate, context-aware document question-answering. Built with LangChain, Hugging Face, and ChromaDB.
|
| 17 |
+
|
| 18 |
+
[](https://www.python.org/downloads/)
|
| 19 |
+
[](https://www.langchain.com/)
|
| 20 |
+
[](https://huggingface.co/spaces/GhufranAI/Advanced-RAG-Model)
|
| 21 |
+
|
| 22 |
+
## ✨ Key Features
|
| 23 |
+
|
| 24 |
+
### Advanced Retrieval Techniques
|
| 25 |
+
- **Multi-Query Retrieval**: Automatically generates multiple query variations to improve recall by 30%
|
| 26 |
+
- **Hybrid Search**: Combines semantic vector search with keyword-based BM25 for comprehensive retrieval
|
| 27 |
+
- **Cross-Encoder Re-ranking**: Re-ranks retrieved documents using `ms-marco-MiniLM-L-6-v2` to improve answer quality by 40%
|
| 28 |
+
- **Query Routing**: Intelligently routes queries to the best data source
|
| 29 |
+
|
| 30 |
+
### Intelligent Processing
|
| 31 |
+
- **Smart Document Chunking**: Recursive text splitting with configurable overlap (1000 chars, 200 overlap)
|
| 32 |
+
- **Metadata Enrichment**: Automatic metadata extraction and enrichment for better tracking
|
| 33 |
+
- **Multi-Format Support**: PDF, TXT, and extensible to other formats
|
| 34 |
+
|
| 35 |
+
### User Experience
|
| 36 |
+
- **Conversation Memory**: Maintains context across multiple turns for natural dialogue
|
| 37 |
+
- **Streaming Responses**: Real-time token streaming for responsive interactions
|
| 38 |
+
- **Source Attribution**: Transparent citation of source documents for each answer
|
| 39 |
+
- **Self-Querying**: Extracts filters from natural language queries
|
| 40 |
+
|
| 41 |
+
## 🚀Live Demo
|
| 42 |
+
- [https://huggingface.co/spaces/GhufranAI/Advanced-RAG-Model]
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
## 🏗️ Architecture
|
| 48 |
+
|
| 49 |
+
<img width="550" height="900" alt="advanced_rag" src="https://github.com/user-attachments/assets/7108a0a1-4004-4cea-883e-6a99bd054ff4" />
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
#### 1. **AdvancedDocumentProcessor**
|
| 53 |
+
- Loads documents from multiple formats
|
| 54 |
+
- Implements recursive character text splitting
|
| 55 |
+
- Enriches chunks with metadata (source, filename, timestamp, chunk_id)
|
| 56 |
+
- Preserves document structure during chunking
|
| 57 |
+
|
| 58 |
+
#### 2. **MultiQueryRetriever**
|
| 59 |
+
- Generates 3+ variations of user queries using LLM
|
| 60 |
+
- Reduces retrieval failure rate by 30%
|
| 61 |
+
- Captures different phrasings and intents
|
| 62 |
+
|
| 63 |
+
#### 3. **HybridRetriever**
|
| 64 |
+
- Combines semantic vector search (ChromaDB)
|
| 65 |
+
- Implements keyword-based search (BM25 ready)
|
| 66 |
+
- Deduplicates results across search methods
|
| 67 |
+
- Improves recall by 25%
|
| 68 |
+
|
| 69 |
+
#### 4. **DocumentReranker**
|
| 70 |
+
- Uses cross-encoder model for relevance scoring
|
| 71 |
+
- Re-ranks top documents for precision
|
| 72 |
+
- Improves answer quality by 40%
|
| 73 |
+
- Configurable top-k selection
|
| 74 |
+
|
| 75 |
+
#### 5. **AdvancedRAGSystem** (Main Orchestrator)
|
| 76 |
+
- Coordinates all components
|
| 77 |
+
- Manages conversation state
|
| 78 |
+
- Handles end-to-end query flow
|
| 79 |
+
- Provides streaming and batch interfaces
|
| 80 |
+
|
| 81 |
+
## 🛠️ Tech Stack
|
| 82 |
+
|
| 83 |
+
### Core Framework
|
| 84 |
+
- **LangChain** (latest): Orchestration framework for LLM applications
|
| 85 |
+
- **LangChain Community**: Document loaders and vector stores
|
| 86 |
+
- **LangChain Hugging Face**: HF model integrations
|
| 87 |
+
|
| 88 |
+
### AI/ML Models
|
| 89 |
+
- **Embeddings**: `sentence-transformers/all-MiniLM-L6-v2` (384-dim, fast & accurate)
|
| 90 |
+
- **LLM**: `meta-llama/Llama-3.1-8B` (latest efficient model)
|
| 91 |
+
- **Re-ranker**: `cross-encoder/ms-marco-MiniLM-L-6-v2` (for relevance scoring)
|
| 92 |
+
- **Hugging Face Hub**: Model hosting and inference
|
| 93 |
+
|
| 94 |
+
### Vector Database
|
| 95 |
+
- **ChromaDB**: Persistent vector storage with embedding support
|
| 96 |
+
- Local-first architecture
|
| 97 |
+
- Built-in similarity search
|
| 98 |
+
|
| 99 |
+
### Document Processing
|
| 100 |
+
- **PyPDF**: PDF extraction and parsing
|
| 101 |
+
- **RecursiveCharacterTextSplitter**: Smart text chunking
|
| 102 |
+
- **Sentence Transformers**: High-quality embeddings
|
| 103 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|