Hitan2004 commited on
Commit
53d50d4
·
verified ·
1 Parent(s): 472b56b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +17 -708
README.md CHANGED
@@ -1,714 +1,23 @@
1
- # 🧠 Agentic Corrective RAG — Document Q&A with Self-Correction
2
-
3
- <div align="center">
4
-
5
- **Production-grade document retrieval system with self-correcting agent reasoning**
6
-
7
- [![Frontend UI](https://img.shields.io/badge/Frontend-HuggingFace%20Spaces-blue?style=for-the-badge&logo=huggingface)](https://huggingface.co/spaces/Hitan2004/agentic-corrective-rag-ui)
8
-
9
- [![Backend API](https://img.shields.io/badge/API-HuggingFace%20Spaces-blue?style=for-the-badge&logo=huggingface)](https://huggingface.co/spaces/Hitan2004/agentic-corrective-rag)
10
-
11
- [![API Docs](https://img.shields.io/badge/Swagger-Docs-green?style=for-the-badge)](https://hitan2004-agentic-corrective-rag.hf.space/docs)
12
-
13
- [![GitHub](https://img.shields.io/badge/GitHub-Repository-black?style=for-the-badge&logo=github)](https://github.com/Hitan547/agentic-corrective-rag)
14
-
15
- [![Python](https://img.shields.io/badge/Python-3.10-blue?style=for-the-badge&logo=python)](#tech-stack)
16
-
17
- *Upload documents, ask questions, get answers grounded in source material with automated hallucination detection and self-correction.*
18
-
19
- ## 🎯 Overview
20
-
21
- Agentic Corrective RAG is a production-grade document Q&A system that combines advanced retrieval techniques with intelligent agent reasoning. Unlike naive RAG systems that often hallucinate, this system automatically validates every answer against source material and retries up to 3 times if validation fails.
22
-
23
- ### ⚡ Core Features
24
-
25
- | Feature | Capability |
26
- |---------|-----------|
27
- | **Hybrid Retrieval** | FAISS semantic + BM25 keyword search with RRF fusion |
28
- | **Intelligent Reranking** | Cross-encoder re-scores top-k candidates for precision |
29
- | **Self-Correcting Agent** | LangGraph pipeline validates answers and auto-retries |
30
- | **Hallucination Detection** | Second LLM call verifies every claim against context |
31
- | **Session Memory** | Remembers last 5 conversation turns per session |
32
- | **Streaming Ingestion** | Synchronous indexing with FAISS + BM25 persistence |
33
- | **CI/CD Pipeline** | GitHub Actions with unit + integration test separation |
34
- | **Multi-Service Deployment** | Backend API + separate frontend UI on HuggingFace Spaces |
35
-
36
- ---
37
-
38
- ## 🏗️ Architecture
39
-
40
- ### System Diagram
41
-
42
- ```
43
- ┌─────────────────────────────────────────────────────────┐
44
- │ Agentic Corrective RAG Pipeline │
45
- └─────────────────────────────────────────────────────────┘
46
-
47
- Document Upload
48
-
49
- ┌─────────────────────────────────────────┐
50
- │ Ingestion Pipeline │
51
- │ ┌─────────────────────────────────┐ │
52
- │ │ PyMuPDF / TXT Parser │ │
53
- │ │ Split into 512-token chunks │ │
54
- │ │ 20-token overlap for context │ │
55
- │ └────────────┬────────────────────┘ │
56
- │ │ │
57
- │ ┌────────────▼───────────────────┐ │
58
- │ │ Embedding Generation │ │
59
- │ │ all-MiniLM-L6-v2 (384-dim) │ │
60
- │ └────────────┬───────────────────┘ │
61
- │ │ │
62
- │ ┌────────────▼──────────────────┐ │
63
- │ │ Index Creation │ │
64
- │ │ FAISS (dense vectors) │ │
65
- │ │ BM25 (sparse inverted index) │ │
66
- │ └──────────────────────────────┘ │
67
- └─────────────────────────────────────────┘
68
-
69
- Query Processing
70
-
71
- ┌─────────────────────────────────────────┐
72
- │ Hybrid Retrieval Pipeline │
73
- │ │
74
- │ ┌──────────┐ ┌──────────┐ │
75
- │ │FAISS Top │ │BM25 Top │ │
76
- │ │ 10 Hits │ │ 10 Hits │ │
77
- │ └────┬─────┘ └────┬─────┘ │
78
- │ └────────┬─────────┘ │
79
- │ │ │
80
- │ ┌───────▼──────────┐ │
81
- │ │ RRF Fusion │ │
82
- │ │ (Top 5 combined) │ │
83
- │ └���──────┬──────────┘ │
84
- │ │ │
85
- │ ┌───────▼──────────────────┐ │
86
- │ │ Cross-Encoder Reranking │ │
87
- │ │ ms-marco-MiniLM-L-6-v2 │ │
88
- │ │ Re-score + sort │ │
89
- │ └───────┬──────────────────┘ │
90
- └─────────────────────────────────────────┘
91
-
92
- Agent Reasoning Loop
93
-
94
- ┌─────────────────────────────────────────┐
95
- │ Corrective RAG Agent (LangGraph) │
96
- │ │
97
- │ Generate (LLaMA 3.3 70B) │
98
- │ ├─ Answer using top-3 chunks │
99
- │ └─ Confidence score │
100
- │ ↓ │
101
- │ Validate (LLM Validation Call) │
102
- │ ├─ Is answer grounded? │
103
- │ └─ All claims supported? │
104
- │ ↓ │
105
- │ Retry Logic (up to 3 times) │
106
- │ ├─ If PASS → Return answer │
107
- │ ├─ If FAIL & retries left: │
108
- │ │ → Use failure reason as feedback │
109
- │ │ → Re-retrieve with new query │
110
- │ │ → Regenerate answer │
111
- │ └─ If 3 retries exhausted → Return │
112
- │ best attempt with FAIL verdict │
113
- └─────────────────────────────────────────┘
114
-
115
- Response
116
-
117
- JSON with:
118
- - answer (generated text)
119
- - source_chunks (exact matched context)
120
- - validation_verdict (PASS/FAIL)
121
- - retry_count (0-3)
122
- - confidence (0.0-1.0)
123
- ```
124
-
125
- ### Component Breakdown
126
-
127
- #### 1. **Ingestion (`ingestion.py`)**
128
- Converts documents to searchable indexes
129
-
130
- ```python
131
- def ingest_documents(file_path: str) -> Dict:
132
- """
133
- Input: PDF or TXT file
134
- Process:
135
- 1. Extract text with PyMuPDF or plain read
136
- 2. Split into 512-token chunks (20-token overlap)
137
- 3. Generate embeddings (all-MiniLM-L6-v2)
138
- 4. Create FAISS dense index
139
- 5. Create BM25 sparse index
140
- Output: Ready for retrieval
141
- """
142
- ```
143
-
144
- **Supported Formats:**
145
- - PDF (single/multi-page)
146
- - TXT (plain text)
147
- - Auto-detects and routes to correct parser
148
-
149
- #### 2. **Retriever (`retriever.py`)**
150
- Hybrid search with intelligent ranking
151
-
152
- ```python
153
- def hybrid_retrieve(query: str, k: int = 5) -> List[Chunk]:
154
- """
155
- Process:
156
- 1. Dense retrieval: FAISS semantic search (top 10)
157
- 2. Sparse retrieval: BM25 keyword search (top 10)
158
- 3. RRF Fusion: Merge and rank by reciprocal rank
159
- 4. Cross-Encoder: Re-rank top-5 using semantic + lexical
160
- Output: Top-k chunks with scores
161
- """
162
- ```
163
-
164
- **Fusion Algorithm (RRF):**
165
- ```
166
- For each document d:
167
- score(d) = Σ(1 / (rank_dense(d) + k)) + Σ(1 / (rank_sparse(d) + k))
168
-
169
- Where k=60 (typical offset to avoid division by zero)
170
- ```
171
-
172
- #### 3. **Agent (`agent.py`)**
173
- Self-correcting reasoning loop using LangGraph
174
-
175
- ```python
176
- class CorrectiveRAGAgent:
177
- """
178
- State machine with 4 nodes:
179
-
180
- Generate Node:
181
- - Takes query + top-3 chunks
182
- - Calls LLaMA 3.3 70B
183
- - Returns answer + initial confidence
184
-
185
- Validate Node:
186
- - Takes answer + source chunks
187
- - Calls validation LLM (fact-checking)
188
- - Checks: Is answer grounded? All claims supported?
189
- - Returns verdict (PASS/FAIL)
190
-
191
- Retry Logic:
192
- - If PASS → End, return answer
193
- - If FAIL and retry_count < 3:
194
- → Inform agent of failure reason
195
- → Re-retrieve with modified query
196
- → Regenerate answer
197
- - If 3 retries exhausted → Return best attempt
198
-
199
- Output Node:
200
- - Formats response
201
- - Includes source chunks
202
- - Validation verdict
203
- - Retry count
204
- """
205
- ```
206
-
207
- #### 4. **FastAPI Backend (`main.py`)**
208
- REST API orchestrating the full pipeline
209
-
210
- ```python
211
- @app.post("/upload")
212
- async def upload_document(file: UploadFile) -> Dict:
213
- """
214
- - Receives PDF/TXT file
215
- - Calls ingestion pipeline
216
- - Returns: {status, message, doc_size, chunk_count}
217
- """
218
-
219
- @app.post("/query")
220
- async def query_documents(query: str, session_id: str) -> Dict:
221
- """
222
- - Receives question
223
- - Runs corrective agent
224
- - Returns:
225
- {
226
- "answer": str,
227
- "source_chunks": [chunk1, chunk2, chunk3],
228
- "validation_verdict": "PASS" or "FAIL",
229
- "retry_count": 0-3,
230
- "confidence": 0.0-1.0
231
- }
232
- """
233
- ```
234
-
235
- ---
236
-
237
- ## 🧪 Testing Architecture
238
-
239
- ### Unit Tests (`tests/test_unit.py`)
240
-
241
- ```python
242
- ✅ test_rrf_fusion
243
- - Verifies Reciprocal Rank Fusion math
244
- - Checks score normalization
245
-
246
- ✅ test_cross_encoder_reranking
247
- - Validates reranking modifies order
248
- - Confirms scores are properly scaled
249
-
250
- ✅ test_config_validation
251
- - Ensures chunk_size > 0
252
- - Validates max_retries in range
253
-
254
- ✅ test_chunk_processing
255
- - Tests document splitting logic
256
- - Checks overlap preservation
257
-
258
- ✅ test_agent_routing
259
- - Verifies state machine transitions
260
- - Confirms node execution order
261
- ```
262
-
263
- **Run locally:**
264
- ```bash
265
- pytest tests/test_unit.py -v
266
- ```
267
-
268
- ### Integration Tests (`tests/test_integration.py`)
269
-
270
- ```python
271
- ✅ test_full_pipeline_end_to_end
272
- - Upload document
273
- - Index with FAISS + BM25
274
- - Query with agent
275
- - Validate response structure
276
- - Requires GROQ_API_KEY
277
-
278
- ✅ test_groq_api_connection
279
- - Confirms Groq API is reachable
280
- - Tests actual LLM inference
281
- - Validates response format
282
-
283
- ✅ test_retrieval_quality
284
- - Uploads test document
285
- - Queries for information
286
- - Verifies retrieved chunks contain answer
287
-
288
- ✅ test_agent_hallucination_detection
289
- - Forces out-of-context query
290
- - Confirms validation catches hallucination
291
- - Checks retry mechanism
292
- ```
293
-
294
- **Run locally (requires API key):**
295
- ```bash
296
- export GROQ_API_KEY=your_key
297
- pytest tests/test_integration.py -v -m integration
298
- ```
299
-
300
- ### CI/CD Test Strategy
301
-
302
- **GitHub Actions:**
303
- ```yaml
304
- on: [push, pull_request]
305
-
306
- jobs:
307
- test:
308
- runs-on: ubuntu-latest
309
- steps:
310
- - uses: actions/checkout@v3
311
- - uses: actions/setup-python@v4
312
- - run: pip install -r requirements.txt
313
- - run: pytest tests/test_unit.py -v
314
- # ✅ Unit tests run (fast, no API)
315
- - run: pytest tests/test_integration.py -v -m "not integration"
316
- # ✅ Integration tests skip (expensive API calls)
317
- ```
318
-
319
- **Key Insight:** Tests marked with `@pytest.mark.integration` are automatically skipped in CI but run locally with API key. This prevents wasting API credits while maintaining code quality.
320
-
321
  ---
322
-
323
- ## 📊 Model & LLM Stack
324
-
325
- ### Retrieval Models
326
-
327
- | Component | Model | Capability |
328
- |-----------|-------|-----------|
329
- | **Dense Embeddings** | `all-MiniLM-L6-v2` | 384-dim vectors, optimized for retrieval |
330
- | **Sparse Search** | BM25 (rank-bm25 lib) | Keyword indexing, recall enhancement |
331
- | **Reranker** | `cross-encoder/ms-marco-MiniLM-L-6-v2` | Semantic + lexical re-scoring |
332
-
333
- ### Reasoning Engine
334
-
335
- | Component | Model | Role |
336
- |-----------|-------|------|
337
- | **Main Generator** | LLaMA 3.3 70B (Groq API) | Answer generation from context |
338
- | **Validator** | LLaMA 3.3 70B (Groq API) | Hallucination detection & fact-checking |
339
-
340
- ### Why These Choices?
341
-
342
- ✅ **all-MiniLM-L6-v2**
343
- - 384-dim embeddings (good balance of size/quality)
344
- - Specifically trained for retrieval tasks
345
- - Fast inference, low memory
346
-
347
- ✅ **BM25**
348
- - Complementary to dense embeddings (catches keyword matches)
349
- - Sparse representation (memory efficient)
350
- - Proven effective in hybrid search
351
-
352
- ✅ **Cross-Encoder Reranking**
353
- - Reads query + chunk together (interaction model)
354
- - Higher precision than encoding separately
355
- - Scales to top-k reranking
356
-
357
- ✅ **LLaMA 3.3 70B via Groq**
358
- - Strong reasoning on diverse topics
359
- - Fast inference (Groq's optimized runtime)
360
- - Production-grade availability
361
- - Cost-effective for hobby projects
362
-
363
- ---
364
-
365
- ## 🚀 Quick Start
366
-
367
- ### Prerequisites
368
- - Python 3.10+
369
- - Free Groq API key (from console.groq.com)
370
- - 1GB disk for models + indexes
371
-
372
- ### Local Setup (10 minutes)
373
-
374
- ```bash
375
- # 1. Clone repository
376
- git clone https://github.com/Hitan547/agentic-corrective-rag.git
377
- cd agentic-corrective-rag
378
-
379
- # 2. Create virtual environment
380
- python -m venv venv
381
- source venv/bin/activate # Windows: venv\Scripts\activate
382
-
383
- # 3. Install dependencies
384
- pip install -r requirements.txt
385
-
386
- # 4. Set up environment
387
- echo "GROQ_API_KEY=your_api_key_here" > .env
388
-
389
- # 5. Run backend
390
- uvicorn main:app --reload --port 8000
391
-
392
- # 6. In another terminal, serve frontend
393
- python -m http.server 3000 --directory ui
394
-
395
- # 7. Open browser
396
- # → http://localhost:3000/index.html
397
- ```
398
-
399
- ### Docker Setup
400
-
401
- ```bash
402
- # Build
403
- docker build -t agentic-rag:latest .
404
-
405
- # Run
406
- docker run -e GROQ_API_KEY=your_key -p 8000:8000 agentic-rag:latest
407
-
408
- # Access at http://localhost:8000
409
- ```
410
-
411
- ### HuggingFace Spaces Deployment
412
-
413
- **Backend Space:**
414
- 1. Create new Space (Python)
415
- 2. Add secret: `GROQ_API_KEY`
416
- 3. Push repo (includes Dockerfile)
417
- 4. Auto-deploys as FastAPI service
418
-
419
- **Frontend Space:**
420
- 1. Create new Space (Static)
421
- 2. Push `ui/` directory
422
- 3. Serves HTML directly
423
-
424
- ---
425
-
426
- ## 🔌 REST API Reference
427
-
428
- ### GET `/health`
429
- System health check
430
-
431
- **Response:**
432
- ```json
433
- {
434
- "status": "online",
435
- "model": "corrective-rag-v1",
436
- "indexes": {
437
- "faiss": "ready",
438
- "bm25": "ready"
439
- },
440
- "sessions": 42
441
- }
442
- ```
443
-
444
- ### POST `/upload`
445
- Upload and index a document
446
-
447
- **Request:**
448
- ```bash
449
- curl -X POST \
450
- -F "file=@document.pdf" \
451
- http://localhost:8000/upload
452
- ```
453
-
454
- **Response:**
455
- ```json
456
- {
457
- "status": "success",
458
- "message": "Document indexed successfully",
459
- "doc_name": "document.pdf",
460
- "chunk_count": 24,
461
- "token_count": 12345,
462
- "file_size_bytes": 2048000
463
- }
464
- ```
465
-
466
- ### POST `/query`
467
- Ask a question about uploaded documents
468
-
469
- **Request:**
470
- ```json
471
- {
472
- "query": "What is the main thesis?",
473
- "session_id": "user_123",
474
- "temperature": 0.7,
475
- "max_retries": 3
476
- }
477
- ```
478
-
479
- **Response:**
480
- ```json
481
- {
482
- "answer": "The main thesis argues that...",
483
- "source_chunks": [
484
- {
485
- "text": "The thesis states that...",
486
- "chunk_id": 3,
487
- "score": 0.92
488
- },
489
- {
490
- "text": "This is supported by...",
491
- "chunk_id": 5,
492
- "score": 0.87
493
- }
494
- ],
495
- "validation_verdict": "PASS",
496
- "retry_count": 0,
497
- "confidence": 0.94,
498
- "processing_time_ms": 3200
499
- }
500
- ```
501
-
502
- ### DELETE `/session/{id}`
503
- Clear conversation history for a session
504
-
505
- **Response:**
506
- ```json
507
- {
508
- "status": "success",
509
- "message": "Session cleared"
510
- }
511
- ```
512
-
513
- ### GET `/docs`
514
- Interactive Swagger UI
515
-
516
- Navigate to: `http://localhost:8000/docs`
517
-
518
- ---
519
-
520
- ## 📁 Project Structure
521
-
522
- ```
523
- agentic-corrective-rag/
524
- ├── agent.py
525
- │ └── CorrectiveRAGAgent
526
- │ ├── generate(query, chunks) → answer
527
- │ ├── validate(answer, chunks) → verdict
528
- │ └── retry_loop() → final_answer
529
- ├── retriever.py
530
- │ ├── hybrid_retrieve() → RRF + reranking
531
- │ ├── faiss_search() → dense vectors
532
- │ └── bm25_search() → keyword search
533
- ├── ingestion.py
534
- │ ├── ingest_pdf()
535
- │ ├── ingest_txt()
536
- │ └── create_indexes() → FAISS + BM25
537
- ├── main.py
538
- │ ├── FastAPI app
539
- │ ├── /upload endpoint
540
- │ ├── /query endpoint
541
- │ └── /session/{id} endpoint
542
- ├── config.py
543
- │ ├── CHUNK_SIZE = 512
544
- │ ├── CHUNK_OVERLAP = 20
545
- │ ├── MAX_RETRIES = 3
546
- │ └── MODEL_PARAMS = {...}
547
- ├── requirements.txt
548
- ├── Dockerfile
549
- ├── .github/workflows/ci.yml
550
- ├── ui/
551
- │ └── index.html (static HTML/JS frontend)
552
- ├── tests/
553
- │ ├── test_unit.py
554
- │ │ ├── test_rrf_fusion
555
- │ │ ├── test_cross_encoder_reranking
556
- │ │ └── test_config_validation
557
- │ └── test_integration.py
558
- │ ├── test_full_pipeline_end_to_end
559
- │ ├── test_groq_api_connection
560
- │ └── test_agent_hallucination_detection
561
- └── README.md
562
- ```
563
-
564
- ---
565
-
566
- ## 🔄 CI/CD Pipeline
567
-
568
- ### GitHub Actions Workflow
569
-
570
- **Trigger:** Push to main or PR
571
-
572
- ```yaml
573
- jobs:
574
- test:
575
- runs-on: ubuntu-latest
576
-
577
- steps:
578
- - uses: actions/checkout@v3
579
- - uses: actions/setup-python@v4
580
- with:
581
- python-version: '3.10'
582
-
583
- - name: Install dependencies
584
- run: pip install -r requirements.txt
585
-
586
- - name: Run unit tests
587
- run: pytest tests/test_unit.py -v
588
- # ✅ Fast tests, no external API calls
589
-
590
- - name: Skip integration tests in CI
591
- run: pytest tests/test_integration.py -v -m "not integration"
592
- # ✅ Prevents wasting Groq API credits
593
-
594
- - name: Docker build test
595
- run: docker build -t agentic-rag:test .
596
- # ✅ Ensures Dockerfile is valid
597
- ```
598
-
599
- ### Deployment Pipeline
600
-
601
- **Backend (API Service):**
602
- 1. HuggingFace Space (Docker runtime)
603
- 2. Auto-deploys on push to `main`
604
- 3. Exposes FastAPI at `https://hitan2004-agentic-corrective-rag.hf.space`
605
-
606
- **Frontend (Static Service):**
607
- 1. HuggingFace Space (Static runtime)
608
- 2. Auto-deploys on push to `main`
609
- 3. Serves HTML at `https://hitan2004-agentic-corrective-rag-ui.hf.space`
610
-
611
- ---
612
-
613
- ## 🎓 What I Learned
614
-
615
- ✅ **Advanced Retrieval**
616
- - Hybrid search (dense + sparse) outperforms single modality
617
- - RRF fusion effectively combines different ranking signals
618
- - Cross-encoders improve precision over bi-encoders
619
- - Trade-off: reranking adds latency but improves quality
620
-
621
- ✅ **Agent-Based Reasoning**
622
- - State machines (LangGraph) cleanly express retry logic
623
- - Validation is critical for production RAG systems
624
- - Feedback loops enable graceful degradation
625
- - Session memory prevents repeated errors
626
-
627
- ✅ **Production ML System Design**
628
- - Test separation (unit vs. integration) reduces CI/CD costs
629
- - Configuration as code improves reproducibility
630
- - Synchronous indexing ensures consistency
631
- - Proper error handling for external API calls
632
-
633
- ✅ **LLM Integration**
634
- - Groq API's speed enables interactive applications
635
- - Temperature tuning affects consistency vs. creativity
636
- - Prompt engineering for specific tasks (validation vs. generation)
637
- - Cost-benefit of multi-turn API calls
638
-
639
- ✅ **Full-Stack Web Development**
640
- - FastAPI for modern async backends
641
- - Static HTML/JS for simple UIs
642
- - Docker for reproducible deployments
643
- - GitHub Actions for automated testing and CI/CD
644
-
645
- ---
646
-
647
- ## 📈 Performance Metrics
648
-
649
- ### Retrieval Quality
650
-
651
- | Scenario | Metric | Value |
652
- |----------|--------|-------|
653
- | Exact answer in docs | Recall@3 | 94% |
654
- | Paraphrased answer | Recall@5 | 87% |
655
- | Complex multi-doc answer | Recall@10 | 92% |
656
-
657
- ### Agent Performance
658
-
659
- | Metric | Value |
660
- |--------|-------|
661
- | Validation PASS rate (correct answers) | 97% |
662
- | Hallucination detection rate | 94% |
663
- | Avg retries (when needed) | 1.2 |
664
- | Zero-shot success (no retries) | 89% |
665
-
666
- ### Latency (end-to-end, on Groq API)
667
-
668
- | Operation | Time |
669
- |-----------|------|
670
- | Hybrid retrieval | 200ms |
671
- | Reranking (top-10) | 150ms |
672
- | LLM generation | 1500ms |
673
- | Validation call | 1200ms |
674
- | **Total (no retries)** | **3050ms** |
675
-
676
- ---
677
-
678
- ## 🤝 Contributing
679
-
680
- This is a portfolio project. Contributions are welcome!
681
-
682
- **Ideas for enhancement:**
683
- - [ ] Add multi-document support (merge indexes)
684
- - [ ] Implement persistent vector DB (Pinecone/Weaviate)
685
- - [ ] Add citation highlighting in frontend
686
- - [ ] Implement streaming responses with Server-Sent Events
687
- - [ ] Add support for images (multimodal embeddings)
688
-
689
- ---
690
-
691
- ## 📜 License
692
-
693
- MIT License — Use freely for learning or commercial purposes.
694
-
695
- ---
696
-
697
- ## 📞 Contact
698
-
699
- **Hitan K** — AI Systems Engineer
700
-
701
- - 🔗 [LinkedIn](https://linkedin.com/in/hitan-k)
702
- - 🐙 [GitHub](https://github.com/Hitan547)
703
- - 🤗 [HuggingFace](https://huggingface.co/Hitan2004)
704
- - 📧 [Email](mailto:hitan.k@outlook.com)
705
-
706
  ---
707
 
708
- <div align="center">
709
 
710
- **⭐ Found this helpful? Please star the repo! ⭐**
711
 
712
- *Built with ❤️ for production and learning.*
 
 
 
 
 
713
 
714
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Agentic Corrective RAG
3
+ emoji: 🤖
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: docker
7
+ app_file: main.py
8
+ pinned: false
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  ---
10
 
11
+ # 🤖 Agentic Corrective RAG
12
 
13
+ AI-powered Retrieval-Augmented Generation system with self-correcting agent loop.
14
 
15
+ ## Features
16
+ - Hybrid Retrieval (FAISS + BM25)
17
+ - Cross-Encoder Reranking
18
+ - Agent-based reasoning with retries
19
+ - Groq LLM integration
20
+ - CI/CD with GitHub Actions
21
 
22
+ ## Usage
23
+ Upload documents and ask questions to get accurate answers with sources.