<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Omer Cihangiroglu</title>
    <description>The latest articles on DEV Community by Omer Cihangiroglu (@devel0mer).</description>
    <link>https://dev.to/devel0mer</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4244204%2F57ab13fd-9cf6-4c45-b684-84a886bf36be.JPG</url>
      <title>DEV Community: Omer Cihangiroglu</title>
      <link>https://dev.to/devel0mer</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devel0mer"/>
    <language>en</language>
    <item>
      <title>git bisect doesn't work on lockfiles — so I built whichdep</title>
      <dc:creator>Omer Cihangiroglu</dc:creator>
      <pubDate>Tue, 24 Nov 2026 15:24:30 +0000</pubDate>
      <link>https://dev.to/devel0mer/git-bisect-doesnt-work-on-lockfiles-so-i-built-whichdep-4d37</link>
      <guid>https://dev.to/devel0mer/git-bisect-doesnt-work-on-lockfiles-so-i-built-whichdep-4d37</guid>
      <description>&lt;p&gt;Your CI was green yesterday. Today a Dependabot PR, a &lt;code&gt;cargo update&lt;/code&gt;, or a fresh install bumped 15 packages at once and your test suite went red.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git bisect&lt;/code&gt; can't help you here: &lt;strong&gt;your code didn't change — your lockfile did.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So you end up doing the dreaded manual loop: pinning packages one by one, fighting half-broken transitive dependency graphs, waiting on rebuilds, and wondering if a test failure is a real regression or just an invalid package combination.&lt;/p&gt;

&lt;p&gt;I built &lt;a href="https://github.com/devel0mer/whichdep" rel="noopener noreferrer"&gt;&lt;strong&gt;whichdep&lt;/strong&gt;&lt;/a&gt; (&lt;code&gt;v0.1.0&lt;/code&gt;, Apache-2.0) to automate that loop across &lt;strong&gt;Cargo, uv, pip, npm, and pnpm&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgds578ul67fnldhgjcfx.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgds578ul67fnldhgjcfx.gif" alt="whichdep isolating a breaking npm dependency update in 7 trials" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Try it in one command
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;whichdep&lt;/code&gt; is written in Rust with &lt;strong&gt;zero external runtime dependencies&lt;/strong&gt;, and ships prebuilt native binaries for Linux, macOS, and Windows across all three registries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Node.js / npm (no install needed)&lt;/span&gt;
npx whichdep --good HEAD -- npm &lt;span class="nb"&gt;test&lt;/span&gt;

&lt;span class="c"&gt;# Python (PyPI / uv)&lt;/span&gt;
uvx whichdep --good HEAD -- pytest
&lt;span class="c"&gt;# or: pip install whichdep&lt;/span&gt;

&lt;span class="c"&gt;# Rust (crates.io)&lt;/span&gt;
cargo install whichdep
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You run it in your repo with the &lt;strong&gt;failing&lt;/strong&gt; lockfile checked out and point &lt;code&gt;--good&lt;/code&gt; at a working git revision (or lockfile path). Every trial runs in an isolated copy of your project, and build caches live outside your source tree — your working directory is never modified.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why naive binary search breaks on lockfiles
&lt;/h2&gt;

&lt;p&gt;At first glance, bisecting a lockfile diff sounds like a textbook binary search. In practice, three real-world constraints break naive bisection immediately:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Invalid lockfile mixes must not be blamed
&lt;/h3&gt;

&lt;p&gt;If you apply half of a &lt;code&gt;Cargo.lock&lt;/code&gt; or &lt;code&gt;package-lock.json&lt;/code&gt; diff, you often produce a lockfile that cannot legally exist (a crate upgraded to a new major version without its updated transitive dependency, or a removed package still required by an un-upgraded parent).&lt;/p&gt;

&lt;p&gt;If a tool treats &lt;em&gt;"the package manager refused to install this mix"&lt;/em&gt; as &lt;em&gt;"test failed"&lt;/em&gt;, it confidently blames an innocent package.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;whichdep&lt;/code&gt; uses &lt;strong&gt;three-valued outcomes&lt;/strong&gt; (&lt;code&gt;Pass&lt;/code&gt;, &lt;code&gt;Fail&lt;/code&gt;, &lt;code&gt;Unresolved&lt;/code&gt;) combined with &lt;strong&gt;Zeller's delta debugging (&lt;code&gt;ddmin&lt;/code&gt;)&lt;/strong&gt; and an &lt;strong&gt;adaptive binary-search strategy&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each adapter parses the lockfile dependency graph and builds a &lt;strong&gt;dependency closure&lt;/strong&gt; (&lt;code&gt;up&lt;/code&gt; / &lt;code&gt;down&lt;/code&gt;), so the search only proposes structurally closed configurations.&lt;/li&gt;
&lt;li&gt;Before running your test command, &lt;code&gt;whichdep&lt;/code&gt; verifies that the package manager kept the rendered lockfile as written (e.g., &lt;code&gt;cargo fetch&lt;/code&gt;, &lt;code&gt;npm ci&lt;/code&gt;, &lt;code&gt;pnpm install --frozen-lockfile&lt;/code&gt;, &lt;code&gt;uv sync --frozen&lt;/code&gt;, &lt;code&gt;pip check&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Anything that cannot be resolved or built is classified &lt;strong&gt;&lt;code&gt;Unresolved&lt;/code&gt;&lt;/strong&gt; and skipped — never blamed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. True interactions vs. required companion updates
&lt;/h3&gt;

&lt;p&gt;This was my favorite bug to catch right before &lt;code&gt;v0.1.0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When I tested &lt;code&gt;whichdep&lt;/code&gt; against a live &lt;code&gt;crates.io&lt;/code&gt; diff bumping &lt;code&gt;rand&lt;/code&gt; from &lt;code&gt;0.8.5&lt;/code&gt; to &lt;code&gt;0.9.5&lt;/code&gt; (with &lt;code&gt;RUSTFLAGS="-D warnings"&lt;/code&gt; turning the &lt;code&gt;thread_rng&lt;/code&gt; deprecation into a failure), &lt;code&gt;whichdep&lt;/code&gt; isolated the failure in 6 trials — and printed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Cause: these updates break the tests together
  getrandom  0.2.17 → 0.3.4
  rand  0.8.5 → 0.9.5
  rand_chacha  0.3.1 → 0.9.0
  rand_core  0.6.4 → 0.9.5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then suggested four separate &lt;code&gt;cargo update ... --precise&lt;/code&gt; commands, starting with &lt;code&gt;getrandom&lt;/code&gt; — which fails because &lt;code&gt;rand 0.9.5&lt;/code&gt; still requires &lt;code&gt;getrandom 0.3&lt;/code&gt;!&lt;/p&gt;

&lt;p&gt;The algorithm wasn't wrong — those four crates &lt;em&gt;had&lt;/em&gt; to move together in the closure — but the &lt;strong&gt;explanation&lt;/strong&gt; was misleading. They aren't four independent packages interacting; &lt;code&gt;rand&lt;/code&gt; is the single root change and the other three are required companions.&lt;/p&gt;

&lt;p&gt;Adding &lt;code&gt;Closure::roots&lt;/code&gt; fixed both the diagnosis and the revert command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Root cause
  rand  0.8.5 → 0.9.5
  Required companion updates:
    getrandom  0.2.17 → 0.3.4
    rand_chacha  0.3.1 → 0.9.0
    rand_core  0.6.4 → 0.9.5

Verified: The bad lockfile without this cause passes the tests again.

To put it back to the good version:
  cargo update rand@0.9.5 --precise 0.8.5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now &lt;code&gt;"these updates break the tests together"&lt;/code&gt; is reserved exclusively for &lt;strong&gt;genuine multi-root interactions&lt;/strong&gt; (when two independent packages pass individually and only fail when upgraded together).&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Flaky tests and "never confidently wrong"
&lt;/h3&gt;

&lt;p&gt;A single flaky failure can derail a bisection and point at an innocent package. Passing &lt;code&gt;--repeat 3&lt;/code&gt; makes &lt;code&gt;whichdep&lt;/code&gt; run each trial multiple times and treat any disagreement as &lt;code&gt;Unresolved&lt;/code&gt; instead of &lt;code&gt;Fail&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In our seeded flakiness benchmark (&lt;code&gt;tests/flakiness_e4.rs&lt;/code&gt;, 300 rounds per cell, &lt;code&gt;n = 20&lt;/code&gt;, &lt;code&gt;adaptive&lt;/code&gt; strategy):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Flake rate &lt;code&gt;p&lt;/code&gt;
&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;--repeat 1&lt;/code&gt; false causes&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;--repeat 3&lt;/code&gt; false causes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;5%&lt;/td&gt;
&lt;td&gt;0.7%&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.0%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10%&lt;/td&gt;
&lt;td&gt;1.3%&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.0%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20%&lt;/td&gt;
&lt;td&gt;8.7%&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.0%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;And when a failure doesn't reproduce at all (for example, running the &lt;code&gt;rand 0.9&lt;/code&gt; test &lt;em&gt;without&lt;/em&gt; &lt;code&gt;RUSTFLAGS="-D warnings"&lt;/code&gt;), &lt;code&gt;whichdep&lt;/code&gt; prints &lt;code&gt;No result&lt;/code&gt; with the tail of the trial log — and even hints to try &lt;code&gt;RUSTFLAGS="-D warnings"&lt;/code&gt; when Cargo emits compiler warnings on a passing run.&lt;/p&gt;




&lt;h2&gt;
  
  
  Early live-registry validation results
&lt;/h2&gt;

&lt;p&gt;Before benchmarking large upstream repositories, I validated &lt;code&gt;whichdep&lt;/code&gt; end-to-end against real PyPI, npm, and crates.io lockfiles using minimal synthetic reproducer harnesses for three well-known upstream breaking releases:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Ecosystem&lt;/th&gt;
&lt;th&gt;Breaking update&lt;/th&gt;
&lt;th&gt;Changes&lt;/th&gt;
&lt;th&gt;Trials&lt;/th&gt;
&lt;th&gt;Unresolved&lt;/th&gt;
&lt;th&gt;Wall time&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Python (&lt;code&gt;pip&lt;/code&gt;)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;httpx 0.27.2 → 0.28.1&lt;/code&gt; (&lt;code&gt;proxies=&lt;/code&gt; removed)&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;36s&lt;/td&gt;
&lt;td&gt;Exact root cause&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Node (&lt;code&gt;npm&lt;/code&gt;)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;chalk 4.1.2 → 6.0.1&lt;/code&gt; (CJS → ESM)&lt;/td&gt;
&lt;td&gt;14&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;4.2s&lt;/td&gt;
&lt;td&gt;Exact root cause · &lt;strong&gt;Verified&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Rust (&lt;code&gt;cargo&lt;/code&gt;)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;rand 0.8.5 → 0.9.5&lt;/code&gt; (&lt;code&gt;thread_rng&lt;/code&gt; under &lt;code&gt;-D warnings&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;6.0s&lt;/td&gt;
&lt;td&gt;Exact root cause + companions · &lt;strong&gt;Verified&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Every one of those three live runs caught a real edge case that offline unit tests missed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;httpx&lt;/code&gt; run revealed that &lt;code&gt;pip&lt;/code&gt; needed reverse &lt;code&gt;# via&lt;/code&gt; closure edges for &lt;strong&gt;removed&lt;/strong&gt; transitive dependencies (&lt;code&gt;sniffio&lt;/code&gt;) so revert verification passes cleanly.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;chalk&lt;/code&gt; run validated reverse closure restoration of 7 removed transitive packages in ~560ms per trial.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;rand&lt;/code&gt; run exposed the root-vs-companion UX bug and led to the &lt;code&gt;-D warnings&lt;/code&gt; hint.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Running it automatically on Dependabot / Renovate PRs
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;whichdep&lt;/code&gt; also ships with a composite GitHub Action, sticky PR comments, &lt;code&gt;$GITHUB_STEP_SUMMARY&lt;/code&gt;, and a machine-readable JSON format (&lt;code&gt;whichdep-report-v2&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;devel0mer/whichdep@v0.1.0&lt;/span&gt;
  &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;good&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;origin/${{ github.base_ref }}&lt;/span&gt;
    &lt;span class="na"&gt;strategy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;adaptive&lt;/span&gt;
    &lt;span class="na"&gt;test-command&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;cargo test -q&lt;/span&gt;
    &lt;span class="na"&gt;format&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;json&lt;/span&gt;
    &lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;whichdep-report.json&lt;/span&gt;
    &lt;span class="na"&gt;github-summary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"true"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(See &lt;code&gt;docs/PLATFORM.md&lt;/code&gt; in the repo for the recommended two-job workflow so untrusted PR code never gets write permissions to comment on PRs.)&lt;/p&gt;




&lt;h2&gt;
  
  
  What's next — and help wanted!
&lt;/h2&gt;

&lt;p&gt;The three runs above are &lt;strong&gt;live-registry synthetic validations&lt;/strong&gt; — real packages and lockfiles, minimal harnesses. My next milestone (E1 in &lt;code&gt;PLAN.md&lt;/code&gt;) is building a public &lt;strong&gt;regression corpus of real upstream repository breakages&lt;/strong&gt; (e.g., Bevy #12044, real Dependabot/Renovate PRs across Cargo, uv, npm, and pnpm) and comparing &lt;code&gt;ddmin&lt;/code&gt; vs. &lt;code&gt;adaptive&lt;/code&gt; trial counts.&lt;/p&gt;

&lt;p&gt;If you've recently hit a gnarly lockfile update or Dependabot PR that broke CI in a public repo, &lt;strong&gt;drop a link in the comments&lt;/strong&gt; — I'd love to add it to the corpus and test &lt;code&gt;whichdep&lt;/code&gt; against it!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/devel0mer/whichdep" rel="noopener noreferrer"&gt;https://github.com/devel0mer/whichdep&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;crates.io:&lt;/strong&gt; &lt;a href="https://crates.io/crates/whichdep" rel="noopener noreferrer"&gt;https://crates.io/crates/whichdep&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PyPI:&lt;/strong&gt; &lt;a href="https://pypi.org/project/whichdep/" rel="noopener noreferrer"&gt;https://pypi.org/project/whichdep/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;npm:&lt;/strong&gt; &lt;a href="https://www.npmjs.com/package/whichdep" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/whichdep&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>rust</category>
      <category>opensource</category>
      <category>devops</category>
      <category>showdev</category>
    </item>
    <item>
      <title>37.1 MiB/s with Zero Token Overflows: Guaranteed Token Budgets and Table-Aware Chunking in text-chipper</title>
      <dc:creator>Omer Cihangiroglu</dc:creator>
      <pubDate>Sat, 21 Nov 2026 18:09:38 +0000</pubDate>
      <link>https://dev.to/devel0mer/371-mibs-with-zero-token-overflows-guaranteed-token-budgets-and-table-aware-chunking-in-34bl</link>
      <guid>https://dev.to/devel0mer/371-mibs-with-zero-token-overflows-guaranteed-token-budgets-and-table-aware-chunking-in-34bl</guid>
      <description>&lt;p&gt;In RAG pipelines, text chunking usually forces an uncomfortable trade-off:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Fast window splitters&lt;/strong&gt; (like a raw &lt;code&gt;tiktoken&lt;/code&gt; loop) are quick, but they slice right through Markdown code blocks, split words in half, and orphan table rows from their column headers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Structure-aware splitters&lt;/strong&gt; try to respect document layout, but they are often 4×–11× slower, pull in dozens of dependencies, and frequently overshoot hard token limits (returning 513–514 tokens on a 512-token budget when headings or BPE boundary joins aren't re-counted).
With &lt;strong&gt;&lt;a href="https://github.com/kameh0use/text-chipper" rel="noopener noreferrer"&gt;text-chipper v1.1.0&lt;/a&gt;&lt;/strong&gt;, the goal was to eliminate that trade-off: build &lt;strong&gt;the fastest chunker that guarantees both strict token budgets and Markdown/table structural awareness&lt;/strong&gt;, backed by reproducible benchmarks.
Here is what the benchmark numbers look like, the two major problems we solved in &lt;code&gt;v1.1.0&lt;/code&gt; (Markdown table-header repetition and zero-GIL Hugging Face tokenizers), and how the Rust engine achieves this speed without breaking source offsets.
---
## 1. The Benchmark: Speed + Strict Token Compliance + Structure
We benchmarked &lt;code&gt;text-chipper&lt;/code&gt; against seven popular chunking approaches across 12 workloads (synthetic prose, Markdown, code, PubMed, finance, Wikipedia, chat logs, and stress cases) with a strict &lt;strong&gt;512-token budget&lt;/strong&gt; (&lt;code&gt;cl100k_base&lt;/code&gt;, &lt;code&gt;overlap=0&lt;/code&gt;).
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu4xfjviyjw3hqqq8fg5t.png" alt="Scorecard: token limit, words, source text and code fences per library, with speed" width="799" height="583"&gt;
### Throughput (Single-Core Geometric Mean across 12 Workloads)
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjo9wkcedfxhgki8ulbh4.png" alt="Bar chart: geometric-mean throughput of each library over all 12 workloads" width="800" height="527"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;text-chipper&lt;/code&gt; (default Markdown- and table-aware strict mode):&lt;/strong&gt; &lt;strong&gt;37.1 MiB/s&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Plain &lt;code&gt;tiktoken&lt;/code&gt; window (no structure, cuts words/code):&lt;/strong&gt; 15.5 MiB/s&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Other chunking libraries:&lt;/strong&gt; 3.2 to 9.5 MiB/s (&lt;code&gt;text-chipper&lt;/code&gt; is &lt;strong&gt;3.9× to 11.6× faster&lt;/strong&gt;)
At the same time:&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;0 chunks over 512 tokens&lt;/strong&gt; across all 12 workloads (compared to 15 over-limit chunks in LangChain up to 514 tokens, and 18 each in &lt;code&gt;tiktoken&lt;/code&gt; window and Chonkie's &lt;code&gt;TokenChunker&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;100% of measured small code fences kept intact&lt;/strong&gt; (392 in &lt;code&gt;markdown_doc&lt;/code&gt; and 3,434 in &lt;code&gt;code_heavy&lt;/code&gt;).&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  - &lt;strong&gt;0 runtime dependencies&lt;/strong&gt; (~4 MB installed wheel size, ~2 ms import time).
&lt;/h2&gt;

&lt;h2&gt;
  
  
  2. New in v1.1.0: Markdown Table-Aware Splitting (Without Breaking Source Offsets)
&lt;/h2&gt;

&lt;p&gt;Consider a 200-row financial or inventory table in Markdown:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;| Row | Item | Category | Price |
| --- | --- | --- | ---: |
| 001 | Product-1 | Hardware | $10 |
...
| 200 | Product-200 | Hardware | $2000 |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When a 512-token budget forces this table to split into multiple chunks, two bad things typically happen in standard splitters:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A cut happens in the middle of a row (&lt;code&gt;| 045 | Prod&lt;/code&gt; in chunk 1, &lt;code&gt;uct-45 | Hardware |&lt;/code&gt; in chunk 2).&lt;/li&gt;
&lt;li&gt;Chunks 2..N lose the table header (&lt;code&gt;| Row | Item | Category | Price |&lt;/code&gt;), leaving the embedding model and LLM with floating rows of numbers that lack column names.
### How &lt;code&gt;text-chipper&lt;/code&gt; v1.1.0 solves it—while keeping &lt;code&gt;doc[start:end] == chunk.text&lt;/code&gt;
A core invariant of &lt;code&gt;text-chipper&lt;/code&gt; (verified across 26.9 million checks in our release test suite) is that &lt;strong&gt;&lt;code&gt;chunk.text&lt;/code&gt; is always an exact contiguous slice of the normalized input&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;start_index&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;end_index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we mutated &lt;code&gt;chunk.text&lt;/code&gt; on chunk 2 by injecting the table header from byte 0 into a row slice at byte 4,000, source byte/character offsets for citations and UI highlighting would break.&lt;br&gt;
Instead, &lt;code&gt;text-chipper&lt;/code&gt; treats the repeated table header as &lt;strong&gt;structural context&lt;/strong&gt;, just like section headings (&lt;code&gt;chunk.headers&lt;/code&gt;):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Tables that fit stay whole:&lt;/strong&gt; If the entire GFM table fits within &lt;code&gt;max_length&lt;/code&gt;, it is never split.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Row-boundary splitting:&lt;/strong&gt; If an oversized table must be split, row boundaries are promoted to top-level structural cut points (&lt;code&gt;R_ITEM&lt;/code&gt;), so rows are kept whole whenever they fit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Chunk 1 of the table&lt;/strong&gt; starts at the table's opening line in the source text, so &lt;code&gt;chunk.text&lt;/code&gt; already begins with the verbatim header and &lt;code&gt;| --- |&lt;/code&gt; delimiter row (&lt;code&gt;chunk.table_header&lt;/code&gt; is &lt;code&gt;None&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Chunks 2..N of the table&lt;/strong&gt; keep &lt;code&gt;chunk.text&lt;/code&gt; as the exact contiguous slice of data rows, attach the header + delimiter lines as &lt;code&gt;chunk.table_header&lt;/code&gt;, and automatically prepend them in &lt;code&gt;chunk.contextualized_text&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Budget-enforced:&lt;/strong&gt; The token cost of the repeated table header is reserved up front during row packing and re-verified on &lt;code&gt;chunk.contextualized_text&lt;/code&gt; by the strict final gate.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;text_chipper&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;TextChipper&lt;/span&gt;
&lt;span class="n"&gt;header&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"| Row | Item | Category | Price |\n| --- | --- | --- | ---: |"&lt;/span&gt;
&lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"| {i:03d} | Product-{i} | Hardware | ${i * 10} |"&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;201&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"# Inventory\n\n"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;header&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"\n"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"\n"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"\n"&lt;/span&gt;
&lt;span class="n"&gt;chipper&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;TextChipper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;overlap&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;encoding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"cl100k_base"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;chunks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;chipper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;token_count&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;120&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;chipper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;count_tokens&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contextualized_text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;token_count&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;header&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contextualized_text&lt;/span&gt;          &lt;span class="c1"&gt;# Every chunk has the table header!&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;start_index&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;end_index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;  &lt;span class="c1"&gt;# And exact source offsets still hold!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. New in v1.1.0: Zero-GIL Hugging Face Tokenizers &amp;amp; Multi-Tokenizer Guards
&lt;/h2&gt;

&lt;p&gt;If you run local embedding models (&lt;code&gt;BAAI/bge-large-en-v1.5&lt;/code&gt;, &lt;code&gt;nomic-embed-text&lt;/code&gt;, &lt;code&gt;jina-embeddings&lt;/code&gt;) or local LLMs (&lt;code&gt;Qwen&lt;/code&gt;, &lt;code&gt;Llama-3&lt;/code&gt;, &lt;code&gt;Mistral&lt;/code&gt;), counting tokens with OpenAI's &lt;code&gt;cl100k_base&lt;/code&gt; is dangerous: a 500-token chunk under &lt;code&gt;cl100k_base&lt;/code&gt; can easily be 610+ tokens under your model's actual tokenizer.&lt;br&gt;
Even worse, if you pass a Python &lt;code&gt;AutoTokenizer&lt;/code&gt; callback into a chunker, calling back into Python thousands of times per document acquires the Python GIL on every probe and destroys multi-threaded performance.&lt;/p&gt;
&lt;h3&gt;
  
  
  Native Rust handoff for &lt;code&gt;AutoTokenizer&lt;/code&gt; and &lt;code&gt;from_pretrained&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;In &lt;code&gt;text-chipper&lt;/code&gt; v1.1.0:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can call &lt;code&gt;TextChipper.from_pretrained("BAAI/bge-large-en-v1.5", max_length=510)&lt;/code&gt; directly (resolving &lt;code&gt;tokenizer.json&lt;/code&gt; from a local folder/file or via &lt;code&gt;huggingface_hub&lt;/code&gt; / &lt;code&gt;tokenizers&lt;/code&gt; / &lt;code&gt;transformers&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Or you can pass an already-loaded &lt;code&gt;transformers.PreTrainedTokenizerFast&lt;/code&gt; (&lt;code&gt;AutoTokenizer.from_pretrained(...)&lt;/code&gt;) or &lt;code&gt;tokenizers.Tokenizer&lt;/code&gt; via &lt;code&gt;tokenizer=&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;At initialization, &lt;code&gt;text-chipper&lt;/code&gt; extracts the serialized JSON from &lt;code&gt;.backend_tokenizer.to_str()&lt;/code&gt; and loads it directly into Hugging Face's native Rust &lt;code&gt;tokenizers&lt;/code&gt; crate (&lt;code&gt;Backend::from_tokenizer_bytes&lt;/code&gt;). &lt;strong&gt;During chunking, zero Python calls are made and the GIL is completely released.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Need a custom Python counter? You can also pass any &lt;code&gt;callable(text) -&amp;gt; int&lt;/code&gt; or object with &lt;code&gt;.encode(text)&lt;/code&gt;.
### Multi-Tokenizer Guards (&lt;code&gt;guard_tokenizers&lt;/code&gt;)
What if your pipeline sends the same chunk to &lt;strong&gt;both&lt;/strong&gt; an embedder (e.g. &lt;code&gt;bge-large-en-v1.5&lt;/code&gt;) &lt;strong&gt;and&lt;/strong&gt; a cross-encoder reranker (&lt;code&gt;bge-reranker-v2-m3&lt;/code&gt;) or LLM with a different vocabulary?
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;transformers&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;AutoTokenizer&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;text_chipper&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;TextChipper&lt;/span&gt;
&lt;span class="n"&gt;embed_tok&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;AutoTokenizer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_pretrained&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"BAAI/bge-large-en-v1.5"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;rerank_tok&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;AutoTokenizer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_pretrained&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"BAAI/bge-reranker-v2-m3"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;chipper&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;TextChipper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;510&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# leave 2 tokens for [CLS] and [SEP] under a 512 limit&lt;/span&gt;
    &lt;span class="n"&gt;overlap&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;tokenizer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;embed_tok&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;guard_tokenizers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;rerank_tok&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;chipper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;markdown_text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Guaranteed &amp;lt;= 510 tokens under BOTH BGE and BGE-reranker-v2-m3!&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;token_count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contextualized_text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Bounded-Memory Streaming on 500+ MiB Files
&lt;/h2&gt;

&lt;p&gt;When processing massive datasets or log exports, loading a 514.3 MiB file into a single Python string and calling &lt;code&gt;chunk()&lt;/code&gt; spikes process memory by &lt;strong&gt;4.6 GB&lt;/strong&gt;.&lt;br&gt;
Because &lt;code&gt;text-chipper&lt;/code&gt;'s &lt;code&gt;BlockParser&lt;/code&gt; and &lt;code&gt;SmartChunker&lt;/code&gt; are incremental line-driven state machines, &lt;code&gt;from_file_stream(path)&lt;/code&gt; streams the 514.3 MiB file in &lt;strong&gt;25 seconds&lt;/strong&gt; (20.5 MiB/s on a single core) with only &lt;strong&gt;56 MB&lt;/strong&gt; of memory growth—while pruning its Unicode normalization offset map behind the active chunk watermark.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5iee5hvxarpibn3xarkz.png" alt="Bar chart: memory growth of each library on a 514 MiB file, single-core lane" width="800" height="610"&gt;
&lt;/h2&gt;
&lt;h2&gt;
  
  
  Try It Out
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;text-chipper&lt;/code&gt; v1.1.0 is open source (Apache-2.0) and available now on PyPI and crates.io:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install -U text-chipper
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Repository &amp;amp; Benchmarks:&lt;/strong&gt; &lt;a href="https://github.com/kameh0use/text-chipper" rel="noopener noreferrer"&gt;https://github.com/kameh0use/text-chipper&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PyPI:&lt;/strong&gt; &lt;a href="https://pypi.org/project/text-chipper/" rel="noopener noreferrer"&gt;https://pypi.org/project/text-chipper/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rust Crate (&lt;code&gt;text_chipper&lt;/code&gt;):&lt;/strong&gt; &lt;a href="https://crates.io/crates/text_chipper" rel="noopener noreferrer"&gt;https://crates.io/crates/text_chipper&lt;/a&gt;
If you hit any strange Markdown tables or tokenizer edge cases in your RAG corpus, open an issue—I'd love to add them to the benchmark and fuzz suite!&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>rag</category>
      <category>python</category>
      <category>rust</category>
      <category>llm</category>
    </item>
    <item>
      <title>513 Tokens in a 512-Token Chunk: Why I Recount Every Chunk</title>
      <dc:creator>Omer Cihangiroglu</dc:creator>
      <pubDate>Wed, 18 Nov 2026 14:15:15 +0000</pubDate>
      <link>https://dev.to/devel0mer/513-tokens-in-a-512-token-chunk-why-i-recount-every-chunk-4e2f</link>
      <guid>https://dev.to/devel0mer/513-tokens-in-a-512-token-chunk-why-i-recount-every-chunk-4e2f</guid>
      <description>&lt;h6&gt;
  
  
  &lt;strong&gt;text-chipper&lt;/strong&gt; is a Rust RAG chunker with strict token budgets, structure-aware chunks, and bounded-memory streaming for large files.
&lt;/h6&gt;

&lt;p&gt;A token budget is only a hard limit if it is checked on the text actually returned. I built &lt;strong&gt;text-chipper&lt;/strong&gt; to do that while preserving Markdown structure and keeping large-file memory use in view.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/kameh0use/text-chipper" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; · &lt;a href="https://pypi.org/project/text-chipper/" rel="noopener noreferrer"&gt;PyPI&lt;/a&gt; · &lt;a href="https://crates.io/crates/text_chipper" rel="noopener noreferrer"&gt;crates.io&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In one benchmark using each library’s documented defaults and a 512-token limit, the tiktoken window and Chonkie’s &lt;code&gt;TokenChunker&lt;/code&gt; produced chunks of up to 513 tokens; LangChain reached 514. text-chipper’s strict mode re-counted every completed chunk, and none exceeded the limit.&lt;/p&gt;

&lt;p&gt;That is a result from a specific benchmark, not a claim that those libraries always exceed their limits. I have not isolated why those particular tiktoken and Chonkie chunks reached 513 tokens; the benchmark counted the delivered chunks but did not trace the libraries’ internal split and reconstruction steps. Adding heading context after an initial count is one separate way a pipeline can exceed its budget, and it is the failure mode text-chipper’s final recount guards against. I am not claiming it explains the benchmark overages.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I built it
&lt;/h2&gt;

&lt;p&gt;Chunking determines what enters an index and how information is packaged. A boundary can split a code example, separate a heading from its explanation, or create input that an embedding model cannot accept. These are ingestion problems that can later surface as missing or confusing retrieval context.&lt;/p&gt;

&lt;p&gt;I wanted a chunker that handled those details without requiring an entire large file to fit in memory. I also suspected that preserving document structure could help retrieval, but I have not measured retrieval quality or hallucination rates. That remains an open question, and one I hope to explore with people building real RAG systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  A token budget should be a real limit
&lt;/h2&gt;

&lt;p&gt;A chunker may estimate token counts as it builds chunks. But the text it delivers can differ from the text it counted during construction. This matters when the chunk includes extra context, such as a heading path: text that fit before contextualization can exceed the budget afterward.&lt;/p&gt;

&lt;p&gt;For an embedding model with a hard input limit, an oversized input may be rejected or truncated, depending on the API and the surrounding pipeline.&lt;/p&gt;

&lt;p&gt;In text-chipper, the default &lt;strong&gt;strict mode&lt;/strong&gt; re-tokenizes each completed chunk in the exact form it returns, including heading context. For the configured tokenizer, every returned chunk satisfies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;token_count &amp;lt;= max_length
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a single Unicode grapheme cluster is larger than the budget, strict mode raises &lt;code&gt;ValueError&lt;/code&gt; instead of returning an oversized chunk. This guarantee applies to the tokenizer you configure; it matches an embedding model’s limit only if that model uses the same tokenizer. A non-strict mode is available when an approximate budget is acceptable and speed matters more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Text has structure, not just tokens
&lt;/h2&gt;

&lt;p&gt;Markdown contains headings, paragraphs, lists, metadata, and fenced code. A generic token window does not recognize these as meaningful units. For example, it can split a code sample halfway through a parameter or detach it from the heading that explains it.&lt;/p&gt;

&lt;p&gt;text-chipper divides a document into blocks at blank lines, tracks heading paths, and keeps fenced code blocks and list items whole whenever they fit within the budget. It does not split a Unicode grapheme cluster, such as an emoji sequence or combining mark, and its offsets map back to the original input.&lt;/p&gt;

&lt;p&gt;I chose a lightweight Markdown block parser rather than a complete CommonMark implementation so files can be processed as a stream. That choice has limits: tables, block quotes, and HTML blocks receive no special handling. The &lt;a href="https://github.com/kameh0use/text-chipper#markdown-support-and-commonmark-conformance" rel="noopener noreferrer"&gt;README&lt;/a&gt; describes the supported constructs and compares its block boundaries with &lt;code&gt;pulldown-cmark&lt;/code&gt; on the CommonMark examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this looks like in an API docs assistant
&lt;/h2&gt;

&lt;p&gt;Imagine a team indexing a few hundred Markdown pages with short code examples. Its embedding model accepts 512 tokens per input.&lt;/p&gt;

&lt;p&gt;A fixed token window can split an example between chunks, leaving a retrieved result with half a call. It can also separate a heading from its explanation, so the returned text arrives without its topic.&lt;/p&gt;

&lt;p&gt;text-chipper keeps fenced blocks intact when they fit. The measured comparison with other chunkers appears below; these results apply to the tested fixtures.&lt;/p&gt;

&lt;p&gt;Headings are available as &lt;code&gt;headers&lt;/code&gt; metadata, and &lt;code&gt;contextualized_text&lt;/code&gt; prefixes the heading path so a chunk about retry settings still carries its section context. Strict mode counts that context against the token budget. Each chunk also includes &lt;code&gt;orig_start_index&lt;/code&gt; and &lt;code&gt;orig_end_index&lt;/code&gt;, which an application can use to link an answer back to its source.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;chipper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page_text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contextualized_text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# heading path + body&lt;/span&gt;
        &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;source_span&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;orig_start_index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;orig_end_index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only the splitting step changes; embedding, storage, and retrieval can stay as they are.&lt;/p&gt;

&lt;h2&gt;
  
  
  Streaming a 514 MiB file
&lt;/h2&gt;

&lt;p&gt;Peak memory can determine whether ingestion fits on a worker at all. I tested &lt;code&gt;from_file_stream()&lt;/code&gt; on a 514.3 MiB WikiText-103 file. Across three single-core runs, including file reading, it reached 20.5 MiB/s. After warm-up, memory grew by 56 MB and the process peaked at about 109 MB. Separately, I ran a whole-file test: reading the complete file into one Python string and then calling text-chipper’s &lt;code&gt;chunk()&lt;/code&gt; increased memory by about 4.6 GB. Other libraries also showed multi-gigabyte peaks in this whole-file test; several implementations were within 2 MB of one another. That suggests that materializing the file contributes much of the memory use, but I have not verified the cause.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftzd48fz2vj8q5uwngbtl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftzd48fz2vj8q5uwngbtl.png" alt="Streaming throughput on a 514 MiB file, single-core lane" width="799" height="524"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0mlcm429c9hinwx6jft8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0mlcm429c9hinwx6jft8.png" alt="Memory growth while chunking a 514 MiB file, single-core lane" width="800" height="610"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the separate large-file comparison, I fed the libraries that require complete strings roughly 8 MiB blocks; text-chipper was also run in block mode. Its memory grew by 140 MB in blocks, compared with 56 MB in direct streaming. SHA-256 hashes of the delivered text from &lt;code&gt;from_file_stream()&lt;/code&gt; and whole-file &lt;code&gt;chunk()&lt;/code&gt; matched. Block boundaries can change chunk output because chunks cannot cross them. These measurements came from a shared virtual machine, so treat throughput as indicative.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I measured
&lt;/h2&gt;

&lt;p&gt;The repository includes a &lt;a href="https://github.com/kameh0use/text-chipper/tree/main/benchmarks" rel="noopener noreferrer"&gt;benchmark harness&lt;/a&gt;, &lt;a href="https://github.com/kameh0use/text-chipper/tree/main/benchmarks/results/20261117_133546" rel="noopener noreferrer"&gt;raw results&lt;/a&gt;, and charts you can regenerate.&lt;/p&gt;

&lt;p&gt;The main comparison covered 12 workloads: synthetic prose, Markdown, code, multilingual text, real documents such as PubMed, finance, Wikipedia, and chat logs, plus stress cases. Each library was asked for chunks of at most 512 &lt;code&gt;cl100k_base&lt;/code&gt; tokens with no overlap. Results are medians of five cold runs in fresh processes on one core; only the chunking call was timed. Each library used its documented token-bounded route and defaults. I did not tune the other libraries, so a Markdown-specific configuration may do better than the defaults measured here. The tested text-chipper version was 0.2.3 at commit &lt;code&gt;d392ce3&lt;/code&gt;; library versions and hardware are in the raw results.&lt;/p&gt;

&lt;p&gt;This is not an equal-feature comparison. text-chipper’s default mode parses Markdown, adds heading context, and recounts every delivered chunk. The other libraries do not do all of that work. The speed results compare documented default routes, not implementations doing identical work.&lt;/p&gt;

&lt;h3&gt;
  
  
  Results at a glance
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Measure&lt;/th&gt;
&lt;th&gt;Result in these workloads&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Token limit&lt;/td&gt;
&lt;td&gt;No text-chipper chunk exceeded 512 tokens. LangChain had 15 over-limit chunks; the tiktoken window and Chonkie’s &lt;code&gt;TokenChunker&lt;/code&gt; had 18 each (maximums: 514 and 513).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Throughput&lt;/td&gt;
&lt;td&gt;37.1 MiB/s geometric mean; fastest on 10 of 12 workloads. That was 2.4× the plain tiktoken window and 3.9–11.6× the other chunkers.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Word boundaries&lt;/td&gt;
&lt;td&gt;One measured mid-word cut by text-chipper out of 1,259 cut points (&amp;lt;0.1%); token windows cut words at up to 35.5% of measured cut points. The harness excludes scripts without whitespace-separated words.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Small code fences&lt;/td&gt;
&lt;td&gt;text-chipper, &lt;code&gt;semantic-text-splitter&lt;/code&gt;, and &lt;code&gt;semchunk&lt;/code&gt; kept all measured fences intact. Token windows and Chonkie broke roughly 21–23%. This result is specific to these fixtures, not unique to text-chipper.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Working memory&lt;/td&gt;
&lt;td&gt;During chunking, text-chipper added 1.7 MB on average and about 11.7 MB on its most memory-intensive workload. Whole-process peak memory includes Python and the tokenizer.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi9nnhqncnzb9zra0kilm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi9nnhqncnzb9zra0kilm.png" alt="Benchmark scorecard for token limits, word boundaries, code fences and speed" width="799" height="583"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The comparisons ran on one shared virtual machine. Treat the ratios as indicative, especially on small files.&lt;/p&gt;

&lt;h3&gt;
  
  
  Unicode and replacement characters
&lt;/h3&gt;

&lt;p&gt;On a 2 MiB CJK stress workload with no separators, the tiktoken window, Chonkie’s &lt;code&gt;TokenChunker&lt;/code&gt;, and Chonkie’s &lt;code&gt;RecursiveChunker&lt;/code&gt; each produced 751 chunks; 245 chunks from each method contained U+FFFD replacement characters. text-chipper produced 774 chunks and none contained U+FFFD.&lt;/p&gt;

&lt;p&gt;A chunk containing U+FFFD does not mean all of its characters were lost. In a separate diagnostic on a synthetic CJK file of about 1.7 million non-whitespace characters, 546 of 2,833 chunks (19.3%) from a 512-token tiktoken window contained U+FFFD; 286 characters were lost (0.017% of the text). That diagnostic is separate from the benchmark above. text-chipper’s flat mode produced no replacement characters and lost nothing on the same file. The &lt;a href="https://github.com/kameh0use/text-chipper/blob/main/benchmarks/cjk_loss_check.py" rel="noopener noreferrer"&gt;counting script&lt;/a&gt; is available in the repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where text-chipper may not fit
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mostly plain prose:&lt;/strong&gt; there may be less structure to preserve, though strict budgets and word-aware cuts still apply.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Non-Markdown input:&lt;/strong&gt; text-chipper does not read HTML, PDF, or DOCX. Convert those formats to Markdown or text first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Need a full syntax tree:&lt;/strong&gt; it is not a full CommonMark parser and does not split code by function or class. Tables, block quotes, and HTML blocks are not special-cased; long tables do not repeat their header row.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Need another Python tokenizer:&lt;/strong&gt; Python supports built-in OpenAI encodings plus &lt;code&gt;chars&lt;/code&gt; and &lt;code&gt;words&lt;/code&gt;. Hugging Face &lt;code&gt;tokenizer.json&lt;/code&gt; support requires a build with the &lt;code&gt;hf&lt;/code&gt; feature; custom counters are currently available only from Rust.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Need flat mode on a very large file:&lt;/strong&gt; &lt;code&gt;include_context=False&lt;/code&gt; does not parse Markdown and reads the whole file; it is limited to 32 MiB. Bounded-memory streaming uses the default Markdown-aware mode.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The question I have not answered yet
&lt;/h2&gt;

&lt;p&gt;These benchmarks measure speed and chunk behavior, not retrieval quality. I have not tested how these chunks affect search results with controlled embeddings, retrieval settings, and relevance judgments. Structure-aware chunks may preserve useful context without improving search; that needs a separate evaluation. I also have not tested whether they reduce hallucinations.&lt;/p&gt;

&lt;p&gt;Retrieval determines what evidence a RAG system places in front of a model. I want to measure how chunking affects that evidence before making stronger claims.&lt;/p&gt;

&lt;p&gt;That is where I would especially value help. If you work on retrieval evaluation, code-heavy documentation, multilingual corpora, or large knowledge bases, I would welcome feedback, reproducible test cases, and collaboration on a controlled comparison against established approaches.&lt;/p&gt;

&lt;p&gt;Next on my list: retrieval-quality comparisons, better handling for Markdown tables and other constructs, and more tokenizer integrations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;text-chipper is licensed under Apache-2.0.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install text-chipper
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;text_chipper&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;TextChipper&lt;/span&gt;

&lt;span class="n"&gt;chipper&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;TextChipper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;512&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;overlap&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;encoding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"cl100k_base"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;chipper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;markdown_text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;token_count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contextualized_text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example uses &lt;code&gt;overlap=50&lt;/code&gt; to show the option; the benchmark comparison above used no overlap.&lt;/p&gt;

&lt;p&gt;For Rust projects, add the crate with Cargo. The Rust crate uses an underscore in its name; the Python package uses a hyphen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cargo add text_chipper
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The library also supports file processing, batch operations, streaming, built-in tokenizer backends, and LangChain and LlamaIndex adapters.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/kameh0use/text-chipper" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pypi.org/project/text-chipper/" rel="noopener noreferrer"&gt;PyPI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://crates.io/crates/text_chipper" rel="noopener noreferrer"&gt;crates.io&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you try text-chipper on your documents, I’d value hearing where it works well and where it falls short. A small, reproducible example in a &lt;a href="https://github.com/kameh0use/text-chipper/issues" rel="noopener noreferrer"&gt;GitHub issue&lt;/a&gt; is especially useful.&lt;/p&gt;

&lt;p&gt;If you work on RAG systems, what retrieval test would convince you that a chunker is helping on your data?&lt;/p&gt;

</description>
      <category>rag</category>
      <category>rust</category>
      <category>python</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
