#chunking #simd #nlp

chunk

The fastest semantic text chunking library — up to 1TB/s chunking throughput

9 releases (5 breaking)

Uses new Rust 2024

0.10.1 Mar 30, 2026
0.10.0 Mar 29, 2026
0.9.2 Jan 21, 2026
0.8.0 Jan 21, 2026
0.1.0 Jan 19, 2026

#349 in Text processing

Download history 1/week @ 2026-02-07 147/week @ 2026-02-14 50/week @ 2026-02-21 148/week @ 2026-02-28 80/week @ 2026-03-07 73/week @ 2026-03-14 288/week @ 2026-03-21 51/week @ 2026-03-28 42/week @ 2026-04-04 15/week @ 2026-04-11 53/week @ 2026-04-18 52/week @ 2026-04-25 1979/week @ 2026-05-02 2859/week @ 2026-05-09

4,948 downloads per month
Used in 4 crates

MIT/Apache

115KB
2K SLoC

chunk

chunk

the fastest text chunking library — up to 1 TB/s throughput

crates.io PyPI npm docs.rs License


you know how every chunking library claims to be fast? yeah, we actually meant it.

chunk splits text at semantic boundaries (periods, newlines, the usual suspects) and does it stupid fast. we're talking "chunk the entire english wikipedia in 120ms" fast.

want to know how? read the blog post where we nerd out about SIMD instructions and lookup tables.

Note

chunk was previously known as memchunk. It still contains the chunk method but now also includes other basic operations that power chonkie core.

Benchmark comparison

See benches/ for detailed benchmarks.

📦 Installation

cargo add chunk

looking for python or javascript?

🚀 Usage

use chunk::chunk;

let text = b"Hello world. How are you? I'm fine.\nThanks for asking.";

// With defaults (4KB chunks, split at \n . ?)
let chunks: Vec<&[u8]> = chunk(text).collect();

// With custom size
let chunks: Vec<&[u8]> = chunk(text).size(1024).collect();

// With custom delimiters
let chunks: Vec<&[u8]> = chunk(text).delimiters(b"\n.?!").collect();

// With multi-byte pattern (e.g., metaspace ▁ for SentencePiece tokenizers)
let metaspace = "".as_bytes();
let chunks: Vec<&[u8]> = chunk(text).pattern(metaspace).prefix().collect();

// With consecutive pattern handling (split at START of runs, not middle)
let chunks: Vec<&[u8]> = chunk(b"word   next")
    .pattern(b" ")
    .consecutive()
    .collect();

// With forward fallback (search forward if no pattern in backward window)
let chunks: Vec<&[u8]> = chunk(text)
    .pattern(b" ")
    .forward_fallback()
    .collect();

📝 Citation

If you use chunk in your research, please cite it as follows:

@software{chunk2025,
  author = {Minhas, Bhavnick},
  title = {chunk: The fastest text chunking library},
  year = {2025},
  publisher = {GitHub},
  howpublished = {\url{https://github.com/chonkie-inc/chunk}},
}

📄 License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Dependencies

~310–440KB