A lucid breakdown of the trade-offs between semantic depth and computational efficiency in RAG architectures. It transforms the mundane task of data preprocessing into a strategic pillar for high-performance AI retrieval.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
RAG Chunking Strategies Explained (With Visual Examples)
Added:In our last video, we have learned how to build a rag architecture in detail step by step.
So, in this video, we will talk about the major important step inside rag building which is called as chunking.
Many companies are trying to build this rag architecture but when they build this architecture, at the end, their performance will not be good.
And one of the main reason of performance not getting good in rag architecture or rag solutions is because of the chunking strategies.
We have many types of chunking strategies.
There may be 15 or 20 of them but not everything is important for us.
And one more thing that I want to talk about is chunking.
It should be purely based on your data.
Depending on your data, you need to decide how to do chunking.
But in this video, I will give you a high level overview on the top chunking strategies and how you can use them.
And before that, let me quickly revise what is a rag architecture.
So, we have PDFs, data, documents, text and lot of stuff.
And after that, we load all of these documents into a place, anywhere in our code.
And once we load all of these documents, because we cannot afford larger context windows in LLM models, what we do is we try to chunk the data into multiple parts.
Such that every chunk can become an embedding vector.
So, once we get all the chunks for our data, we will try to create an embedding model.
What is this embedding model?
It is going to convert chunks into vectors using any kind of models.
We have OpenAI embedding models, sentence transformers, free hugging phase.
There are so many embedding models.
Once we use any embedding model, we can create these vector embeddings.
And to store these vector embeddings, we will use a vector store or vector database.
This is where we store what is the chunk information that we have in the third step.
And along with the vector embedding that we generate using the vector embedding models.
And we will talk about embedding models in detail in the upcoming video.
So, let us not worry about that right now.
Once we complete this process, you finally have a vector store in which we have chunks.
Along with that, we have vector embeddings for those chunks.
And whenever you want to retrieve the answer for a question, let us say a user asks us a question.
And using the same embedding model, you will try to convert that question into vector embeddings.
And once that vector embedding comes, you will try to go to the vector data store.
And after seeing all the embeddings that we have stored, we will try to find the top similar chunks.
Telling what are the similar chunks for our question.
And taking those chunks, you will build the context.
And taking this context, you will pass it to an LLM model with a prompt.
Here you can use any LLM model.
ChatGPT, Claude, Grok or anything.
And once you are done with this, this LLM will generate you the answer.
Which is grounded and which is actual data from the documents.
It is not even hallucinating anywhere.
But if we want this answer to be good, we need to have these chunks better quality.
And how to do those chunks, we are going to talk about in this video.
There are so many chunking strategies, but we will not be able to cover every single thing.
Let us say there are these top chunking strategies.
One is fixed size chunking.
And second is fixed size chunking with overlap.
And third is sentence based chunking.
And fourth is paragraph based chunking.
And then there is recursive chunking and semantic chunking.
Usually 90 % of the cases, you are good with recursive chunking or the semantic chunking.
Because they will try to capture as much meaningful information as possible when you are chunking.
Let us go into each and every one of these processes and understand it more deeply.
So first let us talk about fixed size chunking.
So let us say this is all my data, which is a single page in multiple documents.
I may have hundreds of documents.
And let us understand the chunking strategies using this single page.
What I will do is I will try to fix the chunk size.
Maybe let us say I want to have a chunk size of 500 tokens.
The meaning of this is whenever I try to split these sentences or split this text into multiple chunks.
What I will do is I will try to chunk at a limit of 500 tokens.
That means by mixing all the text in this, they should be less than or equal to 500 chunks.
I don't want to go over that.
And from where 500 chunks will end, I will create one more chunk.
And even this chunk should also be around 500 tokens.
And from where this will end, next we will create one more chunk.
So like this, in every page, in every page, first 500 is one chunk.
Next 500 tokens is another chunk.
Next 500 tokens is another chunk.
So like this, I will create multiple chunks.
And I will do this process for all the documents.
And this is what we call it as a fixed size chunking.
The problem with this is that it is not able to capture the data more correctly.
Because let us assume a scenario where all this is one paragraph.
All these paragraphs will give a single meaning to our text.
But depending on the limit of 500 tokens, you are going to break in between.
Meaning, when you are creating vector embeddings, you are creating a vector 1 for this one.
And you are creating a vector embedding for this one.
So here, a single paragraph which is bringing some importance meaning, you split it.
When you split it, the vector embeddings are going to also get split into multiple things.
And when you are trying to retrieve, maybe you are only retrieving the vector 1, not the vector 2.
So in such cases, the retrieval quality is not good.
But there are some pros as well.
Because it is a very easy one, you can do it as simple as possible.
It is very simple.
And it is easy to implement as well.
Because of this fixed size chunking, you might lose context if the data is complex.
So this is the problem with fixed size chunking.
And next, let us talk about the other one, fixed size chunking with overlap.
And why is it needed?
Earlier we thought, I will break it like this under multiple chunks in fixed size.
But when you are breaking it like this, you are abruptly cutting the paragraph here.
Cutting the text here.
So by cutting it like this, you are not going to gain more information.
Sometimes, you might want the information from the previous chunk to be overlapped in the current chunk.
Because you can have better semantic or retrieval quality.
So for that, we have this technique which is called as fixed size chunking with overlap.
What does this do?
Whenever you are creating two different chunks, let us say chunk 1 and chunk 2.
And whenever you are creating these kinds of chunks, I will have some chunk overlap.
This part is in chunk 1 and chunk 2 as well.
See, this is chunk 1 and this is chunk 2.
There is an overlap.
When you are creating vector embeddings for chunk 1, V1 and V2, they both can have some common vectors in between.
Such that whenever you are retrieving, you might retrieve either from the chunk 1 or chunk 2.
That can have overlap of some other techniques as well.
So this is also a better option compared to the first one.
Because you are trying to improve the context.
Improve the context and it will improve the retrieval quality.
But the cons is that because you are doing an overlap, you might need to create more chunks.
And if you have more chunks, you are going to create more embeddings.
And those embeddings need to be stored in a database.
So you need a lot of vector embeddings to be created when you are doing this kind of chunking strategy.
And because of this, you might need to pay for the storage and indexing as well.
And the next one, let us talk about sentence based chunking.
This is also fine. It is not too good.
What this will do is, let us say we have a chunk limit.
And in chunk limit, let us do it at 500 limit.
Every chunk should have 500 tokens.
So what it will do is, first it will break the chunk into 500 tokens approximately.
And after that, internally the text that is present inside the chunk 1, it will break it at sentence level.
Chunk 1 and this is second one, third one and fourth one.
So this is a single chunk.
And in that single chunk, you have multiple sentences.
And all of these sentences, you will create vector embeddings.
So what this will do is, it will preserve the complex sentence relations and it will provide the readability as well.
And sometimes, because you are chunking sentence based, there is a lower chance of you cutting the data in between.
The next one is basically the paragraph based chunking.
This is a good one.
So whenever you can use this, when you are working on novel or books, because when you are looking at story books or novels, a paragraph contains a more semantic meaning.
Isn't it?
So cutting the paragraph in between doesn't make any sense.
So in that scenario, you take one paragraph and you create that as one chunk.
Paragraph is small and big.
You take one paragraph and you will keep it as a chunk.
Like that paragraph 2 as another chunk.
Paragraph 3 is another chunk.
Paragraph 4 is another chunk.
So you are creating chunks based on paragraphs, not on the chunk size and limits.
So what happens is, it will maintain logical structure and context more clearly.
Cons is, sometimes the paragraph can have multiple pages.
In case, in such situations, the vector embeddings might not capture the entire details of the paragraph.
If paragraph is large, then vector embeddings might not capture full details.
What can you do in such situations?
You can mix this with the sentence based chunking.
So first split the paragraph.
Then try to split the data into paragraphs and you create one more chunk.
So there is no dedicated answer to how to do chunking.
No.
You have to understand the data and decide how to do chunking.
Then you can think about all of these different techniques.
I know chunking techniques.
So I will go ahead and use these chunking techniques for my use case.
What is your data?
Think about how much chunking you need for that data and design your own chunking strategy.
If all these work, but if it is not working, then I think designing your own chunking strategy is much better actually.
And now let's talk about the other one which is called as recursive chunking.
This is a popular chunking technique.
Because it will look at the heading, there is a subheading and there is a text inside this subheading.
So let me create a chunk for this one.
And there are multiple parts inside another subheading.
Let me create one more chunk for this one.
There are multiple parts inside another subheading.
So let me create one more chunk for this.
What it will do is it will look like a tree.
It will look at the hierarchy.
This is my subheading, heading.
What data is there inside the heading?
What data is there inside the subheading?
I will try to create chunks based on the data that I have.
And usually recursive chunking works really good.
And it will preserve document structure and context as well.
And because when we do such things, when you convert vector embeddings, they capture more semantic meaning.
More semantic meaning.
And usually, Elantic chunking strategy works with any kind of documents.
And let's talk about the most popular one which is called as semantic chunking.
Which is also called as meaning -aware chunking.
Why are we doing chunking?
Because we are going to convert them into vector embeddings.
And vector embeddings should carry the semantic meaning.
In such cases, if we even do the chunking that can do semantically, so why not use that technique?
Yes, 95 % of the cases you are good to go with semantic chunking.
But as I said, based on your data, you need to decide what kind of chunking you want.
What this semantic chunking will do is it will look at data.
This paragraph has a meaning.
Or this sentence has a meaning.
Or maybe this sentence has a meaning.
So it will find that data and it will try to create a chunk.
And second one, maybe all of this is for solar energy.
It will create one more chunk for solar energy.
And the third one is for wind energy.
It will create for wind energy chunk.
So looking at the semantic meaning of the data, it is going to create the chunks.
And that chunks will carry more semantic differences.
The advantage of this is that you are able to capture or retrieve the information more reliably.
It is going to do time taking chunking.
Because you need to understand the data first and then split it.
If I have like million documents, then it is going to take multiple hours if not days for you to complete this type of chunking.
Because it is computationally expensive.
And the boundaries, chunks, everything is random.
Not random actually based on the semantic meaning.
But there is no fixed stuff.
So you can do this one.
But it is going to be computationally expensive.
And you need to wait a lot of time for it to complete.
So these are all the top chunking strategies that I want to talk about.
You can ask Mr. Balaji now that we know these chunking strategies, how to implement these things.
Yes, that is an interesting question.
So for that, we have a framework which is called as LangChain.
What this LangChain does is, it will be able to provide us all the existing packages.
Where you can just call the chunking strategy and it will take care of it.
If you want, you can build it from scratch.
And that is what exactly we are going to do on this Sunday live on YouTube.
We are doing 2 hour master class on building a rag from scratch.
We will not be using LangChain guys.
We will build it from scratch.
And then maybe later on, we will try to use LangChain to solve the same problem as well.
What happens when you build it from scratch is, you will understand the details more properly.
Step by step, what to do, how to do it.
And once you understand this, using LangChain is just a piece of cake.
So if you want to learn how to build the entire rag from start to end.
So this is the one.
From start to end, if you want to understand how it is being built.
Make sure that you are joining or attending the Sunday live.
I have scheduled it on my channel actually.
You can click on this and you can wait for this one.
And once the live starts, YouTube will give you notification.
We are doing custom live coding.
We will not do the code and we will explain the code now.
We are doing the live coding actually.
So yeah, that is all about the chunking strategy, Sanamata.
And next, we will talk about embedding strategies.
We will talk about every single part in detail.
So let's not worry about that.
And if you like the content, please subscribe.
And if you know someone who wants to listen to this kind of content, please share the channel with them.
And that's all for this one.
Bye bye.
Related Videos

Expanding Stikbot thumbnails
leopoldshorts
2K views•2023-09-24

Digital Discrimination: Cognitive Bias in Machine Learning
redmonktechevents2974
4K views•2019-12-18

Evolutionary Approach to Clustering by Ujjwal Maulik
ICTStalks
279 views•2019-06-26

Rose Yu "Learning from Large-Scale Spatiotemporal Data"
networkscienceinstitute
2K views•2019-03-04

Stanford Seminar - Generalization through Task Representations with Foundation Models
stanfordonline
4K views•2025-07-14

Satellite-Based Wheat Yield Forecasting using GEE & Transformer Neural Network
gisrsinstitute
634 views•2025-06-15

Paradigm Shifts in Data Processing for the Generative AI Era: Robert Nishihara of Anyscale & Ray.io
GradientFlow
2K views•2025-01-02

How to Build Your Own GenAI-Based Knowledge Management System
2150GmbH
360 views•2025-06-03
Trending

Playstation NO DISC/NO BUY Fight Is Over...
DavidJaffeGames
4K views•2026-07-23

Steam and Xbox Just Dropped The Hammer On PlayStation
OhNoItsAlexx
9K views•2026-07-23

Americans Confused in Australia for 17 Minutes Straight
IWrocker
17K views•2026-07-23

SuperBike Factory Has Gone... What's Next for the Motorcycle Industry?
thatbikersimon
11K views•2026-07-22