How alokssingh/pdf_question_answering_rag_with_pymupdf4llm works
Purpose and actual entry points
This is a Python document-ingestion and retrieval/QA prototype centered on PDFs, web content, and an Ollama-backed RAG workflow. The README describes a broader pipeline, but the checked-in executable surface is script-oriented; no main.py, data/, or scripts/ directory is present. Likely primary orchestration/QA entry point: QA_without_runnable_ollama.py.
Acquisition boundary
Documents can enter from remote PDF URLs, general web pages, or Google-discovered links:
• pdf_downloader.py
• doc_downloader.py
• google_search.py
These scripts form the external-network boundary and produce locally usable document artifacts/content for downstream extraction.
Web text ingestion
HTML/web-page content is fetched and converted into text and metadata before it can be indexed or queried:
• text_downloader.py
• text_scrape.py
This is parallel to PDF ingestion rather than a web application layer. It likely depends on changing third-party page structures and search results.
PDF extraction and layout handling
PDFs are transformed into structured text, with explicit handling for multi-column layouts:
• pdf_information_extraction.py
• multi_column.py
The stated extraction runtime is pymupdf4llm; README also claims bounding-box-based OCR/layout extraction. This stage is the key normalization boundary between binary source files and retrieval-ready text.
Retrieval-augmented QA
Question answering is represented by:
• QA_without_runnable_ollama.py
Per the README, the intended flow is: extracted text → embeddings → nearest-neighbor retrieval → retrieved context supplied to Ollama for response generation. The filename indicates this script may support QA logic without requiring a runnable local Ollama service, so Ollama availability should be treated as an optional/runtime-dependent boundary.
Vector-store and model infrastructure
The intended retrieval infrastructure is ChromaDB or FAISS, with Ollama as the local LLM service. These are material external runtimes/dependencies, although dedicated vector-store scripts described in the README are absent from the tree. Dependency declarations are centralized in requirements.txt.
Data flow and repository gaps
Expected end-to-end control flow is:
1. Discover/download PDFs or scrape web text.
2. Extract and normalize text, including multi-column PDFs.
3. Chunk/embed and persist vectors in ChromaDB or FAISS.
4. Retrieve relevant chunks for a user query.
5. Generate an answer through Ollama or a non-runnable fallback path.
DCM_singapore_data.xlsx is a checked-in data artifact that may be an alternate source or evaluation corpus, but it is not documented as part of the RAG pipeline. The README’s listed main.py and vector/retrieval scripts do not exist in this snapshot; integration is therefore distributed across the available scripts rather than a confirmed single CLI.
Main entry points: QA_without_runnable_ollama.py QA orchestration · pdf_information_extraction.py PDF text extraction · doc_downloader.py Document downloader · requirements.txt Dependencies
Components 17
Acquisition
Network-facing document discovery and download scripts.
- Remote PDF sources
- Web pages
- Google search · Search-result structures are an external dependency.
- PDF downloader
pdf_downloader.py - Document downloader
doc_downloader.py - Google link discovery
google_search.py
Text Normalization
PDF layout extraction and web-text conversion.
- Web text fetcher
text_downloader.py - HTML text scraper · Converts pages into text and metadata.
text_scrape.py - PDF text extraction · Normalization boundary from PDF binaries to structured text.
pdf_information_extraction.py - Multi-column layout · Handles multi-column PDF layout.
multi_column.py - Normalized text · Extraction-ready corpus for chunking and embedding.
RAG QA
Distributed retrieval and answer-generation workflow.
- QA orchestration · Likely primary retrieval and QA entry point.
QA_without_runnable_ollama.py - ChromaDB or FAISS · Intended embedding persistence and nearest-neighbor retrieval runtime.
- Ollama · Optional runtime-dependent answer generation boundary.
- Non-runnable fallback · Supports QA logic when Ollama is unavailable.
Other components
- Spreadsheet artifact · Possible alternate source or evaluation corpus; not documented in the pipeline.
DCM_singapore_data.xlsx - Dependencies · Centralized Python dependency declarations.
requirements.txt
Connections 18
- Remote PDF sources → PDF downloader: downloads
- Remote PDF sources → Document downloader: downloads
- Google search → Google link discovery: search results
- Google link discovery → Document downloader: discovered links
- Web pages → Web text fetcher: fetches
- Web text fetcher → HTML text scraper: HTML content
- HTML text scraper → Normalized text: text and metadata
- PDF downloader → PDF text extraction: PDF artifacts
- Document downloader → PDF text extraction: PDF artifacts
- Multi-column layout → PDF text extraction: layout handling
- PDF text extraction → Normalized text: structured text
- Normalized text → QA orchestration: chunks and embeds
- QA orchestration → ChromaDB or FAISS: persists and retrieves vectors
- ChromaDB or FAISS → QA orchestration: relevant chunks
- QA orchestration → Ollama: retrieved context
- QA orchestration → Non-runnable fallback: when runtime unavailable
- Dependencies → PDF text extraction: declares dependencies
- Dependencies → QA orchestration: declares dependencies