A production-quality system for summarizing peer-reviewed medical research papers using Large Language Models (LLMs). Designed for accuracy, safety, and academic rigor.
- Multi-format Support: PDF and PubMed Central XML
- Intelligent Section Detection: Automatically identifies Abstract, Methods, Results, Discussion, etc.
- Map-Reduce Summarization: Handles papers up to 40+ pages
- Preserves Numerical Accuracy: Exact replication of statistical results
- Safety Controls: Built-in safeguards against hallucination and medical advice
- Structured Output: JSON and Markdown formats
- Modular Architecture: Easy to extend and customize
- LLM Flexibility: Supports Claude (Anthropic) and GPT-4 (OpenAI)
- Python 3.10+
- API key for Anthropic (Claude) or OpenAI (GPT-4)
# Clone repository
cd medical-paper-summarizer
# Install dependencies
pip install -r requirements.txt
# Download NLTK data (optional, for better sentence splitting)
python -c "import nltk; nltk.download('punkt')"
# Configure API keys
cp .env.example .env
# Edit .env and add your API keysLaunch the web interface:
python web_server.pyThen open http://localhost:8000 in your browser. Drop a PDF to get an AI-generated summary.
Deploy as a live site: See DEPLOY.md for one-click deploy to Render, Railway, or Fly.io.
# Summarize a PDF paper
python app.py paper.pdf
# Save as JSON
python app.py paper.pdf -o summary.json -f json
# Save as Markdown
python app.py paper.pdf -o summary.md -f markdown
# Use specific model
python app.py paper.pdf --model claude-sonnet-4-20250514
# Verbose output
python app.py paper.pdf -vfrom summarization.summarizer import MedicalPaperSummarizer
# Initialize summarizer
summarizer = MedicalPaperSummarizer()
# Summarize paper
summary = summarizer.summarize("path/to/paper.pdf")
# Access structured data
print(summary.title)
print(summary.objective)
print(summary.key_findings)
# Export to markdown
markdown = summary.to_markdown()
# Export to JSON
json_str = summary.model_dump_json(indent=2)Input (PDF/XML)
↓
Text Extraction & Cleaning
↓
Section Detection
↓
Chunking (800-1200 tokens, 150-250 overlap)
↓
Map-Reduce Summarization
├─ Map: Summarize each chunk
└─ Reduce: Combine chunk summaries
↓
Structured Information Extraction
├─ Metadata (objective, study type, population)
├─ Methods summary
├─ Key findings
├─ Limitations
└─ Conclusions
↓
Output (PaperSummary object → JSON/Markdown)
medical-paper-summarizer/
│
├── ingestion/ # Document loading
│ ├── pdf_loader.py # PDF text extraction
│ ├── xml_loader.py # PMC XML parsing
│ └── text_cleaner.py # Text normalization
│
├── processing/ # Text processing
│ ├── section_parser.py # Section detection
│ └── chunker.py # Text chunking
│
├── summarization/ # LLM orchestration
│ ├── prompts.py # Prompt templates
│ ├── llm_client.py # API client wrapper
│ ├── map_reduce.py # Map-reduce logic
│ └── summarizer.py # Main orchestrator
│
├── output/ # Output schemas
│ └── schema.py # Pydantic models
│
├── tests/ # Test suite
│ └── test_components.py # Unit tests
│
├── static/ # Web UI assets
│ └── index.html # Drag-and-drop interface
│
├── config.py # Configuration
├── app.py # CLI application
├── web_server.py # Web UI server (FastAPI)
├── requirements.txt # Dependencies
└── README.md # This file
Edit .env file or set environment variables:
# API Keys
ANTHROPIC_API_KEY=your_key_here
OPENAI_API_KEY=your_key_here
# Model Selection
PRIMARY_MODEL=claude-sonnet-4-20250514
FALLBACK_MODEL=gpt-4-turbo-preview
TEMPERATURE=0.2
MAX_TOKENS=4096
# Chunking
CHUNK_SIZE=1000
CHUNK_OVERLAP=200
MAX_SECTION_CHUNKS=20
# Processing
MAX_RETRIES=3
TIMEOUT=60
RATE_LIMIT_DELAY=1.0{
"title": "Paper title",
"objective": "Primary research question",
"study_type": "RCT | Meta-analysis | Cohort | etc.",
"population": "Sample size and demographics",
"methods": "Study design and procedures",
"key_findings": [
"Finding 1 with exact statistics",
"Finding 2 with exact statistics"
],
"limitations": [
"Limitation 1",
"Limitation 2"
],
"author_conclusions": "Authors' stated conclusions",
"keywords": ["keyword1", "keyword2"],
"summary_timestamp": "2026-01-30T12:00:00",
"model_used": "claude-sonnet-4-20250514",
"safety_disclaimer": "This summary is for academic research purposes only..."
}# Paper Title
## Objective
Primary research question
## Study Design
**Type:** RCT
**Population:** 600 adults aged 40-75...
## Methods
Study design details...
## Key Findings
1. Finding with exact statistics
2. Another finding...
## Limitations
1. Limitation 1
2. Limitation 2
## Author Conclusions
Authors' conclusions...
## Keywords
keyword1, keyword2, keyword3
---
⚠️ This summary is for academic research purposes only...- No Hallucination: Only extracts information explicitly stated in source text
- Numerical Accuracy: Preserves all statistics exactly as reported
- No Medical Advice: Explicitly forbidden from providing clinical guidance
- Author Conclusions Only: Reports only what authors state, no interpretation
- Limitation Disclosure: Always includes study limitations
- Safety Disclaimer: All outputs include academic use disclaimer
- Low Temperature: Uses temperature ≤ 0.3 for deterministic outputs
# Run tests
pytest tests/ -v
# Run specific test
pytest tests/test_components.py::TestPaperSummary -v
# Run with coverage
pytest tests/ --cov=. --cov-report=htmlfrom summarization.summarizer import MedicalPaperSummarizer
summarizer = MedicalPaperSummarizer(
chunk_size=1200, # Larger chunks
chunk_overlap=250 # More overlap
)# Use specific models
summarizer = MedicalPaperSummarizer(
primary_model="claude-sonnet-4-20250514",
fallback_model="gpt-4-turbo-preview"
)from processing.section_parser import SectionParser
from processing.chunker import TextChunker
parser = SectionParser()
chunker = TextChunker()
# Parse document
sections = parser.parse(text)
# Process specific section
methods_section = sections['methods']
chunks = chunker.chunk(methods_section.content)- PDF Quality: Use text-based PDFs, not scanned images
- Paper Length: System handles up to 40 pages efficiently
- API Costs: Monitor token usage for long papers
- Rate Limits: Built-in delays prevent API throttling
- Validation: Always validate numerical accuracy in output
- Clinical Use: NEVER use for actual patient care decisions
- PDF may be scanned image (use OCR first)
- Try
use_pymupdf=Truein PDFLoader
- Paper may have non-standard structure
- Check section headers match expected patterns
- Manually specify sections if needed
- Increase
RATE_LIMIT_DELAYin config - Reduce
CHUNK_SIZEto make fewer API calls
- Check source PDF text extraction quality
- Verify LLM temperature is ≤ 0.3
- Review prompt templates for clarity
This tool is for academic research purposes only. It does NOT:
- Provide medical advice
- Replace professional medical judgment
- Guarantee accuracy for clinical decisions
- Constitute peer review or validation
Always consult original papers and domain experts for medical decisions.
If you use this tool in research, please cite:
Medical Research Paper Summarizer
https://github.com/AliM3ski/MedicalPaperSummarizer
- AI was used in assistance to create this project
- Supports GPT-4 (OpenAI)
- Uses industry-standard libraries (pdfplumber, BeautifulSoup, Pydantic)
Version: 1.0.0
Last Updated: January 30, 2026