prithvi1029 commited on
Commit
3a745a5
·
verified ·
1 Parent(s): 02d318a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +147 -24
README.md CHANGED
@@ -10,50 +10,173 @@ pinned: false
10
  license: apache-2.0
11
  ---
12
 
13
- # 📄 PDF RAG with Together.ai
14
- ### *Agentic Document Intelligence*
15
 
16
- This Hugging Face Space demonstrates a **Retrieval-Augmented Generation (RAG)** system that allows users to **upload a PDF and ask questions grounded strictly in the document content**.
 
 
17
 
18
  ---
19
 
20
- ## 🚀 What this Space Does
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- The system combines:
 
 
23
 
24
- - 🔍 **Semantic search** using embeddings + FAISS
25
- - 🧠 **Large Language Model** served via **Together.ai**
26
- - 🎛️ **Interactive Gradio interface**
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  ---
29
 
30
- ## 🧩 Why This Space Exists
 
 
 
 
 
 
31
 
32
- This Space is designed as a **foundational Agentic Document Intelligence component**.
33
 
34
- It serves as:
35
- - a clean reference RAG implementation
36
- - a building block for more advanced agentic AI systems
37
- - a practical example of grounded, document-aware LLM applications
38
 
39
  ---
40
 
41
- ## 🛠️ Core Concepts Demonstrated
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
- - Retrieval-Augmented Generation (RAG)
44
- - Vector-based semantic search
45
- - Context-constrained LLM prompting
46
- - Transparent source grounding
47
 
48
  ---
49
 
50
- ## 🧠 Intended Use Cases
 
 
 
 
 
 
 
51
 
52
- - Document Q&A
53
- - Research paper analysis
54
- - Internal knowledge assistants
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  - Agentic AI system foundations
56
 
57
  ---
58
 
59
- Built with ❤️ for the Hugging Face community.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  license: apache-2.0
11
  ---
12
 
13
+ # 📄 Agentic Document Intelligence
14
+ ### PDF RAG with Together.ai
15
 
16
+ This Hugging Face Space demonstrates a **Retrieval-Augmented Generation (RAG)** system that allows users to upload a PDF and ask questions that are **strictly grounded in the document content**.
17
+
18
+ The Space serves as a **foundational Agentic Document Intelligence component**, designed to be simple, transparent, and extensible.
19
 
20
  ---
21
 
22
+ ## 🚀 What This Space Does
23
+
24
+ - Upload a PDF document
25
+ - Build a semantic index using embeddings + FAISS
26
+ - Ask natural-language questions
27
+ - Receive answers grounded only in the uploaded document
28
+ - View retrieved source passages for transparency
29
+
30
+ ---
31
+
32
+ ## 🧠 Architecture Overview
33
+
34
+ 1. **PDF Ingestion**
35
+ - Extracts text from uploaded PDF
36
+ - Cleans and normalizes content
37
+
38
+ 2. **Chunking**
39
+ - Splits text into overlapping semantic chunks
40
+ - Ensures contextual continuity
41
 
42
+ 3. **Vector Indexing**
43
+ - Generates embeddings using Sentence Transformers
44
+ - Indexes vectors using FAISS (cosine similarity)
45
 
46
+ 4. **Retrieval**
47
+ - Retrieves top-K relevant chunks for each query
48
+
49
+ 5. **Generation (RAG)**
50
+ - Injects retrieved context into LLM prompt
51
+ - Uses Together.ai (Mixtral) for answer generation
52
+
53
+ ---
54
+
55
+ ## ▶️ How to Use This Space (End-to-End)
56
+
57
+ ### **Step 1: Upload a PDF**
58
+ - Click **“Upload PDF”**
59
+ - Select a text-based PDF file
60
+ > ⚠️ Note: Scanned PDFs without text extraction will not work unless OCR is applied.
61
 
62
  ---
63
 
64
+ ### **Step 2: Wait for Indexing**
65
+ - The system will:
66
+ - extract text
67
+ - split it into chunks
68
+ - build a FAISS vector index
69
+ - You will see a confirmation message:
70
+
71
 
 
72
 
 
 
 
 
73
 
74
  ---
75
 
76
+ ### **Step 3: Ask a Question**
77
+ - Type a natural-language question related to the document
78
+ Examples:
79
+ - *“Summarize the document”*
80
+ - *“What is the main contribution?”*
81
+ - *“Explain the methodology section”*
82
+
83
+ ---
84
+
85
+ ### **Step 4: Receive the Answer**
86
+ You will get:
87
+ - ✅ A generated answer based **only on document context**
88
+ - 📌 Retrieved source passages with similarity scores
89
+ - 🚫 No hallucinated or external information
90
+
91
+ If the answer is not present in the document, the system will respond:
92
+
93
 
 
 
 
 
94
 
95
  ---
96
 
97
+ ### **Step 3: Ask a Question**
98
+ - Type a natural-language question related to the document
99
+ Examples:
100
+ - *“Summarize the document”*
101
+ - *“What is the main contribution?”*
102
+ - *“Explain the methodology section”*
103
+
104
+ ---
105
 
106
+ ### **Step 4: Receive the Answer**
107
+ You will get:
108
+ - A generated answer based **only on document context**
109
+ - 📌 Retrieved source passages with similarity scores
110
+ - 🚫 No hallucinated or external information
111
+
112
+ If the answer is not present in the document, the system will respond:
113
+
114
+
115
+
116
+
117
+ ---
118
+
119
+ ## 🤖 Models Used
120
+
121
+ ### **Language Model**
122
+ - **Provider:** Together.ai
123
+ - **Model:** `mistralai/Mixtral-8x7B-Instruct-v0.1`
124
+
125
+ ### **Embedding Model**
126
+ - `sentence-transformers/all-MiniLM-L6-v2`
127
+
128
+ ---
129
+
130
+ ## 🧰 Tech Stack
131
+
132
+ - Python
133
+ - Gradio (UI)
134
+ - FAISS (vector search)
135
+ - Sentence Transformers (embeddings)
136
+ - Together.ai (LLM)
137
+ - Hugging Face Spaces
138
+
139
+ ---
140
+
141
+ ## 🔐 Environment Configuration (For Developers)
142
+
143
+ ### **Secrets**
144
+ - `TOGETHER_API_KEY` → Together.ai API key
145
+ - `OPENAI_API_KEY` → Same value (compatibility with OpenAI client)
146
+
147
+ ### **Variables**
148
+ - `TOGETHER_MODEL` → `mistralai/Mixtral-8x7B-Instruct-v0.1`
149
+ - `TOGETHER_BASE_URL` → `https://api.together.xyz/v1`
150
+
151
+ ---
152
+
153
+ ## 🧩 Intended Use Cases
154
+
155
+ - Research paper Q&A
156
+ - Technical documentation assistants
157
+ - Internal knowledge bases
158
+ - RAG pipeline reference implementation
159
  - Agentic AI system foundations
160
 
161
  ---
162
 
163
+ ## 🔮 Future Enhancements
164
+
165
+ - Multi-PDF support
166
+ - Chat memory
167
+ - Streaming responses
168
+ - Agent routing & tool usage
169
+ - Evaluation and scoring agents
170
+
171
+ ---
172
+
173
+ ## 🙌 Author
174
+
175
+ Built by **Abhishek Prithvi Teja**
176
+ Focused on **Agentic AI, RAG systems, and applied LLM engineering**
177
+
178
+ ---
179
+
180
+ ## 🏷️ Tags
181
+
182
+ `rag` · `agentic-ai` · `document-qa` · `faiss` · `together-ai` · `huggingface-spaces`