- Python 95.5%
- Shell 4.5%
| .gitattributes | ||
| .gitignore | ||
| install.sh | ||
| LICENSE | ||
| pdfsum | ||
| README.md | ||
pdfsum
A command-line tool that summarizes scientific PDFs with Claude or a local model.
$ pdfsum paper.pdf
Converting 1 PDF …
✓ paper.pdf: 19 pages, 85,841 characters (removed: front matter 336, references/back matter 22,202)
Estimated cost with claude-haiku-5-5: up to ≈ $0.0137 for 1 PDF
[1/1] paper.pdf
Summarizing with claude-haiku-5-5 in one request …
Summary: ~/.pdfsum/Doe2025_Title-of-the-Paper.md
Full text: ~/.pdfsum/full-text/Doe2025_Title-of-the-Paper.md
Done in 34 s · Tokens: 27,868 in / 8,340 out · cost $0.0070
The summary is a Markdown file with this structure (shortened, placeholder text):
# Title of the Paper
**Authors:** Doe, Jane; Roe, John
**Year:** 2025
**Published in:** Journal Name
**DOI:** [10.1234/example.2025.001](https://doi.org/10.1234/example.2025.001)
**File:** paper.pdf (19 pages)
*Generated automatically with claude-haiku-5-5 on 2026-01-15. Check numbers and
statements against the original before using them.*
## Overview
Three to five sentences on the context, the research question, the approach and
the main result.
## Summary by Section
### 1 Introduction
- Key claim of the section in one sentence.
- Definition or method, with the numbers and units given in the source.
### 2 Methods
#### Subtopic of a long section
- ...
## Key Findings
1. First main conclusion of the source, with its key number.
2. Second main conclusion.
## Notes on the Source
- Section 3 and Table 2 give different values for the same quantity.
- An equation referred to in section 2 is missing from the converted text.
Features
- Four-part summary: Overview, Summary by Section, Key Findings and, with the Claude models, Notes on the Source (contradictions, numbers that do not add up, claims without evidence, content lost in the conversion).
- Text cleaning before the model sees it: running headers and footers, page numbers, table of contents, front matter, licence text, back matter and the reference list are removed.
- Section headings follow the source: the headings in the summary are matched against the headings of the PDF, with their original numbers.
- File names from title, first author and year, for example
Doe2025_Title-of-the-Paper.md. - Several PDFs in one run. All files are checked and converted first; a file that fails does not stop the others.
- Cost estimate and cost brake: the estimated cost is shown before anything is sent, and pdfsum asks for confirmation before expensive runs. The actual token usage and cost are shown after each PDF.
- Local model as a privacy option: with
--model qwennothing leaves your computer.
Requirements
- Linux (tested on CachyOS/Arch). macOS is untested.
- uv. pdfsum is a single Python script; uv provides a suitable Python (3.11 or newer) and installs the only dependency, PyMuPDF4LLM, on the first run.
- For the Claude models: an Anthropic API key.
- For
--model qwen: Ollama with the modelqwen3:8b(ollama pull qwen3:8b). A GPU with 8 GB of VRAM or more is recommended.
Installation
git clone ssh://git@git.bennis99.de:222/bennis/pdfsum.git
cd pdfsum
./install.sh
install.sh links pdfsum into ~/.local/bin and creates
~/.config/pdfsum/.env if it does not exist. An existing .env is never
changed. Because the command is a link into the cloned repository, git pull
updates it.
Then add your API key to ~/.config/pdfsum/.env:
CLAUDE-API-KEY=sk-ant-...
Keep the file private (chmod 600 ~/.config/pdfsum/.env). Alternatively, pdfsum
reads the environment variable ANTHROPIC_API_KEY. The local model needs no key.
Usage
pdfsum paper.pdf # one PDF with the default model (haiku)
pdfsum *.pdf --model sonnet # several PDFs with Sonnet
pdfsum paper.pdf --german --live # German summary, output shown live
pdfsum confidential.pdf --model qwen # local model, nothing leaves the computer
usage: pdfsum [-h] [-m {haiku,sonnet,opus,qwen}] [-l] [--no-full-text]
[--german] [-V]
PDF [PDF ...]
| Option | Description |
|---|---|
PDF |
one or more PDF files |
-m, --model {haiku,sonnet,opus,qwen} |
model to use (default: haiku) |
-l, --live |
show the model's output live while it is written |
--no-full-text |
do not save the complete text to ~/.pdfsum/full-text/ |
--german |
write the summary in German (Claude models only); section headings stay in the original language |
-V, --version |
show program's version number and exit |
-h, --help |
show this help message and exit |
pdfsum asks before runs estimated above $1.00 or documents above 100k input tokens. Without a terminal to ask (for example in a script), such a run is aborted before anything is sent to the model.
Models and costs
| Name | Model | Notes | Approximate cost per paper |
|---|---|---|---|
haiku |
claude-haiku-5-5 |
default | 1–2 cents |
sonnet |
claude-sonnet-5-5 |
more careful, for important sources | 15–35 cents |
opus |
claude-opus-5-5 |
most capable | 30–70 cents |
qwen |
qwen3:8b via Ollama |
runs locally; Key Findings and numbers are less reliable | none |
These are rough guide values for typical journal articles; long reports cost more. API prices can change, and the prices built into pdfsum may then be out of date. The actual token usage and cost are shown after every run; your Anthropic account is the authoritative source.
Output files
| Path | Content |
|---|---|
~/.pdfsum/<Author><Year>_<Title>.md |
the summary |
~/.pdfsum/full-text/<Author><Year>_<Title>.md |
the complete cleaned text including references (skipped with --no-full-text) |
~/.pdfsum/.raw/<pdf name>.md |
the last raw model answer, also kept when a run is aborted |
~/.config/pdfsum/.env |
the API key |
~/.cache/pdfsum/ |
partial summaries of the local model, so an interrupted run can resume |
The file name is built from the surname of the first author, the year and the
title (shortened to about 80 characters), for example
Doe2025_Title-of-the-Paper.md. German summaries get the suffix _de. If
author or year cannot be determined, they are left out; without a title the
name of the PDF is used.
Existing files with the same name are overwritten. Summarizing the same paper again, for example with another model, replaces the earlier summary.
How it works
- Each PDF is checked (readable, not password-protected, has a text layer) and converted page by page to Markdown with PyMuPDF4LLM.
- Lines that repeat at the top or bottom of many pages (running headers and footers) and bare page numbers are removed; sentences interrupted by a page break are joined again.
- The table of contents, the front matter before the abstract or introduction, licence and correspondence paragraphs, and everything from the back matter or reference list onwards are cut from the text that goes to the model. The complete text is saved separately.
- The cost is estimated from the length of the text. pdfsum asks for confirmation if the estimate or the document is large.
- With a Claude model, the whole document is summarized in a single request (very long documents are split into parts). With the local model, the text is split into small parts that are summarized one by one and cached; Overview and Key Findings are then written from the combined section summaries.
- The section headings of the answer are compared with the headings of the source. Matching headings get their original wording and number; headings the model added become subheadings without a number.
- Title, authors, year, journal and DOI are taken from the model's answer and the PDF metadata, and the summary is written under the resulting file name.
Privacy
With the Claude models (haiku, sonnet, opus), the text of the PDF is sent
to the Anthropic API. Do not use them for documents that must not leave your
computer, and check Anthropic's terms for how API data is handled.
With --model qwen, the text is only sent to the Ollama server on your own
machine (localhost:11434); nothing leaves the computer.
Independent of the model, uv downloads PyMuPDF4LLM from PyPI on the first run.
Limitations
- Scanned PDFs are rejected. pdfsum needs a text layer. Run OCR first, for
example
ocrmypdf input.pdf output.pdf. - Equations and figures are missing. The conversion keeps text and tables only; the summary cannot cover what is shown only in a figure or formula.
- Conversion errors are possible: paragraphs in the wrong order, words joined at line breaks, damaged tables. In documents with an unusual layout, the cleaning step can also remove too much or too little.
- Always check the result against the original. A summary can contain errors, in particular in numbers and in the Notes on the Source. It is a starting point for reading, not a replacement.
- The local model is less reliable. With
qwen, Key Findings and numbers are wrong noticeably more often than with the Claude models, there are no Notes on the Source, and--germanis not available.
Uninstall
./install.sh --uninstall
This removes the link in ~/.local/bin. Your data is kept; delete it yourself
if you no longer need it:
rm -r ~/.config/pdfsum # API key
rm -r ~/.pdfsum # summaries and full texts
rm -r ~/.cache/pdfsum # cache of the local model