Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,12 +1,127 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
π RAG AI Assistant β Document-Aware Chatbot Powered by Retrieval-Augmented Generation
|
| 2 |
+
|
| 3 |
+
Welcome to the RAG AI Assistant, a lightweight, open-source document question-answering system that lets you chat with your own knowledge base.
|
| 4 |
+
|
| 5 |
+
Upload documents β Rebuild the index β Ask questions β Get grounded, explainable answers sourced from your files.
|
| 6 |
+
|
| 7 |
+
Built with:
|
| 8 |
+
|
| 9 |
+
FAISS for fast vector search
|
| 10 |
+
|
| 11 |
+
Sentence Transformers for embeddings
|
| 12 |
+
|
| 13 |
+
Transformers QA pipeline for extraction
|
| 14 |
+
|
| 15 |
+
Gradio Blocks UI for clean chat + KB management
|
| 16 |
+
|
| 17 |
+
π Features
|
| 18 |
+
π§ Retrieval-Augmented Generation (RAG)
|
| 19 |
+
|
| 20 |
+
The assistant retrieves relevant document chunks and uses a QA model to produce accurate, grounded answers.
|
| 21 |
+
|
| 22 |
+
π Knowledge Base Uploads
|
| 23 |
+
|
| 24 |
+
You can upload your own documents directly inside the Space:
|
| 25 |
+
|
| 26 |
+
Supported formats:
|
| 27 |
+
|
| 28 |
+
txt, md, pdf, docx, doc
|
| 29 |
+
|
| 30 |
+
βοΈ Rebuildable FAISS Index
|
| 31 |
+
|
| 32 |
+
After uploading files, click Rebuild index to update the vector store instantly β no need to restart the Space.
|
| 33 |
+
|
| 34 |
+
π¬ Interactive Chat
|
| 35 |
+
|
| 36 |
+
Ask free-form questions about your uploaded documents.
|
| 37 |
+
|
| 38 |
+
The model will:
|
| 39 |
+
|
| 40 |
+
Retrieve relevant context
|
| 41 |
+
|
| 42 |
+
Extract answers
|
| 43 |
+
|
| 44 |
+
Show confidence scores
|
| 45 |
+
|
| 46 |
+
Cite the source document
|
| 47 |
+
|
| 48 |
+
π Full Transparency
|
| 49 |
+
|
| 50 |
+
If no answer is found, youβll receive helpful suggestions and context previews.
|
| 51 |
+
|
| 52 |
+
π οΈ How It Works
|
| 53 |
+
1. Chunking
|
| 54 |
+
|
| 55 |
+
Documents are split into overlapping chunks:
|
| 56 |
+
|
| 57 |
+
Size: 500 characters
|
| 58 |
+
|
| 59 |
+
Overlap: 50 characters
|
| 60 |
+
|
| 61 |
+
2. Embedding
|
| 62 |
+
|
| 63 |
+
Each chunk is embedded with:
|
| 64 |
+
|
| 65 |
+
sentence-transformers/all-MiniLM-L6-v2
|
| 66 |
+
|
| 67 |
+
3. Vector Search
|
| 68 |
+
|
| 69 |
+
FAISS (IndexFlatIP) finds the closest matches using cosine similarity.
|
| 70 |
+
|
| 71 |
+
4. Answer Extraction
|
| 72 |
+
|
| 73 |
+
A QA model extracts precise answers:
|
| 74 |
+
|
| 75 |
+
deepset/roberta-base-squad2
|
| 76 |
+
|
| 77 |
+
π§ͺ Usage Instructions
|
| 78 |
+
1. Upload Your Documents
|
| 79 |
+
|
| 80 |
+
Go to the Knowledge Base tab and upload as many files as you want.
|
| 81 |
+
|
| 82 |
+
2. Rebuild the Index
|
| 83 |
+
|
| 84 |
+
Click Rebuild index to process the files and generate embeddings.
|
| 85 |
+
|
| 86 |
+
3. Start Asking Questions
|
| 87 |
+
|
| 88 |
+
Switch to the Chat tab and ask questions like:
|
| 89 |
+
|
| 90 |
+
What is the main topic of the report?
|
| 91 |
+
Summarize the key findings.
|
| 92 |
+
What does section 3 say about metrics?
|
| 93 |
+
|
| 94 |
+
π Project Structure
|
| 95 |
+
βββ app.py # Main application logic
|
| 96 |
+
βββ config.yaml # Optional configuration file
|
| 97 |
+
βββ knowledge_base/ # User-uploaded documents
|
| 98 |
+
βββ index/ # Saved FAISS index + metadata
|
| 99 |
+
βββ README.md # This file
|
| 100 |
+
|
| 101 |
+
π§© Tech Stack
|
| 102 |
+
|
| 103 |
+
Python 3.10
|
| 104 |
+
|
| 105 |
+
Gradio
|
| 106 |
+
|
| 107 |
+
FAISS
|
| 108 |
+
|
| 109 |
+
Sentence Transformers
|
| 110 |
+
|
| 111 |
+
Transformers (HuggingFace)
|
| 112 |
+
|
| 113 |
+
PyPDF2 / python-docx
|
| 114 |
+
|
| 115 |
+
π§± Roadmap (Upcoming Enhancements)
|
| 116 |
+
|
| 117 |
+
π Streaming responses (LLM-style typing)
|
| 118 |
+
|
| 119 |
+
π Document preview inside the chat
|
| 120 |
+
|
| 121 |
+
π Source highlighting of extracted spans
|
| 122 |
+
|
| 123 |
+
π¨ Theming + cleaner chat UI
|
| 124 |
+
|
| 125 |
+
β‘ Optional lightweight QA model for faster inference
|
| 126 |
+
|
| 127 |
+
Feel free to suggest improvements or contribute!
|