Ingest external data, transform it into embeddings and indexes, and query it at runtime so LLMs can generate accurate, grounded responses. Master each stage of the retrieval-augmented generation pipeline—from data connectors and chunking through vector stores, retrievers, and response synthesis.
Large language models (LLMs) like GPT-4 or LLaMA are trained on a fixed snapshot of data. Once training is complete, the model has no awareness of anything outside that snapshot — not your company's internal documents, not a live database, not a PDF uploaded this morning. If you ask such a model about your private data, it simply cannot answer accurately; it will either refuse or hallucinate.
LlamaIndex is an open-source Python framework built to close this gap. It gives you a structured, composable pipeline for ingesting external data, indexing it in a way an LLM can reason over, and querying it at runtime so the model can generate grounded, accurate responses. Think of LlamaIndex as the connective tissue between your data and the LLM brain.
The fundamental workflow in LlamaIndex follows three stages:
The three-stage LlamaIndex pipeline: raw data is loaded, transformed into an index, then queried at runtime to ground LLM responses.
LlamaIndex ships with a large library of data connectors (also called readers) that can pull content from PDFs, Word documents, Notion pages, Slack channels, SQL databases, REST APIs, and many more sources. Each reader converts a raw source into a Document object — a standardised container that holds the text content alongside metadata such as the source URL or file name.
A raw document is usually too large to feed directly into an LLM's context window. LlamaIndex breaks documents into smaller units called Nodes. A node typically represents a chunk of text (e.g., a few paragraphs) plus a reference back to the parent document. The chunking strategy — chunk size, overlap, and splitting logic — can be configured or customised.
Once data is chunked into nodes, LlamaIndex converts each node into a vector embedding — a numerical representation that captures semantic meaning. The embedding model can be an OpenAI model, a Hugging Face model, or any other compatible encoder. These vectors are what make semantic search possible: similar concepts end up close together in the embedding space.
Mathematically, given a text chunk , an embedding model produces a vector . Retrieval then finds the nodes whose vectors have the highest cosine similarity to the query vector:
An index is the data structure that organises nodes for fast, relevant retrieval. The most common type is the VectorStoreIndex, which stores embeddings in a vector store (in-memory by default, or backed by external stores like Pinecone or Chroma) and retrieves top- nearest neighbours at query time. Other index types include list indexes, tree indexes, and keyword table indexes, each suited to different retrieval patterns.
A retriever is the component responsible for fetching the most relevant nodes from an index given a query. The default retriever uses the vector similarity search described above, but LlamaIndex supports more advanced strategies such as hybrid search (combining dense and sparse retrieval) and recursive retrieval across multiple indexes.
Once relevant nodes are retrieved, a response synthesiser assembles a prompt that includes the retrieved context and the original question, then calls the LLM to generate an answer. A query engine is a higher-level object that combines a retriever and a response synthesiser into a single interface — you call query_engine.query("your question") and get back a grounded answer in one step.
For more dynamic tasks, LlamaIndex supports agents — LLM-powered reasoning loops that can decide which tools to call and in what order. A query engine can be wrapped as a tool and handed to an agent. This enables multi-step reasoning, such as querying multiple data sources, performing calculations, and synthesising a final answer.
Full LlamaIndex architecture: the top row is the ingestion pipeline; the bottom row is the query pipeline. Both share the index as their meeting point.
This pattern — retrieve relevant context, then generate — is known as Retrieval-Augmented Generation (RAG). RAG is important because:
LlamaIndex is one of the most fully featured frameworks for building RAG systems in Python, offering fine-grained control over every stage of the pipeline.
This course walks through each component in depth:
Each topic builds on the previous one. By the end, you will be able to design and deploy a fully functional RAG application over your own data using LlamaIndex.