How to Optimize RAG Parameters

Hi, I have a question about RAG. How should I set the Batch Size, Chunk Size, and Chunk Overlap to optimize search results? Are there any recommended references or learning resources for this? I’m from Taiwan—thank you so much for your help!

Hello @tony_li

Batch Size

Default recommendation: 16 documents
For large documents: 8-12 documents
For small documents: 20-32 documents
Impact: Affects processing speed and memory usage

Block Size

Technical documents: 512-768 tokens
General texts: 1024 tokens
Long documents: 1536-2048 tokens
Practical tip: Blocks should contain a complete idea or logical section

Block Overlap

Rule of thumb: 10-20% of the block size
Minimum recommended value: 100 tokens
For complex texts: 25% of the block size
For simple texts: 5-10% of the block size

Quick Tweaks in n8n
Start with average values ​​(batch: 16, block: 1024, overlap: 200)
Test with your typical queries
Tweak one parameter at a time and observe the results
Monitor the execution time in the n8n executions dashboard

If this suggestion solved your problem, please mark my post as a solution (blue box with check mark) so that this ongoing discussion does not distract others who want to find the answer to the original question and click the heart. Thanks :blush:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.