How sreevathsans/chatpdf works
ChatPDF is a local PDF question-answering application. Users upload a PDF through Streamlit; the app extracts, chunks, embeds, and indexes its text. For a question, the app invokes the high-level chat pipeline, which retrieves relevant chunks, builds a context-bound prompt, and requests an answer from a local Ollama server. The graph distinguishes document ingestion from question answering and includes embedding, retrieval, and persistent storage layers. Relationships are based on the shown source excerpts and README; storage paths are named in the vector-store implementation, but the stored binary contents were not inspected.
Main entry points: app.py Streamlit app · vector_store.py FAISS vector store · rag.py RAG retrieval · rag_pipeline.py Chat pipeline
Components 15
Document ingestion
- Uploaded PDFs
data - PDF extraction
extractor.py - Text chunking
chunker.py - Chunk embeddings
embeddings.py
Retrieval and storage
- SentenceTransformer model
embeddings.py - FAISS vector store
vector_store.py - FAISS index file
db/faiss_index.bin - Chunk metadata file
db/metadata.pkl - RAG retrieval
rag.py
Answer generation
- Chat pipeline
rag_pipeline.py - Context prompt
rag_pipeline.py - Ollama client
llm.py
User interface
- Streamlit app
app.py
Other components
- PDF user
- Ollama server
Connections 18
- PDF user → Streamlit app: uses
README.md - Streamlit app → Uploaded PDFs: saves upload
app.py - Streamlit app → PDF extraction: extracts text
app.py - PDF extraction → Text chunking
- Streamlit app → Text chunking: creates chunks
app.py - Streamlit app → Chunk embeddings: embeds chunks
app.py - Chunk embeddings → SentenceTransformer model: encodes chunks
embeddings.py - Streamlit app → FAISS vector store: builds and saves
app.py - FAISS vector store → FAISS index file: writes and loads
vector_store.py - FAISS vector store → Chunk metadata file: writes and loads
vector_store.py - PDF user → Streamlit app: asks question
README.md - Streamlit app → Chat pipeline: asks
app.py - Chat pipeline → RAG retrieval: retrieves chunks
rag_pipeline.py - RAG retrieval → SentenceTransformer model: embeds query
rag.py - RAG retrieval → FAISS vector store: searches vectors
rag.py - Chat pipeline → Context prompt: builds context prompt
rag_pipeline.py - Context prompt → Ollama client: provides prompt
rag_pipeline.py - Ollama client → Ollama server: sends generation request
llm.py