01. The engine behind the page
LlamaIndex builds every guide page in the How It Works family. It does not write from memory. First it reads the real source code. Then it splits the code into small pieces called chunks. Each chunk is turned into an embedding. Embeddings are like fingerprints that capture what the chunk says. Those embeddings are filed in a vector index. That index lets the system find relevant chunks quickly. When a question comes in, it retrieves only the few matching chunks. A large language model answers the question using only those chunks. This approach is called retrieval-augmented generation, or RAG.
Think of it like a librarian. She never answers from memory. She goes to the actual books. She tears each page into small cards. Each card gets a unique code. Then she files those cards in a cabinet. When you ask something, she pulls the few matching cards and reads them aloud. That is exactly what LlamaIndex does with source code.
The whole point is grounding. Grounding means every answer stays faithful to the actual code. A human typing a page by hand might make mistakes. The code changes often. A manually written page would quickly become outdated. A model fine-tuned on old code gives stale answers. Stuffing entire files into the model's context drowns it in irrelevant text. So the retrieval pipeline wins. It always reads the current source at generation time. It also runs a verification pass. That pass checks every identifier in the generated code example. Each identifier must trace back to a real token in the source file. If any identifier is missing, the system retries. It retries up to three times. If violations remain, a warning is printed. The operator sees that and knows the excerpt is not fully grounded.
This verification ensures every code snippet is real. It does not accept partial matches. For example, two files might share similar function names. The retrieval step could return a chunk from the wrong file. The verification pass catches it. It checks each identifier in the code block. At least two-thirds must appear as whole tokens in the target file's identifier set. If not, a violation is recorded. The system retries with feedback about which symbols are ungrounded. After three tries with no success, the excerpt is dropped. No made-up example gets into the page.
The design involves a key trade-off. That trade-off is between faithfulness and ease of generation. Sentence-level splitting is simpler and faster but it fragments functions. A function name, its parameters, and its body may end up in different chunks. That makes it hard for the retrieval step to present a complete unit. The large language model might then hallucinate to fill gaps. So for code files, a code-specific splitter is used. It uses a tree-sitter grammar to split by function or class body. This preserves whole units. Prose files use sentence splitting. Both approaches work together.
In the end, every guide page is generated by LlamaIndex running over its own code. The page about memory principles is built the same way. It is not manually typed. It is generated from the real source. The pipeline retrieves relevant chunks from files like the memory model files. It answers using only that text. Then it verifies the identifiers. This guarantees the page stays correct as the code evolves. No manual updates are needed. The page self-updates whenever the source changes.
That is what LlamaIndex does. It is a retrieval-augmented generation engine. It reads the real source, splits it into chunks, embeds them, indexes them, retrieves relevant ones, and generates answers grounded in those chunks. Every claim on the page is faithful to the current code.