Extract structure and content from academic papers with AI-powered layout detection, OCR, and formula recognition.
Project description
PaperStructure
PaperStructure is a lightweight CLI tool designed to transform academic papers into clean, structured Markdown. By leveraging ONNX models, it delivers high-performance inference optimized for standard laptops. It is a reliable companion for formula-heavy research, though users may currently observe lower accuracy in vertical table recognition.
Features
- Layout Detection -- YOLOX detects titles, sections, paragraphs, formulas, tables, figures
- Text Recognition -- PP-OCRv5 ONNX pipeline
- Formula Recognition -- Encoder-decoder LaTeX OCR
- Markdown Export -- clean, readable markdown output
- Parallel Processing -- multi-threaded PDF page processing
Demo
| Markdown | |
|---|---|
Installation
pip install paper-structure
This registers the paper-structure CLI and installs the Python package.
CLI Usage
# Process a PDF
paper-structure process paper.pdf -o output.md
# Shorthand also works:
paper-structure paper.pdf -o output.md
# Process first 5 pages, verbose
paper-structure process paper.pdf -o output.md --max-pages 5 -v
# Also save extracted images to an images/ directory
paper-structure process paper.pdf -o output.md --save-images
# Generate annotated preview PDF with bounding boxes
paper-structure preview paper.pdf -o preview.pdf
# Manage models
paper-structure models status # show what's downloaded
paper-structure models download # pre-download all models
Python API
from paper_structure import PaperStructurePipeline
pipeline = PaperStructurePipeline()
result = pipeline.process_pdf("paper.pdf")
# Markdown string
print(result["markdown"])
# Save to file (images not saved by default)
pipeline.save_markdown(result, "output.md")
# Save with extracted images alongside
pipeline.save_markdown(result, "output.md", save_images=True)
# Structured page data
for page in result["pages"]:
for elem in page["elements"]:
print(elem["type"], elem["content"][:80])
Options
pipeline = PaperStructurePipeline(
layout_model="yolox", # layout detection model
use_formula_recognition=True, # enable LaTeX formula OCR
skip_types=["Page-header", "Page-footer"],
use_gpu=False, # CUDA acceleration for OCR
use_dml=False, # DirectML (Windows)
)
result = pipeline.process_pdf(
"paper.pdf",
page_limit=5, # max pages to process
max_workers=8, # parallel threads
)
Model Management
from paper_structure.models import registry
registry.ensure_all() # pre-download everything
print(registry.status()) # show cache status
Models
The tool automatically downloads models on its first call. All model weights are hosted at hpllduck/PaperStructure (~399 MB total) and cached locally via huggingface_hub.
| Group | Files | Description |
|---|---|---|
latex_ocr |
encoder, decoder, image_resizer, tokenizer | RapidLaTeXOCR formula recognition |
yolox |
yolox_l0.05.onnx | YOLOX-L document layout detection |
paddle_ocr |
det, cls, rec, dictionary | PP-OCRv5 text detection/recognition |
License
Apache License 2.0. Individual model weights retain their original licenses (MIT for LaTeX OCR, Apache-2.0 for YOLOX and PaddleOCR).
Acknowledgments
- PaddleOCR -- text recognition
- OnnxOCR -- ONNX OCR pipeline
- RapidLaTeXOCR -- formula recognition
- unstructured-inference -- layout detection
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file paper_structure-0.1.0.tar.gz.
File metadata
- Download URL: paper_structure-0.1.0.tar.gz
- Upload date:
- Size: 53.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
650295f4953573b9bba0f156d4d5ed49ac7bcb61943f60f25c0716f900be5d13
|
|
| MD5 |
b7dd45a356b181fe49d165dfe3664e63
|
|
| BLAKE2b-256 |
b1e3bd51cd4455eee189ecbfe1d634ffcfd442fe62641dd062f501cafee65c6a
|
Provenance
The following attestation bundles were made for paper_structure-0.1.0.tar.gz:
Publisher:
pypi.yml on yuanjua/PaperStructure
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
paper_structure-0.1.0.tar.gz -
Subject digest:
650295f4953573b9bba0f156d4d5ed49ac7bcb61943f60f25c0716f900be5d13 - Sigstore transparency entry: 941297148
- Sigstore integration time:
-
Permalink:
yuanjua/PaperStructure@68397e79f51b97f8ad8f30f0db079719eb41accc -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/yuanjua
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@68397e79f51b97f8ad8f30f0db079719eb41accc -
Trigger Event:
release
-
Statement type:
File details
Details for the file paper_structure-0.1.0-py3-none-any.whl.
File metadata
- Download URL: paper_structure-0.1.0-py3-none-any.whl
- Upload date:
- Size: 69.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cea1be10bddfeecb819231e755438791db477f09bd84d30562f1d0a7e0616cc6
|
|
| MD5 |
1ffa60b74890e66aaf7ab982fe350f35
|
|
| BLAKE2b-256 |
85b3e7c309a003ce2f1f811aff1801474ccb7dd560a7286463e4899361e048f3
|
Provenance
The following attestation bundles were made for paper_structure-0.1.0-py3-none-any.whl:
Publisher:
pypi.yml on yuanjua/PaperStructure
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
paper_structure-0.1.0-py3-none-any.whl -
Subject digest:
cea1be10bddfeecb819231e755438791db477f09bd84d30562f1d0a7e0616cc6 - Sigstore transparency entry: 941297205
- Sigstore integration time:
-
Permalink:
yuanjua/PaperStructure@68397e79f51b97f8ad8f30f0db079719eb41accc -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/yuanjua
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@68397e79f51b97f8ad8f30f0db079719eb41accc -
Trigger Event:
release
-
Statement type: