Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 0.5.0 instead.

⚡ LightningParse

Fast, accurate PDF parsing for RAG pipelines — a Rust extraction core (via PyO3) feeding a Python chunking/embedding/retrieval pipeline.

Status: core pipeline complete — Rust extraction, cleanup, OCR fallback, chunking, retrieval, and generation are all implemented and benchmarked end-to-end. See PHASES.md for what's built and BENCHMARKS.md for full results.

What's New in v0.2.0

  • Structured table extraction: tables with detected captions are now parsed into structured row/column data instead of flat text, with markdown-formatted output in RAG chunks
  • CID/Type0 composite font support: proper /W and /DW array parsing for embedded CJK and other composite fonts (previously fell back to a fixed 0.5em width)
  • New robustness fixtures: added synthetic distorted-scan and Word-export test cases to broaden Tier 2/Tier 1 coverage
  • Fixed: a performance regression introduced during table-detection development (O(N²)O(N))
  • Fixed: a false-positive table detection issue that was incorrectly merging multi-author affiliation blocks

Why

Traditional Python PDF libraries (PyPDF2, pdfplumber, PyMuPDF) are GIL-bound and process pages sequentially, which becomes a bottleneck in RAG ingestion pipelines. LightningParse pushes extraction, header/footer cleanup, and OCR fallback into Rust, parallelized across pages, and returns structured JSON that Python can chunk with page/section metadata intact.

Architecture

React → FastAPI → Rust PDF Parser (PyO3) → Chunker → FAISS/Chroma → LLM

Two processing tiers:

  • Tier 1 — Digital-native PDFs: direct text extraction, no OCR. This is where the speed claim is benchmarked.
  • Tier 2 — Scanned/image PDFs: routed per-page to OCR (Tesseract) when no text layer is present.

Full design details: ARCHITECTURE.md Product scope and roadmap: PRD.md Contributor/agent instructions: AGENTS.md

Benchmarks

LightningParse is 6.0×–93.1× faster than pypdf/pdfplumber on digital-native (Tier 1) PDFs, with the gap widening on longer documents. Some representative results:

Document Pages LightningParse (median) pypdf pdfplumber
Multi-page IEEE paper (ieee_template_placeholder.pdf) 8 0.61 ms 7.89 ms (12.9× slower) 56.82 ms (93.1× slower)
Two-column academic paper (arxiv_twocolumn.pdf) 15 41.12 ms 951.92 ms (23.1× slower) 2579.90 ms (62.7× slower)
Single-page resume (Shivam_FullStack.pdf) 1 6.82 ms 82.14 ms (12.0× slower) 208.42 ms (30.6× slower)

OCR (Tier 2) and mixed-document handling are also supported, benchmarked separately from Tier 1 — pypdf and pdfplumber can't perform OCR, so comparing their near-instant-but-empty results against LightningParse's actual OCR time would be misleading rather than informative. See BENCHMARKS.md for those numbers on their own terms.

A concurrent-load test also confirms the Rust FFI genuinely releases Python's GIL during parsing: 10 concurrent OCR-heavy parse requests complete 4.78× faster than running them sequentially, on an 8-core/16-thread machine.

Full methodology, per-document results, and reproduction steps: benchmarks/BENCHMARKS.md. Run them yourself:

cd benchmarks
python benchmark.py --tier all

Results are published in benchmarks/BENCHMARKS.md — generated, not hand-written.

Known Limitations

  • CID/Type0 composite fonts: glyph width lookup currently only reads /Widths (simple fonts); CID fonts fall back to a standard 0.5 em width, verified safe (no crash) but not pixel-precise for bbox positioning. See ARCHITECTURE.md decision log.
  • OCR noise: Tesseract confidence-based filtering removes most scan artifacts (binder shadows, margin smudges) but some low-level noise can still pass through on real-world scans. OCR output is not expected to be flawless — see PRD.md non-goals.
  • Tier 2/Mixed fixture coverage: currently validated against a small number of real scanned/mixed fixtures rather than a broad corpus. On the synthetic phone_photo_invoice.pdf fixture specifically, heavy combined distortion (rotation + noise + lighting gradient + blur) caused the OCR confidence filter to discard all real content along with the noise — 0 of 7 real lines recovered. This demonstrates the system fails safely (no crash, no hallucinated garbage) under severe distortion, but does not currently recover text from heavily degraded scans. Real-world phone photos are often less distorted than this synthetic worst-case, but this is a genuine, unresolved limitation, not just a synthetic-vs-real fidelity gap. Speedup claims for Tier 1 are well-validated across multiple document types; Tier 2 performance numbers should be read as representative of the current fixtures, not a broad guarantee.
  • Tables and complex layouts: table extraction is flattened to text, not structured (rows/columns), in v1. Full table structure extraction is out of scope for now — see PRD.md.
  • Encrypted/form PDFs: not explicitly supported in v1.

Install

# Rust core (requires maturin)
cd lightningparse-core
maturin develop --release

# Python API
cd lightningparse-api
pip install -e .

Quickstart

from lightningparse import parse_pdf

result = parse_pdf("document.pdf")
for page in result["pages"]:
    for block in page["blocks"]:
        print(block["section_id"], block["text"][:80])

Scope (v1)

In scope: digital-native PDF extraction, header/footer/footnote removal, OCR fallback for scanned pages, metadata-aware chunking, retrieval + LLM Q&A pipeline with citations.

Not in scope yet: structured table extraction, encrypted/form PDFs, ML-based layout detection. See PRD.md §2 for the full non-goals list — these are deliberate cuts, not oversights.

Contributing

See AGENTS.md for repo conventions, build commands, and non-negotiable rules (FFI safety, GIL handling, benchmark discipline) before opening a PR.

License

MIT License.

Download files

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

Source Distribution

lightningparse-3.1.0.tar.gz (1.0 MB view details)

Uploaded Source

File details

Details for the file lightningparse-3.1.0.tar.gz.

File metadata

  • Download URL: lightningparse-3.1.0.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lightningparse-3.1.0.tar.gz
Algorithm Hash digest
SHA256 cd4da950e5ff6837cd7713835cfcf11114364fb14e0c66c52631c974f4a0aa63
MD5 c7fc3a9ab4fa4e5d450852b150f544be
BLAKE2b-256 2113577fec55e2977bc73b5ff6aea911009f9ee10867e1d42ad4b1785a87c01a

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightningparse-3.1.0.tar.gz:

Publisher: CI.yml on ShivamMalge/LightningParse

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

Release history Release notifications | RSS feed

This release

3.1.0 This release

1 file

0.5.0

28 files

0.4.1

28 files

0.4.0

28 files

0.3.0

1 file

0.2.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page