PaperPilot extracts text from PDF research papers, chunks them, and uses the Gemini API to produce a structured review (summary, claims, method, results, reproducibility, risk breakdown, experiments, citations). It supports a replication plan, RAG-lite Q&A over chunks, and Markdown export.
- PDF upload → extract text (pdfplumber, fallback pypdf)
- Chunking → ~800–1200 token chunks with overlap; cap at 40 chunks (with batch summarization when longer)
- Review → Gemini returns structured JSON; risk score is computed in code from a deterministic rubric (dataset, splits, hyperparameters, etc.)
- Citations → Every claim/result/checklist/risk item includes chunk_id + quote, or “Not found in provided text” when absent
- Replication plan → Generate prerequisites, data/env, training/eval, ablations, compute, risks
- Q&A → TF-IDF retrieval over chunks → Gemini answer with citations; “Not found in provided text” if unsupported
- Export → Download Review and/or Review + Replication Plan as a single Markdown file
cd project
python -m venv .venv
source .venv/bin/activate # Linux/macOS
# Windows: .venv\Scripts\activatepip install -r requirements.txtSecrets are read only from the environment (e.g. via .env and python-dotenv).
Option A — .env
cp .env.example .env
# Edit .env and set:
# GEMINI_API_KEY=your_actual_key_hereOption B — export
export GEMINI_API_KEY=your_actual_key_hereGet a key at Google AI Studio. GOOGLE_API_KEY is also accepted.
From the project directory:
streamlit run paperpilot.pyOpen the URL shown (typically http://localhost:8501).
- Run
streamlit run paperpilot.pyand open the app. - Upload a PDF research paper (e.g. a short ML paper).
- Wait for extraction and chunking (and summarization if the paper is long).
- Click Analyze with Gemini and wait for the review.
- Check the risk score badge and Risk tab (breakdown table).
- Click Generate Replication Plan, then Download as Markdown.
- In Q&A, ask e.g. “What dataset did the authors use?” and check the answer and Evidence expander.
- Scanned PDFs: If extraction yields < 1500 characters, the app shows an error and suggests trying another PDF or using OCR.
- Long papers: Chunks are capped at 40; excess is batch-summarized before review. Very long papers may lose detail.
- Gemini: Rate limits or timeouts trigger one automatic retry, then a user-friendly error.
See requirements.txt:
streamlit— UIpdfplumber— PDF extraction (primary)pypdf— fallback extractiongoogle-generativeai— Gemini APIpython-dotenv— load.envpydantic— schemasscikit-learn— TF-IDF retrieval
Use and modify as you like.