Can anyone tell me, what is chunk_overlap in text spliting using langchain framework?
I am learning langchain features and this is text spliting techniques.I have understand chunk size but chunk_overlap is not understand to me.
Can anyone tell me, what is chunk_overlap in text spliting using langchain framework?
I am learning langchain features and this is text spliting techniques.I have understand chunk size but chunk_overlap is not understand to me.
As @ZKS said, it is crucial for maintaining context, let me provide you an example for it, suppose you are working on multiple documents say 1000. And among that 1000, say you have 200 docs that are on similar topic, like regarding space(but each of them are different, but regarding space).
so when you will convert it to vector embeddings and perform similarity search for some space related query, you will get chunks of this all documents.
Now consider this scenario, when you have chunk overlap equal 0.
-> Then, when you feed that to your model for preparing answer or summarizing it etc, then model will mix the chunks and will not create the proper answer.
Now you have some chunk overlapping(like 10% or 20% of chunk size)
-> Then this chunks of one document will have some common text between them and will be related to each other(hence maintaining the context of that doc) and will be more efficient in generating answer.
chunk_size and chunk_overlap are two important parameter when we are dealing with text_splitter.
Chunk_size defines the length of each chunk, while chunk_overlap defines the amount of consecutive chunks' overlap. This ensures context continuity between chunks, crucial for certain applications where "context" is having more importance.
Example may help to understand chuck overlap better
Text: "The cat sat on the mat."
Chunk size: 5
Chunk overlap: 2
Chunks: