The LlamaIndex Mental Model: Documents, Indexes, and Query Engines
LlamaIndex is a context-augmentation framework: it turns your files, APIs, and databases into structures an LLM can retrieve and reason over.
Search across all documentation pages
LlamaIndex is a context-augmentation framework: it turns your files, APIs, and databases into structures an LLM can retrieve and reason over.
Agents built on LlamaIndex treat retrieval as a first-class tool, not as a one-off prompt hack.
Large language models ship with public knowledge only.
Your useful data usually lives in PDFs, wikis, SQL tables, tickets, or object storage.
Context augmentation injects the right slices of that data into the prompt at query time.
Retrieval-Augmented Generation (RAG) is the most common form: embed chunks, retrieve nearest neighbors, then generate an answer from those chunks.
LlamaIndex organizes that path into a small set of objects you can compose:
| Object | Role |
|---|---|
| Document | Source unit with text plus metadata (path, author, source id). |
| Node | Chunk (or structured piece) derived from a Document; inherits metadata. |
| Index | Structure optimized for lookup (vector, summary/list, keyword, and others). |
| Retriever | Given a query, returns relevant Nodes. |
| Query Engine | Retrieve + synthesize a single-shot answer. |
| Chat Engine | Multi-turn conversational interface over the same data. |
| Agent / Workflow | LLM decides when to call tools (including query engines) across steps. |
The high-level API hides most of this for a five-line demo.
The low-level API lets you replace any stage: readers, splitters, vector stores, retrievers, postprocessors, and synthesizers.
Python is the flagship surface.
LlamaIndex.TS brings the same document-index-engine story to Node, Deno, Bun, and related JS runtimes.
Managed pieces (LlamaParse, LlamaCloud indexing) sit on top when you need production parsing without owning every pipeline step.
A typical read-path looks like this:
Document objects (SimpleDirectoryReader, LlamaHub readers, custom loaders).Nodes (SentenceSplitter, token splitters, semantic splitters, hierarchical parsers).VectorStoreIndex, which embeds text and stores vectors).index.as_query_engine(), which builds a retriever + response synthesizer.QueryEngineTool and hand it to a FunctionAgent (or similar).from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
documents = SimpleDirectoryReader("data").load_data()
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()
response = query_engine.query("What does the policy say about refunds?")Each layer has a clear contract.
Documents are what you own.
Nodes are what you embed and retrieve.
Indexes are how you look Nodes up.
Engines are how users or agents ask questions.
Indexes are not all the same.
A vector index answers “find the paragraphs closest to this question.”
A summary or list-style index supports “synthesize across the whole collection.”
Keyword and hybrid approaches catch exact terms embeddings miss.
Router query engines sit above multiple engines and pick (or fan out) based on the query and tool descriptions.
Agents change the control flow.
A plain query engine always retrieves-then-answers once.
An agent can decide whether to query docs, call another tool, ask for clarification, or stop.
That is why LlamaIndex treats RAG pipelines as tools among tools, not as the entire product.
Ingestion is usually a pipeline, not a one-liner, once you leave the tutorial:
Global Settings (LLM, embed model, chunker) configure defaults for many high-level constructors.
Prefer explicit models in production so agent code does not silently depend on ambient globals.
For multi-agent systems, keep LlamaIndex focused on data plane work: ingest, index, retrieve, evaluate.
Use agents/workflows for control plane work: planning, tool choice, handoffs, and stopping conditions.
Patterns that fit the mental model well:
Trade-offs versus neighboring stacks:
| Approach | Strength | Weakness | Best fit |
|---|---|---|---|
| LlamaIndex-first RAG | Document/index abstractions, many connectors, eval helpers | Heavier than raw embeddings SDK | Knowledge-heavy agents |
| LangChain / LangGraph | Rich graph orchestration | You assemble more of the RAG stack yourself | Complex multi-step control flow |
| Direct vector DB + LLM SDK | Minimal dependencies | You own chunking, synthesis, and eval glue | Tiny single-index apps |
| LlamaCloud / LlamaParse managed path | Production parsing and pipelines | Cost and vendor coupling | Enterprise document quality |
Version-sensitive surfaces (package names under llama-index-*, agent class names such as FunctionAgent vs older OpenAI agents) move quickly.
Treat import paths in examples as verify at build.
A Document is a source object (often one file or record). A Node is a chunk or structured piece derived from that Document, carrying inherited metadata for retrieval.
No. Vector indexes dominate Q&A, but summary/list indexes, keyword indexes, SQL engines, and routers cover other query shapes.
Typically twice in spirit: embeddings (or other retrievers) select context, then a generative LLM synthesizes the final answer from the retrieved nodes (exact calls depend on configuration).
A retriever returns Nodes. A query engine retrieves and then synthesizes a natural-language response.
Chat engines maintain multi-turn conversation state over your data. Query engines are request/response Q&A interfaces.
Yes. Wrap each query engine as a QueryEngineTool with a clear description, or use a router that selects among engines.
Python is primary. LlamaIndex.TS covers TypeScript/JavaScript runtimes with the same context-engineering goals.
On Documents at load time (and ensure it propagates to Nodes). Filters and citations depend on clean source, tenant, and section metadata.
A transform chain that runs readers' output through splitters, extractors, and embeddings before indexing, suitable for batch and incremental jobs.
MCP and A2A are protocols for tools and agent-to-agent communication. LlamaIndex builds the retrieval and agent logic those protocols may expose.
When PDFs and complex layouts (tables, figures, nested structure) defeat plain text extractors and retrieval quality suffers.
Yes. Indexes commonly sit on top of Chroma, Pinecone, pgvector, Azure AI Search, and many others via integration packages (verify package names at build).
Not necessarily. You can use LlamaIndex for RAG tools inside LangGraph, CrewAI, custom loops, or LlamaIndex's own agents and workflows.
Retrieval hit-rate or recall on a labeled question set, then faithfulness of answers to retrieved context. Generation quality without retrieval quality is noise.
Stack versions: Pins from the category manifest (verify at build): OpenRouter (~315+ models, July 2026 pricing/fees); LangGraph 1.0+; CrewAI 1.14+; Microsoft Agent Framework 1.0; Vercel AI SDK 6; Pydantic AI (latest); LlamaIndex (latest); OpenAI Agents SDK (latest + MCP); MCP (Linux Foundation governance); A2A (HTTP+SSE+JSON-RPC 2.0); Solana
@solana/web3.js+@solana/spl-token.
Reviewed by Chris St. John·Last updated Jul 16, 2026