Skip to main content

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

PDF Markdown
Screenshot 2026-02-11 at 21 54 00 Screenshot 2026-02-11 at 22 20 52

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paper_structure-0.1.0.tar.gz (53.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paper_structure-0.1.0-py3-none-any.whl (69.2 kB view details)

Uploaded Python 3

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

Hashes for paper_structure-0.1.0.tar.gz
Algorithm Hash digest
SHA256 650295f4953573b9bba0f156d4d5ed49ac7bcb61943f60f25c0716f900be5d13
MD5 b7dd45a356b181fe49d165dfe3664e63
BLAKE2b-256 b1e3bd51cd4455eee189ecbfe1d634ffcfd442fe62641dd062f501cafee65c6a

See more details on using hashes here.

Provenance

The following attestation bundles were made for paper_structure-0.1.0.tar.gz:

Publisher: pypi.yml on yuanjua/PaperStructure

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file paper_structure-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for paper_structure-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cea1be10bddfeecb819231e755438791db477f09bd84d30562f1d0a7e0616cc6
MD5 1ffa60b74890e66aaf7ab982fe350f35
BLAKE2b-256 85b3e7c309a003ce2f1f811aff1801474ccb7dd560a7286463e4899361e048f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for paper_structure-0.1.0-py3-none-any.whl:

Publisher: pypi.yml on yuanjua/PaperStructure

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page