HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
zeroentropy-ai
zchunk
Python2024–2024
zeroentropy-ai / zchunk

zchunk

A new chunking strategy developed by ZeroEntropy for general semantic chunking using Llama-70B.

2Distinct people
4Mentions
0Explicit recommenders
277GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

A new chunking strategy developed by ZeroEntropy for general semantic chunking using Llama-70B.

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:56:07 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by day4 dated mentions

Observed mentions: 2024-11-15 16:39:50 UTC to 2024-12-04 18:41:24 UTC.

01232024-11-15 00:00:00 UTC to 2024-11-16 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 commentsNov 152024-11-16 00:00:00 UTC to 2024-11-17 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-11-17 00:00:00 UTC to 2024-11-18 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-11-18 00:00:00 UTC to 2024-11-19 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-11-19 00:00:00 UTC to 2024-11-20 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-11-20 00:00:00 UTC to 2024-11-21 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-11-21 00:00:00 UTC to 2024-11-22 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-11-22 00:00:00 UTC to 2024-11-23 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-11-23 00:00:00 UTC to 2024-11-24 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-11-24 00:00:00 UTC to 2024-11-25 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 commentsNov 242024-11-25 00:00:00 UTC to 2024-11-26 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-11-26 00:00:00 UTC to 2024-11-27 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-11-27 00:00:00 UTC to 2024-11-28 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-11-28 00:00:00 UTC to 2024-11-29 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-11-29 00:00:00 UTC to 2024-11-30 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-11-30 00:00:00 UTC to 2024-12-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-12-01 00:00:00 UTC to 2024-12-02 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-12-02 00:00:00 UTC to 2024-12-03 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-12-03 00:00:00 UTC to 2024-12-04 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-12-04 00:00:00 UTC to 2024-12-05 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 commentsDec 4

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
Nov 152024-11-15 00:00:00 UTC2024-11-16 00:00:00 UTC312
Nov 162024-11-16 00:00:00 UTC2024-11-17 00:00:00 UTC000
Nov 172024-11-17 00:00:00 UTC2024-11-18 00:00:00 UTC000
Nov 182024-11-18 00:00:00 UTC2024-11-19 00:00:00 UTC000
Nov 192024-11-19 00:00:00 UTC2024-11-20 00:00:00 UTC000
Nov 202024-11-20 00:00:00 UTC2024-11-21 00:00:00 UTC000
Nov 212024-11-21 00:00:00 UTC2024-11-22 00:00:00 UTC000
Nov 222024-11-22 00:00:00 UTC2024-11-23 00:00:00 UTC000
Nov 232024-11-23 00:00:00 UTC2024-11-24 00:00:00 UTC000
Nov 242024-11-24 00:00:00 UTC2024-11-25 00:00:00 UTC000
Nov 252024-11-25 00:00:00 UTC2024-11-26 00:00:00 UTC000
Nov 262024-11-26 00:00:00 UTC2024-11-27 00:00:00 UTC000
Nov 272024-11-27 00:00:00 UTC2024-11-28 00:00:00 UTC000
Nov 282024-11-28 00:00:00 UTC2024-11-29 00:00:00 UTC000
Nov 292024-11-29 00:00:00 UTC2024-11-30 00:00:00 UTC000
Nov 302024-11-30 00:00:00 UTC2024-12-01 00:00:00 UTC000
Dec 12024-12-01 00:00:00 UTC2024-12-02 00:00:00 UTC000
Dec 22024-12-02 00:00:00 UTC2024-12-03 00:00:00 UTC000
Dec 32024-12-03 00:00:00 UTC2024-12-04 00:00:00 UTC000
Dec 42024-12-04 00:00:00 UTC2024-12-05 00:00:00 UTC110

What Hacker News says

4 sources
ghita_·Dec 4, 2024Submission

Show HN: I Used Llama-70B Logprobs for Better, Cheaper and Faster Chunking

The LlamaChunk algorithm is simple: We pick a special token that we know is not in the corpus, e.g. "段". We pick the character "段" because 1. tiktoken always encodes it to exactly one token, 2. it is not in the corpus, and 3. it means "section" in Chinese. Then, we ask Llama to repeat the User's message with the "段" token sprinkled throughout. And just like that, it's perfect out of the box! It correctly used the "段" character to mark the end of every section. BUT if you've ever worked with LLM's, you know that input tokens are processed almost instantly, and output tokens take an eternity to generate. A naïve method is to simply wait for the LLM to repeat the entire python code, inserting "段" throughout. However, by inferencing llama locally, we have a vastly more efficient way of doing this! We can simply pass in the entire paragraph
Read the rest
, and check the logprobs to see the probability that Llama wanted to output a "段" token at that location! Done! The high logprob values, clearly indicate the locations that we should chunk! And, this is only possible because we have direct low-level access to Llama 3.1 70B. Of course, there is a caveat. Because there are no output tokens, Llama can no longer see its own line breaks. Thus, as the text gets longer, it loses the willpower to continue to want to output "段" But, we can simply normalize by this decaying curve in order to to fix this. And now, we're ready to split any type of document, without having to resort to regex or manually created rules. Processing 450,000 characters took about 15 minutes on an A100. However, ~80% of that time was saving and loading the KVCache (Which can be done instantly if written in C++, rather than Python). So, we can expect that it would take 3 minutes per 450,000 characters if done optimally. Or, 7 MTokens per hour. In terms of accuracy, LlamaChunk has higher recall AND precision, than a naïve chunking method and than semantic chunking (Which uses embeddings to detect sentence split boundaries, and still requires a good regex-based sentence splitter). --- One thing you might wonder: What if the ideal chunk split is not along a token boundary? Well for one thing, this is rare, as tokenizers intentionally split along meaningful boundaries. However, if the best split really is after the "f" in "fun", then you calculate ``` lp = logprob(prefix="Fine Tuning is", next_token=" f") if lp > -7: lp *= logprob(prefix="Fine Tuning is f", next_token="段") ``` In other words, if the logprob of token " f" has a non-negligible value > -7, then we can multiply by the logprob of the token after that being "段". The first line of code has a prefix that matches the main inference, so it does not need to be recalculated. However, if the "if" statement passes, then we'll have to do an extra inference, costing us latency. However, this "if" statement almost never passes (In our measurement, it happens once every ~2000 tokens, so it amortizes well). Check out the repo for examples and more technical details.
1 points · Open discussion
Good question! For long documents we have a rolling window strategy. So, we cut the document into 5,000 token groupings for use in inference. There's also a 400 token overlap, and we prefer the earlier chunk for overlap tokens. For example, if Group #0 overlaps with Group #1 at index 5,200, then we use the logprob from Group #0, because it had more context. Group #1 gets the benefit of context for indices 5,000-5,400, even though we toss out the logprobs for that range. Details about the groupings are here: https://github.com/ZeroEntropy-AI/llama-chunk/blob/0cac10a34... -- No need to keep track of chunks that it's already made, we just want heatmap values and then we use those heatmaps to split at the hottest character that's around our target chunk length (Or use a threshold value and binary search the threshold for our target # Chunks o
Read the rest
r average chunk size).
In LlamaChunk: Better RAG Chunking Than LlamaIndex
Yep benchmarks are available at https://github.com/ZeroEntropy-AI/llama-chunk?tab=readme-ov-... , we used this dataset https://github.com/ZeroEntropy-AI/legalbenchrag which is a retrieval-focused version of LegalBench. It scored better than LlamaIndex's recursive character text splitter and that was including some custom regex work to improve it. If you put enough effort into the regex you could probably get there, but the whole point of the agentic chunking is for it to be automatic and contextual.
In LlamaChunk: Better RAG Chunking Than LlamaIndex

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.