Development & process
From PDF pages
to research answers.
The project uses retrieval-augmented generation (RAG): it searches indexed documents before asking a language model to write an answer. Here are the steps described in the supplied implementation review.
Stage one • Prepare the knowledge base
Build the collection before deployment.
01 / Extract PDF text
PyMuPDF reads documents page by page. The pipeline normalizes whitespace and preserves the source filename and PDF page number.
02 / Create overlapping passages
Text is split into approximately 900-character chunks with roughly 150 characters of overlap. Chunks shorter than 120 characters are discarded. Overlap helps preserve context at boundaries.
03 / Represent the text numerically
SentenceTransformers uses all-MiniLM-L6-v2 to create 384-dimensional embeddings. These vectors allow passages and questions to be compared by semantic similarity.
04 / Save a reusable index
Normalized vectors are stored as NumPy float32 arrays. Compressed passage text and source metadata are saved separately, along with a manifest describing the build.
Stage two • Answer a question
Search locally. Generate remotely.
05 / Receive the question
The interface provides a status message and progress feedback. Empty input prompts the user to enter a question; simple greetings are handled locally.
06 / Find related passages
The index and embedding model load when needed and are cached. The question is embedded with the model recorded in the manifest and compared with stored passage vectors.
07 / Filter the results
The documented defaults retrieve five chunks and apply a similarity threshold of 0.5. Because the vectors are normalized, their dot products represent cosine similarity.
08 / Generate and display
Selected passages and the question are sent to OpenRouter. The application presents the answer and source table, giving readers material to inspect.
Instructions for a concise, sourced response.
When retrieved material is available, the documented prompt asks the model to use the supplied excerpts, state when evidence is insufficient, cite numbered passages, and produce two to four concise bullets.
These are generation instructions, not a guarantee that every output is correct. Readers should verify that each reference supports the associated claim.
Preserve traceability
Source metadata includes filenames and page numbers so retrieved passages remain connected to their origin.
Handle interruptions
The code separates retrieval and generation and includes error handling. The public documentation describes preserving excerpts when generation is unavailable.
Maintain the collection
Changes to the PDFs require rebuilding and uploading the index. Changing only the answer-generation model does not require rebuilding the document embeddings.
A modular Python project.
app.py handles the interface and presentation. build_index.py prepares the PDFs and index. rag_core.py handles search, prompt construction, external requests, and errors.
The project also includes dependency and setup files, saved index data, and test_rag_core.py for automated checks of generation, errors, diagnostics, and token budgets. The supplied background identifies these tests; it does not report a test pass rate or scientific benchmark.
Implementation details reflect the supplied local review. The deployed Space can differ. View public documentation.
Explore questions and limitations →