Who thinks document "chunking" sucks and why?
All the "memory" systems/pipelines for LLMs seems to be using the exact same approach:
1. Chunk Docs + Embed 2. Store in a VectorDB 3. Query embeddings based on semantic relevance
In my work, this has consistently failed to get meaningful context for prompts. Who has seen a better way of handling this problem?
4 comments
[ 2.7 ms ] story [ 22.6 ms ] threadThat being said, people are finding the basic steps you showed above sufficient. There are parameters you can change in these 3 steps. Have you tried changing any of those?
- how you chunk, chunk size and rules - how you embed, which model and size - how you query, the metric(s) used
2 is probably only important to quality of results in that it determines what is available for you to use in the other steps, notably the embedding comparison metric that really defines relevance
Most documents have implicit structural semantics not explicitly worded in the text. You need to surface and embed those into the chunks, and also furter enrich chunk candidades by flatten in references and other relations.
There is no general solution to this. While you can apply chunking and enrichment patterns, each document type is a bespoke effort to get it right.
https://github.com/Ighina/DeepTiling
https://medium.com/@ganymedenil/how-to-segment-large-texts-f...
1. How does that webpage code work?
2. Summarize this website.
As you can see, you might benefit from pre-processing info different based on the intended result. One cares strongly about the tags, styling etc. while one only cares about the text and you could maybe just scrub the tags.
Also, consider chunks overlap and max chunk size and tune them based on different trials.
Check your chunk scores (cos similarity) against sample queries and make sure chunks texts are meaningful. "Is this how I would store info in my head?" might be a good way to start, if your chunks are garbage you will get garbage.
Consider visualizing your chunks in clusters to validate topic relevance.
Last thing a RAG is a multi-step arch., only one step being bad will turn the whole thing to garbage, put lots of debugging, eval steps in yours. Make sure its not the prompt step thats ruining it. Identify the weak points and triage accordingly.