How sahahahil/pdf-q-a- works
This repository is a local, multi-PDF question-answering application with both terminal and Streamlit interfaces. Its workflow loads PDFs, splits them into chunks, indexes embeddings for semantic retrieval, and uses retrieved context to generate grounded answers with Ollama/Llama2. The Streamlit interface additionally displays retrieved sources and keeps chat history in session state. The graph reflects the sampled Python code; external model integrations are shown as dependencies, not as inspected repository modules.
Main entry points: app_streamlit.py Streamlit app · rag_pdf_qa.py QA chain builder · data PDF folder
Components 16
User interfaces
- CLI workflow
rag_pdf_qa.py - Streamlit app
app_streamlit.py - Chat history
app_streamlit.py - Source display
app_streamlit.py
PDF ingestion
- PDF folder
data - PDF loader
rag_pdf_qa.py - Chunk splitter
rag_pdf_qa.py
Semantic retrieval
- Sentence embeddings
- In-memory vector store
rag_pdf_qa.py - Top-3 retriever
rag_pdf_qa.py
Grounded answering
- QA chain builder
rag_pdf_qa.py - Context-only prompt
rag_pdf_qa.py - Ollama Llama2
- String output parser
rag_pdf_qa.py
Other components
- Terminal user
- Web user
Connections 31
- Terminal user → CLI workflow: asks questions
- Web user → Streamlit app: asks questions
- CLI workflow → PDF loader: loads PDFs
- Streamlit app → PDF loader: loads PDFs
- PDF folder → PDF loader: provides files
- PDF loader → Chunk splitter: passes documents
- CLI workflow → Chunk splitter: splits documents
- Streamlit app → Chunk splitter: splits documents
- CLI workflow → Top-3 retriever: builds index
- Streamlit app → Top-3 retriever: builds index
- Top-3 retriever → Sentence embeddings: embeds chunks
- Top-3 retriever → In-memory vector store: indexes chunks
- In-memory vector store → Top-3 retriever: creates retriever
- CLI workflow → QA chain builder: builds QA chain
- Streamlit app → QA chain builder: builds QA chain
- QA chain builder → Context-only prompt: configures prompt
- QA chain builder → Ollama Llama2: configures model
- QA chain builder → String output parser: configures output parsing
- CLI workflow → Top-3 retriever: queries documents
- Streamlit app → Top-3 retriever: fetches sources
- QA chain builder → Top-3 retriever: retrieves context
- QA chain builder → Context-only prompt: formats context
- Context-only prompt → Ollama Llama2: sends grounded prompt
- Ollama Llama2 → String output parser: returns answer
- CLI workflow → QA chain builder: invokes QA chain
- Streamlit app → QA chain builder: invokes QA chain
- Streamlit app → Chat history: stores chat
- Streamlit app → Source display: shows citations
- Top-3 retriever → Source display: returns source pages
- CLI workflow → Terminal user: prints answer
- Streamlit app → Web user: displays answer