Skip to main content

LangChain document loader for pdfmuse — deterministic PDF/DOCX parsing for RAG.

Project description

langchain-pdfmuse

LangChain document loader for pdfmuse — a deterministic PDF/DOCX parser for RAG. Same file in → same Documents out, with exact coordinates, tables and section structure.

pip install langchain-pdfmuse

Usage

from langchain_pdfmuse import PdfmuseLoader

# one Document per page (default)
docs = PdfmuseLoader("report.pdf").load()

# RAG-optimized: one Document per block, with section-aware metadata
elements = PdfmuseLoader("report.pdf", mode="elements").load()
for e in elements:
    print(e.metadata["category"], e.metadata["heading_path"], e.metadata["bbox"])

Modes

mode Documents Best for
"single" the whole file as one quick ingestion
"page" (default) one per page page-level retrieval
"elements" one per block (heading / paragraph / table) RAG — chunk with structure

Metadata (elements mode)

Each Document.metadata carries:

  • source, source_kind (Pdf / Docx)
  • page — 0-based page index
  • categoryTitle · NarrativeText · Table
  • heading_path — the section breadcrumb, e.g. ["Experience", "Alibaba"]
  • bbox{x0, y0, x1, y1} on the page (top-left origin, points)

heading_path + bbox let your retriever return "which section, where on the page" — not just a blob of text.

Why deterministic matters for RAG

Non-deterministic extractors make your chunks (and therefore embeddings and eval results) drift between runs. pdfmuse has no probabilistic models in its core path, so your index is reproducible. OCR / layout inference are opt-in backends, kept out of the deterministic core — scanned pages surface a NeedsOcr warning instead of guessing.

MIT OR Apache-2.0 · part of the pdfmuse project.

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

langchain_pdfmuse-0.1.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

langchain_pdfmuse-0.1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file langchain_pdfmuse-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_pdfmuse-0.1.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for langchain_pdfmuse-0.1.0.tar.gz
Algorithm Hash digest
SHA256 36047ee31c8ac7950411b39667111f7f89b11c59d3e1df85b872ebe33a00fa77
MD5 8bd74f79daf74152a243b2645ae67794
BLAKE2b-256 c2724caad1a6f913ac9b2a131d5f3701ea71860ba9c69553a07d21f6739beca5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_pdfmuse-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0239828a298e4b35de2c6a73ee8145cdc28518a6447baa6deab4acfb30567dc6
MD5 cc5798f09abc0c5b1dfd2d0db56f400b
BLAKE2b-256 50e505622d1d8708d538e5f739c5b2834d24522134fca8182b0ef0d277936705

See more details on using hashes here.

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