AskReference
EffectIntermediate

What is the effect of chunk size on RAG performance, and why does it matter?

Chunk size is a key tuning factor in RAG because it directly affects whether retrieved chunks contain enough relevant information. Too-small chunks can miss necessary details, while too-large chunks create oversized context that degrades LLM performance and produce embeddings that no longer represent the chunk's content effectively. For this reason, chunk size must be balanced, often by experimenting with the Split Text component's chunk size and overlap parameters.

In RAG, chunk size matters because each chunk is stored in the vector database as a fixed-size embedding. If a chunk is too small, it may not include all the information needed to answer a question correctly, so the retriever could fail to supply the LLM with sufficient context. If a chunk is too big, the context becomes too large, which degrades LLM performance, and the fixed-size embedding cannot effectively represent all of the content in the oversized chunk, harming retrieval quality. The recommended approach is to strike a balance by adjusting the chunk size and overlap parameters in the Split Text component and testing whether responses improve.

Key points

  • Chunks that are too small may omit information needed for correct answers.
  • Chunks that are too big make the context too large and degrade LLM performance.
  • Large chunks are stored as fixed-size embeddings that cannot effectively represent all their content.
  • The Split Text component lets you change chunk size and overlap to find a better balance.
Source:AI Agents and Applications· Writing the right prompt· p. 111–115

Related questions

Cover of AI Agents and Applications

AI Agents and Applications

Andrea De Mauro

MEAP Edition Version 7 · Manning Publications

View this ebook