How pranavkombra/pdfragsystem works
Purpose and Entry Points
This repository is a Streamlit-based PDF question-answering system using retrieval-augmented generation (RAG). Users upload multiple PDFs, ask natural-language questions, and receive GPT-generated answers grounded in retrieved document chunks.
Primary entry point: app.py. A duplicate project directory, ChatPDF-main/, contains a parallel copy with its own ChatPDF-main/app.py.
Application UI and Session Control
The Streamlit application owns the interactive lifecycle: PDF upload, document-processing trigger, chat input, answer display, and conversational state. Streamlit session state is the likely boundary for retaining the RAG conversation chain between user turns.
Paths:
• app.py
• ChatPDF-main/app.py
PDF Ingestion and Text Extraction
Uploaded PDFs are accepted as a batch and transformed into extractable text before indexing. This ingestion stage is the boundary between unstructured user files and the retrieval pipeline; source PDFs are processed in-memory/application scope rather than represented by a separate storage subsystem in the repository.
Paths:
• app.py
• ChatPDF-main/app.py
Chunking, Embeddings, and Vector Retrieval
Extracted PDF text is split into retrieval-sized chunks, embedded with Hugging Face’s all-MiniLM-L6-v2 model, and indexed in FAISS. At query time, the user’s question is embedded and used to retrieve relevant chunks from this vector store.
This is the repository’s core RAG knowledge boundary: PDFs become local vector representations rather than being sent wholesale to the generator.
Paths:
• app.py
• ChatPDF-main/app.py
Conversational RAG Generation
Retrieved context and accumulated conversation history are passed to a conversational retrieval chain. The chain uses conversation-buffer memory so follow-up questions can reference prior turns, then invokes OpenAI GPT-3.5 Turbo to generate the final response.
External service boundary:
• OpenAI API for GPT-3.5 Turbo generation
• Hugging Face embedding model for vector creation
Paths:
• app.py
• ChatPDF-main/app.py
Chat Presentation Layer
The UI renders user and assistant messages using reusable HTML/CSS template strings. This keeps chat formatting separate from the Streamlit orchestration and RAG pipeline.
Paths:
• htmlTemplates.py
• ChatPDF-main/htmlTemplates.py
Runtime and Dependencies
The system runs as a Python Streamlit process, launched with streamlit run app.py. Its material runtime dependencies include Streamlit, PDF parsing, LangChain-style RAG orchestration, FAISS vector search, Hugging Face embeddings, and OpenAI client access.
Paths:
• requirements.txt
• ChatPDF-main/requirements.txt
• app.py
Main entry points: app.py Conversational retrieval chain · requirements.txt Python dependencies · htmlTemplates.py Chat templates · ChatPDF-main/app.py Duplicate Streamlit app
Components 15
Primary Streamlit app
- Python dependencies
requirements.txt - Streamlit application · Launched with streamlit run app.py.
app.py - Upload and chat UI · Owns upload, processing trigger, chat input, and answer display.
app.py - Chat templates · Reusable user and assistant message formatting.
htmlTemplates.py - Conversation state · Retains the RAG chain between user turns.
app.py - PDF text extraction · Processes uploaded PDF batches in application memory.
app.py - Text chunking
app.py - Hugging Face embeddings · Uses all-MiniLM-L6-v2 for document and question vectors.
app.py - FAISS vector index · Stores chunk embeddings and returns relevant chunks.
app.py - Conversational retrieval chain · Combines retrieved context with conversation history.
app.py - Conversation buffer · Provides prior turns for follow-up questions.
app.py
Parallel copy
- Duplicate Streamlit app · Parallel copy of the primary application architecture.
ChatPDF-main/app.py - Duplicate chat templates
ChatPDF-main/htmlTemplates.py - Duplicate dependencies
ChatPDF-main/requirements.txt
Other components
- OpenAI GPT-3.5 Turbo
Connections 18
- Python dependencies → Streamlit application: provides runtime
- Streamlit application → Upload and chat UI: renders
- Upload and chat UI → PDF text extraction: uploads PDFs
- PDF text extraction → Text chunking: extracts text
- Text chunking → Hugging Face embeddings: embeds chunks
- Hugging Face embeddings → FAISS vector index: indexes vectors
- Upload and chat UI → Conversational retrieval chain: submits question
- Conversational retrieval chain → Hugging Face embeddings: embeds query
- FAISS vector index → Conversational retrieval chain: retrieved chunks
- Conversation state → Conversational retrieval chain: retains chain
- Conversation buffer → Conversational retrieval chain: conversation history
- Conversational retrieval chain → Conversation buffer: records turns
- Conversational retrieval chain → OpenAI GPT-3.5 Turbo: generates answer
- OpenAI GPT-3.5 Turbo → Upload and chat UI: answer
- Chat templates → Upload and chat UI: formats messages
- Duplicate Streamlit app → Streamlit application: parallel copy
- Duplicate chat templates → Chat templates: parallel copy
- Duplicate dependencies → Python dependencies: parallel copy