A toolkit for scientists who refuse to flatten their PDFs
It models scientific papers as overlapping text and layout layers so you can query sentences, rows, and figures by their messy real-world intersections rather than forcing them into a single hierarchy.

What it does
PaperMage ingests academic PDFs and exposes their contents through a Document class that carries multiple segmentation layers—tokens, sentences, rows, pages, figures, tables, and more. Instead of forcing these layers into a rigid hierarchy, it treats them as intersecting sets of Entity objects backed by spans and bounding boxes. The library wraps existing utilities like PDFPlumber and PDF2Image, then stitches their outputs together with in-house predictors that can be heuristics or full machine-learning models.
The interesting bit
The real trick is the dynamic indexing: every time you add a new layer, the document rebuilds intersection maps so any Entity can instantly retrieve whatever else overlaps with it. This means a sentence can ask for its rows even when those rows bleed past the sentence boundary, which is exactly the kind of mess real scientific PDFs serve up.
Key highlights
Document.symbolsholds the raw text, while named layers (pages,tokens,sections, etc.) provide alternate slices into the same string.- Entities expose both
.spans(character ranges) and.boxes(page coordinates), linking textual and visual representations. - Predictors can be stacked incrementally: load a saved document, run a new model, save the enriched JSON, and repeat.
- Ships with a
CoreRecipethat bundles parser, rasterizer, and default predictors into a single pipeline.
Caveats
- The authors explicitly warn this is a research prototype for EMNLP 2023 and regular maintenance is unlikely; active development has moved to the Dolma project.
- Intersection logic is non-obvious: because layers overlap rather than nest, iterating
sent.rowscan yield tokens that sit outside the sentence entirely.
Verdict
Worth a look if you are building multimodal scientific-NLP prototypes and need a sane abstraction over PDF chaos. Skip it if you want a production-grade, maintained parser—head to Dolma instead.
Frequently asked
- What is allenai/papermage?
- It models scientific papers as overlapping text and layout layers so you can query sentences, rows, and figures by their messy real-world intersections rather than forcing them into a single hierarchy.
- Is papermage open source?
- Yes — allenai/papermage is open source, released under the Apache-2.0 license.
- What language is papermage written in?
- allenai/papermage is primarily written in Python.
- How popular is papermage?
- allenai/papermage has 800 stars on GitHub.
- Where can I find papermage?
- allenai/papermage is on GitHub at https://github.com/allenai/papermage.