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).

Metadata

Release files for langchain-docuweave 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-docuweave 0.1.0
File Size Uploaded
langchain_docuweave-0.1.0.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-docuweave 0.1.0
File Interpreter ABI Platform
langchain_docuweave-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / langchain_docuweave-0.1.0.tar.gz

Download URL langchain_docuweave-0.1.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9faf400d2e31895060f9fad378721d90e9675300dbb9f9cfe1cb4db90cb73555
BLAKE2b-256 checksum
How to use checksums
f5e60379cc4ccf0e604eeb5eea4537eab1d125b34fcffa21057e54ae4b874a6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / langchain_docuweave-0.1.0-py3-none-any.whl

Download URL langchain_docuweave-0.1.0-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9db3b6e0d612690ae86ec5bc0fc10e19d54c3755bf663661b348c46098adf456
BLAKE2b-256 checksum
How to use checksums
ffea09f941ef49030907c97f8dc4ba038ba77bcd4377d7e65449bc85be6ba834
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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