A RAG assistant for research papers: upload multiple PDFs and ask questions across all of them at once, with every answer citing the exact paper and page it came from.
🔗 Live demo: HuggingFace Space
"Chat with your PDF" is one of the most common LLM demos out there; this project pushes past the single-document version in two ways:
- Cross-paper comparison, not just multi-upload: Retrieval uses Maximal Marginal Relevance instead of plain top-k similarity search, specifically so that a comparison question ("how do these methods differ?") doesn't get flooded with chunks from whichever single paper happens to score highest in the search. This means that every uploaded paper gets a real chance to contribute to the answer.
- Citations specific enough to verify: Every claim is tagged
[filename, p.X], pointing at the exact source and page from which it came.
- Upload any number of PDF research papers at once
- Ask questions across all of them simultaneously
- Inline citations with filename and page number on every claim
- Automatic bibliography/references filtering, so citation-list text doesn't pollute retrieval
- Per-session state; safe for multiple people to use the public demo at the same time
LangChain - ChromaDB - sentence-transformers (all-MiniLM-L6-v2) - Gemini 2.5 Flash - Gradio
- Each uploaded PDF is loaded page by page, the references section is stripped, and the text is split into overlapping chunks.
- Chunks are embedded with sentence-transformers (all-MiniLM-L6-v2) and stored in ChromaDB, tagged with source filename and page number.
- A question triggers retrieval: MMR pulls diverse chunks across all uploaded papers, plus each paper's opening chunk so general "what is this paper about" questions are grounded too.
- The retrieved chunks and the question are sent to Gemini 2.5 Flash.
- The answer comes back with inline
[filename, p.X]citations pointing at the exact source. - Every push to the
mainbranch automatically redeploys the live demo via GitHub Actions and no manual deploy step is required.
Requires a free Google AI Studio API key.
git clone https://github.com/Ali-Rafiaei/rag-research-assistant.git
cd rag-research-assistant
pip install -r requirements.txt
Create a .env file in the project root with your API key:
GOOGLE_API_KEY=your-key-here
Run it:
python app.py
Open the local URL Gradio prints (usually http://127.0.0.1:7860), upload a few PDFs,
and start asking questions.
Being upfront about what this doesn't handle well:
- No conversation memory: Each question is answered independently. There's no follow-up/chat history, so "what about the second one?" won't know what "the second one" refers to.
- No OCR: Scanned or image-only PDFs won't yield extractable text,
since text extraction is purely
pypdf-based. - References-section filtering is a heuristic, not a parser: It looks for a line reading exactly "References" or "Bibliography" and cuts from there, which works well on standard IEEE-style papers, but isn't guaranteed on every formatting style.
- Retrieval-based by design, even though these documents are short enough to fit in Gemini's context window whole: A production tool optimizing purely for answer quality on a handful of short papers might skip chunking and retrieval entirely. This project deliberately implements the full RAG pipeline (chunking, embedding, vector search) because demonstrating those mechanics was the point of building it; the tradeoff was made consciously, not out of necessity.
- Vector store isn't persisted between sessions: Every upload rebuilds it from scratch, which is intentional for a public multi-user demo (see below), but means re-uploading the same papers re-embeds them each time.
- The vector store lives in Gradio's per-session
gr.State, not a global variable. A global variable would leak one visitor's uploaded papers into another's session on a public deployment. - No
persist_directoryon the Chroma store, for the same reason: a shared on-disk collection could let concurrent users' data collide.
