Semantic Chunking
Properties
tags
gen_aigen_ai/rag
created
07.02.2025, 16:39
modified
02.08.2026, 10:12
published
Empty
sources
Pinecone Chunking Strategies
topics
Chunking
authors
Jakub
ai-assisted
No
A new experimental technique for approaching chunking was first introduced by Greg Kamradt. In his notebook, Kamradt rightfully points to the fact that a global chunking size may be too trivial of a mechanism to take into account the meaning of segments within the document. If we use this type of mechanism, we can’t know if we’re combining segments that have anything to do with one another.
Here are the steps that make semantic chunking work:
- Break up the document into sentences.
- Create sentence groups: for each sentence, create a group containing some sentences before and after the given sentence. The group is essentially “anchored” by the sentence use to create it. You can decide the specific numbers before or after to include in each group - but all sentences in a group will be associated with one “anchor” sentence.
- Generate embeddings for each sentence group and associate them with their “anchor” sentence.
- Compare distances between each group sequentially: When you look at the sentences in the document sequentially, as long as the topic or theme is the same - the distance between the sentence group embedding for a given sentence and the sentence group preceding it will be low. On the other hand, higher semantic distance indicates that the theme or topic has changed. This can effectively delineate one chunk from the next.
LangChain has created a semantic chunking splitter implemented based on Kamradt’s work. You can also try out our notebook for advanced chunking methods for RAG.