OMAR
Field NotesCV
LlamaIndex: RAG Beyond the Toy Example
← All Notes
AI Engineering19 May 2026 · 5 min read

LlamaIndex: RAG Beyond the Toy Example

Chunking strategy decides whether your retrieval works. Everything else is a distant second.

Every retrieval-augmented generation tutorial ends at the same place: load documents, split them, embed them, search. It works on the tutorial's PDF and falls apart on your client's document set.

The reason is almost always chunking. Everything else — which vector database, which embedding model, which framework — matters far less than people assume.

Why chunking decides everything

Retrieval finds chunks, not documents. If your chunks are wrong, the model gets fragments that do not contain the answer, and then it either says nothing useful or invents something. No amount of prompt engineering repairs a bad chunk.

Splitting every 1000 characters — the default in most examples — cuts tables in half, separates a heading from the paragraph it introduces, and splits a numbered procedure across two chunks so step 4 arrives without steps 1 through 3.

What actually helps

Split on structure, not length. Headings, sections, list boundaries. Documents have shape; use it.

Overlap deliberately. A couple of hundred characters of overlap keeps context from falling into the gap between two chunks.

Attach metadata to every chunk. Source document, section title, page, date. Metadata gives you filtered retrieval — "only from the 2026 policy" — which fixes a whole category of wrong answers that no amount of semantic similarity will.

Keep tables whole. A split table is worse than no table, because it looks like data and is not.

Include the heading in the chunk text. A chunk that begins mid-thought retrieves poorly. Prefixing its section title improves matching immediately.

Then measure it

The step everyone skips. Write twenty real questions with the answer you expect, and check whether the correct chunk is retrieved at all. If retrieval fails, the generation was never going to succeed and you are tuning the wrong stage.

Separating those two failure modes — did we retrieve the right thing, and did we generate well from it — is the single most useful debugging habit in this work.

Arabic considerations

Test your embedding model on Arabic specifically. Multilingual embedding quality varies a lot, and a model that performs well in English can retrieve poorly in Arabic. Mixed-language document sets need particular attention, since a query in one language must find content in the other.

Resources

AIOpen Sourcellama_index

Need this built properly?

I build secure, fast, bilingual platforms for clients across Egypt, Saudi Arabia, the UAE and Kuwait.

Keep Reading