Skip to main content

langchain-docuweave

LangChain integration for DocuWeave — a PDF loader that reconstructs the document's heading hierarchy before chunking, so each chunk knows which section it came from.

Installation

pip install -U langchain-docuweave

Usage

from langchain_docuweave import DocuWeaveLoader

loader = DocuWeaveLoader("paper.pdf", max_tokens=512)
docs = loader.load()

print(docs[0].metadata["section_path"])
# "3 Methods > 3.2 Experimental Setup"

# or stream one chunk at a time
for doc in loader.lazy_load():
    print(doc.page_content[:80])
    print(doc.metadata["section_path"])

Metadata

Each returned Document includes:

Field Description
source Path to the PDF
section_title Heading text of the section
section_path Full breadcrumb, e.g. "3 Methods > 3.2 Setup"
section_level Nesting depth (0 = top-level)
page_start / page_end 1-based page numbers
previous_chunk_id / next_chunk_id Linked-list pointers for context expansion
hierarchy_confidence [0, 1] score; below 0.3 means scanned/image-heavy PDF

Why not PyMuPDFLoader?

PyMuPDFLoader extracts text per page. DocuWeaveLoader builds a section tree from heading signals across the full document and cuts chunks at section boundaries. In a benchmark of 390 PDFs / 3,927 QA pairs, this improved Recall@1 by +23.4% over recursive character splitting (p<0.01, bge-base-en-v1.5).

Download files

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

Source Distribution

langchain_docuweave-0.1.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

langchain_docuweave-0.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for langchain_docuweave-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9faf400d2e31895060f9fad378721d90e9675300dbb9f9cfe1cb4db90cb73555
MD5 a8a25df00bb698ed9a4b5e5334a96bc6
BLAKE2b-256 f5e60379cc4ccf0e604eeb5eea4537eab1d125b34fcffa21057e54ae4b874a6c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_docuweave-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9db3b6e0d612690ae86ec5bc0fc10e19d54c3755bf663661b348c46098adf456
MD5 8a3d12488fede7c9155ea6615b186634
BLAKE2b-256 ffea09f941ef49030907c97f8dc4ba038ba77bcd4377d7e65449bc85be6ba834

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 Sentry Error logging StatusPage Status page