ChunkViz v0.1

Want to learn more about AI Engineering Patterns? Join me on Twitter or Newsletter.


Language Models do better when they're focused.

One strategy is to pass a relevant subset (chunk) of your full data. There are many ways to chunk text.

This is an tool to understand different chunking/splitting strategies.

Explain like I'm 5...

Total Characters: 2658
Number of chunks: 107
Average chunk size: 24.8
One of the most important things I didn't understand about the world when I was a child is the degree to which the returns for performance are superlinear. Teachers and coaches implicitly told us the returns were linear. "You get out," I heard a thousand times, "what you put in." They meant well, but this is rarely true. If your product is only half as good as your competitor's, you don't get half as many customers. You get no customers, and you go out of business. It's obviously true that the returns for performance are superlinear in business. Some think this is a flaw of capitalism, and that if we changed the rules it would stop being true. But superlinear returns for performance are a feature of the world, not an artifact of rules we've invented. We see the same pattern in fame, power, military victories, knowledge, and even benefit to humanity. In all of these, the rich get richer. [1] You can't understand the world without understanding the concept of superlinear returns. And if you're ambitious you definitely should, because this will be the wave you surf on. It may seem as if there are a lot of different situations with superlinear returns, but as far as I can tell they reduce to two fundamental causes: exponential growth and thresholds. The most obvious case of superlinear returns is when you're working on something that grows exponentially. For example, growing bacterial cultures. When they grow at all, they grow exponentially. But they're tricky to grow. Which means the difference in outcome between someone who's adept at it and someone who's not is very great. Startups can also grow exponentially, and we see the same pattern there. Some manage to achieve high growth rates. Most don't. And as a result you get qualitatively different outcomes: the companies with high growth rates tend to become immensely valuable, while the ones with lower growth rates may not even survive. Y Combinator encourages founders to focus on growth rate rather than absolute numbers. It prevents them from being discouraged early on, when the absolute numbers are still low. It also helps them decide what to focus on: you can use growth rate as a compass to tell you how to evolve the company. But the main advantage is that by focusing on growth rate you tend to get something that grows exponentially. YC doesn't explicitly tell founders that with growth rate "you get out what you put in," but it's not far from the truth. And if growth rate were proportional to performance, then the reward for performance p over time t would be proportional to pt. Even after decades of thinking about this, I find that sentence startling.

What's going on here?

Language Models have context windows. This is the length of text that they can process in a single pass.
Although context lengths are getting larger, it has been shown that language models increase performance on tasks when they are given less (but more relevant) information.

But which relevant subset of data do you pick? This is easy when a human is doing it by hand, but turns out it is difficult to instruct a computer to do this.

One common way to do this is by chunking, or subsetting, your large data into smaller pieces. In order to do this you need to pick a chunk strategy.

Pick different chunking strategies above to see how they impact the text, add your own text if you'd like.

You'll see different colors that represent different chunks. This could be chunk 1. This could be chunk 2, sometimes a chunk will change in the middle of a sentence (this isn't great). If any chunks have overlapping text, those will appear in orange.

Chunk Size: The length (in characters) of your end chunks

Chunk Overlap (Green): The amount of overlap or cross over sequential chunks share

Notes: *Text splitters trim the whitespace on the end of the js, python, and markdown splitters which is why the text jumps around, *Overlap is locked at <50% of chunk size *Simple analytics (privacy friendly) used to understand my hosting bill.

For implementations of text splitters, view LangChain (py, js) & Llama Index (py, js)

MIT License, Opened Sourced, PRs Welcome

Made with ❤️ by Greg Kamradt