Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -11,3 +11,73 @@ license: apache-2.0
|
|
| 11 |
---
|
| 12 |
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
| 14 |
+
# File: `README.md`
|
| 15 |
+
|
| 16 |
+
```markdown
|
| 17 |
+
# RAG Document Assistant
|
| 18 |
+
|
| 19 |
+
A complete Retrieval-Augmented Generation (RAG) Python project using:
|
| 20 |
+
- HuggingFace Transformers
|
| 21 |
+
- sentence-transformers (for embeddings)
|
| 22 |
+
- ChromaDB (vector store)
|
| 23 |
+
- Gradio (UI)
|
| 24 |
+
|
| 25 |
+
## Project Structure
|
| 26 |
+
```
|
| 27 |
+
|
| 28 |
+
project/
|
| 29 |
+
├── app.py
|
| 30 |
+
├── rag_pipeline.py
|
| 31 |
+
├── generator.py
|
| 32 |
+
├── utils.py
|
| 33 |
+
├── requirements.txt
|
| 34 |
+
├── README.md
|
| 35 |
+
├── data/
|
| 36 |
+
└── db/
|
| 37 |
+
|
| 38 |
+
````
|
| 39 |
+
|
| 40 |
+
## Installation
|
| 41 |
+
1. Create a virtual environment (recommended):
|
| 42 |
+
|
| 43 |
+
```bash
|
| 44 |
+
python -m venv venv
|
| 45 |
+
source venv/bin/activate # on Windows use venv\Scripts\activate
|
| 46 |
+
````
|
| 47 |
+
|
| 48 |
+
2. Install requirements:
|
| 49 |
+
|
| 50 |
+
```bash
|
| 51 |
+
pip install -r requirements.txt
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
3. Run the app:
|
| 55 |
+
|
| 56 |
+
```bash
|
| 57 |
+
python app.py
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
Open the Gradio URL shown in the console (default `http://127.0.0.1:7860`).
|
| 61 |
+
|
| 62 |
+
## How RAG Works (short)
|
| 63 |
+
|
| 64 |
+
1. Documents are uploaded and their text is extracted.
|
| 65 |
+
2. Text is chunked into overlapping passages.
|
| 66 |
+
3. Each chunk is embedded using a pretrained sentence-transformer.
|
| 67 |
+
4. Chunks and embeddings are stored in a vector database (ChromaDB).
|
| 68 |
+
5. At query time, the user question is embedded and used to retrieve most relevant chunks.
|
| 69 |
+
6. Retrieved chunks are passed to a generator LLM which composes a grounded answer.
|
| 70 |
+
|
| 71 |
+
## Notes & Troubleshooting
|
| 72 |
+
|
| 73 |
+
* Textract may need system-level dependencies for PDF/DOCX parsing on some platforms.
|
| 74 |
+
* Large models may require GPUs. For local CPU usage, prefer small models like `flan-t5-small`.
|
| 75 |
+
* If you see memory errors, reduce model size or run on a machine with more RAM.
|
| 76 |
+
|
| 77 |
+
## Roadmap / Improvements
|
| 78 |
+
|
| 79 |
+
* Add user authentication and per-user collections
|
| 80 |
+
* Support incremental indexing and deletion
|
| 81 |
+
* Add streaming generation for long answers
|
| 82 |
+
* Add API endpoints via FastAPI
|
| 83 |
+
|