Skip to main content

chunkr

⚡ Blazingly Fast Document & Text Chunking for LLMs, Agents and RAG

Crates.io PyPI License

chunkr is a high-performance document chunking library built in Rust with first-class Python native bindings for Large Language Models (LLMs) and Retrieval-Augmented Generation (RAG) applications. It delivers throughput up to hundreds of MB/sec with zero superfluous heap allocations, advanced structure awareness, OpenAI BPE tokenization, semantic clustering, proposition decomposition, query-adaptive sizing, agentic topic segmentation, and multi-core parallel processing.


📦 Installation

Rust

Add chunkr to your Cargo.toml:

[dependencies]
chunkr = "1.0"

Python

Install chunkr-rs via pip:

pip install chunkr-rs

Or build from source with maturin:

maturin develop --release

🚀 Supported Chunking Strategies (12 Strategies)

Strategy Rust Chunker Python Chunker Description
Recursive RecursiveChunker chunkr.RecursiveChunker SIMD-accelerated recursive separator splitting (~600+ MB/s)
Token BPE TokenChunker chunkr.TokenChunker OpenAI BPE token splitting (cl100k_base, o200k_base, etc.)
Sentence SentenceChunker chunkr.SentenceChunker Abbreviation & decimal protected sentence boundary splitting
Paragraph ParagraphChunker chunkr.ParagraphChunker Paragraph grouping across \n\n boundaries
Semantic SemanticChunker chunkr.SemanticChunker Distance threshold breakpoint clustering
Proposition PropositionChunker chunkr.PropositionChunker Atomic factual claim extraction with subject propagation
Contextual ContextualChunker chunkr.ContextualChunker Anthropic-style situational document preface injection
Query-Aware QueryAwareChunker chunkr.QueryAwareChunker Search query hotspot detection & adaptive sizing
Agentic AgenticChunker chunkr.AgenticChunker Autonomous discourse transition & topic segmentation
Hierarchical HierarchicalChunker chunkr.HierarchicalChunker Parent-child pairs & multi-level tree generation
Markdown MarkdownChunker chunkr.MarkdownChunker Header hierarchy (#–######) & breadcrumb paths
Code CodeChunker chunkr.CodeChunker Multi-language syntax chunking (Rust, Python, JS, Go, etc.)

Python Quickstart

import chunkr

sample_text = (
    "Convolutional neural networks specialize in visual imagery. "
    "Recurrent networks process sequential text.\n\n"
    "In conclusion, deep learning powers modern vision systems."
)

# 1. Recursive Character Chunking
recursive_chunker = chunkr.RecursiveChunker(chunk_size=500, overlap=50)
docs = recursive_chunker.chunk(sample_text)
for doc in docs:
    print(doc.content, doc.metadata)

# 2. Token-Based Chunking (OpenAI cl100k_base / GPT-4)
token_chunker = chunkr.TokenChunker(chunk_size=100, overlap=20, encoding="cl100k_base")
token_docs = token_chunker.chunk(sample_text)

# 3. Query-Aware Adaptive Chunking
query_chunker = chunkr.QueryAwareChunker(query="neural networks", hotspot_sentences=1, context_sentences=2)
query_docs = query_chunker.chunk(sample_text)

# 4. Agentic Topic Chunking
agentic_chunker = chunkr.AgenticChunker(min_chars=100, max_chars=1000)
agentic_docs = agentic_chunker.chunk(sample_text)

# 5. Markdown Structure Chunking (with header breadcrumbs)
md_chunker = chunkr.MarkdownChunker(chunk_size=1000, overlap=100)
md_docs = md_chunker.chunk("# Title\n## Section\nContent...")

# 6. PDF Document Loading & Chunking
loader = chunkr.PDFLoader()
pages = loader.load_pages("path/to/document.pdf")
pdf_chunks = recursive_chunker.chunk(pages[0].content)

Rust Quickstart

use chunkr::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let text = "Convolutional neural networks specialize in visual imagery. Recurrent networks process sequential text.\n\nIn conclusion, deep learning powers modern vision.";

    // 1. Recursive Chunker
    let recursive_chunker = RecursiveChunker::new()
        .with_chunk_size(500)
        .with_overlap(50);
    let chunks = recursive_chunker.chunk(text)?;

    // 2. Query-Aware Adaptive Chunker
    let query_chunker = QueryAwareChunker::new("convolutional neural networks")
        .with_hotspot_sizing(1, 0)
        .with_context_sizing(3, 1);
    let query_chunks = query_chunker.chunk(text)?;

    // 3. Hierarchical Parent-Child Tree Chunker
    let hier_chunker = HierarchicalChunker::with_sizes(150, 20, 50, 10)?;
    let tree = hier_chunker.chunk_tree(text)?;

    // 4. PDF Document Loading & Chunking
    let loader = PDFLoader::new();
    let pdf_pages = loader.load_pages_from_file("tests/test_files/sample_doc.pdf")?;
    let pdf_chunks = recursive_chunker.chunk_documents(&pdf_pages)?;

    Ok(())
}

📊 In-Memory Speed Benchmark: Chunkr (Rust/Python) vs. LangChain

Pure in-memory Python runtime comparison (import chunkr vs. langchain-text-splitters):

Strategy & Test Case Document Size LangChain (ms) Chunkr (ms) LangChain Throughput Chunkr Throughput Speedup Factor
Fixed Char (100 KB) 100 KB 9.94 ms 0.59 ms 9.8 MB/s 166.0 MB/s 16.9x Faster
Fixed Char (1 MB) 1 MB 128.94 ms 9.89 ms 7.8 MB/s 101.1 MB/s 13.0x Faster
Recursive Char (100 KB) 100 KB 0.29 ms 0.11 ms 338.2 MB/s 864.1 MB/s 2.6x Faster
Recursive Char (1 MB) 1 MB 3.01 ms 1.87 ms 332.2 MB/s 534.3 MB/s 1.6x Faster
Recursive Char (5 MB) 5 MB 23.00 ms 9.89 ms 217.4 MB/s 505.6 MB/s 2.3x Faster
Markdown Language Split 500 KB 1.96 ms 0.81 ms 248.9 MB/s 603.8 MB/s 2.4x Faster
Markdown Header Parser 500 KB 41.81 ms 2.57 ms 11.7 MB/s 190.2 MB/s 16.3x Faster
Python Code Split 200 KB 0.39 ms 0.18 ms 500.8 MB/s 1087.0 MB/s 2.2x Faster

💡 Contributing

Contributions are welcome! Please check out the Contribution Guide to get started.

📝 License

Licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for chunkr-rs 1.0.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 chunkr-rs 1.0.0
File Size Uploaded
chunkr_rs-1.0.0.tar.gz 78.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for chunkr-rs 1.0.0
File
chunkr_rs-1.0.0-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
chunkr_rs-1.0.0-cp38-abi3-win32.whl CPython 3.8 abi3 Windows x86-32 Details
chunkr_rs-1.0.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details
chunkr_rs-1.0.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl CPython 3.8 abi3 Linux glibc 2.17+ IBM System/390x Details
chunkr_rs-1.0.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl CPython 3.8 abi3 Linux glibc 2.17+ PowerPC 64-le Details
chunkr_rs-1.0.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl CPython 3.8 abi3 Linux glibc 2.17+ ARMv7l Details
chunkr_rs-1.0.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details
chunkr_rs-1.0.0-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details
chunkr_rs-1.0.0-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details

Total release size: 44.4 MB

Release files / chunkr_rs-1.0.0.tar.gz

Download URL chunkr_rs-1.0.0.tar.gz
Size 78.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bd0b61a4dfd2b727f16a03866baa3d917bbecfde1b8399d71182309c2971aa08
BLAKE2b-256 checksum
How to use checksums
6b672b0632f6742047f32654eeb615a7159fb7825a35e8863f3d2cec4aef6c48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / chunkr_rs-1.0.0-cp38-abi3-win_amd64.whl

Download URL chunkr_rs-1.0.0-cp38-abi3-win_amd64.whl
Size 4.7 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
9c246f8c952bbefe9c6f3cd5318f4426882ffdb08d026c9b582a02d8e6be8a4a
BLAKE2b-256 checksum
How to use checksums
96f1162458cae35007d89995d3d90bc9f383d795ddb4d4a7701b041d43c9b2ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / chunkr_rs-1.0.0-cp38-abi3-win32.whl

Download URL chunkr_rs-1.0.0-cp38-abi3-win32.whl
Size 4.6 MB
Tags CPython 3.8 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
d5bb02bb0a757035fe1760b493c56059d4c2d9438adfe3fd5425ce6713b0556d
BLAKE2b-256 checksum
How to use checksums
36a5f44a372bd7c3009cfdc767583d2f6dbc3f4f960244d88b4b8fa0e68a9f9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / chunkr_rs-1.0.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL chunkr_rs-1.0.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.0 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
f7b0754e4c6d9f093dad781784c7f338e9b12970d2d032202166b9114bbd09a2
BLAKE2b-256 checksum
How to use checksums
ed39bacc775a1b3498bcc9cd9a7233c59e79373b0ae9e6c22a7b4f62cad6a885
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / chunkr_rs-1.0.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl

Download URL chunkr_rs-1.0.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Size 5.1 MB
Tags CPython 3.8 Linux glibc 2.17+ IBM System/390x abi3
SHA-256 checksum
How to use checksums
e59736bf1ddb8b75a0dc29e70753bb6b19db16da8401e6e5a605515f9c68d4bb
BLAKE2b-256 checksum
How to use checksums
becb085c29b29e85574ea16020afe169493d01f9c01a33084b411c7363397859
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / chunkr_rs-1.0.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl

Download URL chunkr_rs-1.0.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Size 5.3 MB
Tags CPython 3.8 Linux glibc 2.17+ PowerPC 64-le abi3
SHA-256 checksum
How to use checksums
7dcda26f3d9d06609b908df1c63d0726f15ee9fa305b5598de352f99a2dc3779
BLAKE2b-256 checksum
How to use checksums
9106f22199f326e13873ac12f23ee51e68bac4fb1f11242efa85aa9bd14ff043
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / chunkr_rs-1.0.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

Download URL chunkr_rs-1.0.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 4.9 MB
Tags CPython 3.8 Linux glibc 2.17+ ARMv7l abi3
SHA-256 checksum
How to use checksums
c1be060deffaaeeeb63315de94b23ee876cab89296fa923e8e101099327e4662
BLAKE2b-256 checksum
How to use checksums
58af4459c6bd55cc9885dfeda715eae68e730bf4a0d3729d5465c4f8432306ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / chunkr_rs-1.0.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL chunkr_rs-1.0.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 5.0 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
54a8aa1b34c1daae3987ea856d47a772527c2c689026d8991dc8ddf4ef2566e6
BLAKE2b-256 checksum
How to use checksums
2d0d880711d9402f6ea34daf56647833628d3685fedb1bb4070fdd89055e7f0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / chunkr_rs-1.0.0-cp38-abi3-macosx_11_0_arm64.whl

Download URL chunkr_rs-1.0.0-cp38-abi3-macosx_11_0_arm64.whl
Size 4.9 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a8ddf37c7f373b267e3fe3d6ecd046ae23cfbe987979daf3bb9cb6e863bfa6c1
BLAKE2b-256 checksum
How to use checksums
69b240146fafce3d4afb09d279da433dc5e36b48fc7825692766e7443fc5d6c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / chunkr_rs-1.0.0-cp38-abi3-macosx_10_12_x86_64.whl

Download URL chunkr_rs-1.0.0-cp38-abi3-macosx_10_12_x86_64.whl
Size 4.9 MB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
39c1f64b07ac516bdc2acf026ffbb0d7769005d883a44e385ee209acf88238c0
BLAKE2b-256 checksum
How to use checksums
59d9f0637efdd2c4646f356aa32fc47932a0d33905baf693e6d6cb53302239d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release history Release notifications | RSS feed

1.4.0

6 release files

1.0.1

10 release files

This release

1.0.0 This release

10 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