Skip to content
19 / Answers

LlamaIndex for data, LangChain for glue.

LlamaIndex is a framework whose centre is your data: loading it, indexing it, querying it with a language model. LangChain is a general framework for composing models, prompts, tools and agents. For a retrieval-first application LlamaIndex gets you further faster; for an agent that uses many tools LangChain and LangGraph are more natural. Both hide details you will eventually need to see.

LlamaIndex
Indexes, query engines, data connectors
LangChain
Chains, tools, agents, broad integrations
Both
Open source, Python and TypeScript
Neither
Replaces a test set and plain-code understanding
  • 5production AI apps
  • 14engineers led
  • 200+students mentored
01

Questions students ask

The LlamaIndex questions searched most, answered from building retrieval with and without frameworks.

What is LlamaIndex?

LlamaIndex is an open-source framework for connecting language models to your own data. It started as a library for building indexes over documents and querying them, and that remains its core: loaders for hundreds of sources, node parsers that chunk documents, index types (vector, keyword, summary, knowledge graph), retrievers, query engines that combine retrieval with a model, and evaluation tools. It has since added agents and workflows, but its design centre is still the question 'how do I get accurate answers from this data', which is why it is the framework most associated with RAG.

What is LlamaIndex used for?

  • Document question answering over PDFs, web pages, Notion, Slack, databases and APIs through its data connectors.
  • Building and comparing retrieval strategies: chunk sizes, hybrid retrieval, re-ranking, auto-merging and sentence-window retrieval.
  • Structured extraction: pulling typed fields from documents with a schema.
  • Query over several indexes with routing, sub-questions and summarisation.
  • Agents and multi-step workflows that use those indexes as tools.
  • Evaluating retrieval and answer quality with its built-in evaluators and datasets.

How does LlamaIndex work?

Data flows through four stages. Loading: readers turn files and services into Document objects with text and metadata. Parsing: node parsers split documents into nodes (chunks) and keep relationships such as previous, next and parent. Indexing: an index stores nodes in a form a retriever can search, most commonly embeddings in a vector store, optionally alongside keyword or graph structures. Querying: a query engine takes a question, runs a retriever, optionally post-processes the nodes (re-ranking, filtering), and synthesises an answer with a model using a response mode such as compact or tree summarise. Each stage is swappable and inspectable.

What is LlamaIndex in RAG?

In a RAG system LlamaIndex covers everything from the raw files to the answer: ingestion, chunking, embedding, storage, retrieval, re-ranking and synthesis, with sensible defaults at every step and a way to override each. Its advanced retrievers are the useful part: sentence-window retrieval (retrieve a sentence, return its surrounding window), auto-merging (retrieve small chunks, merge into their parent when enough siblings match), and hybrid retrieval with fusion. Those are the techniques I describe on this site, packaged. What it does not do for you is build the question set that tells you whether any of them helped.

What is LlamaIndex document?

A Document is LlamaIndex's container for a source item: its text, a metadata dictionary (file name, page, URL, date, anything you add) and an ID. Readers produce Documents; node parsers split them into Nodes, which carry the same metadata plus relationships to neighbouring and parent nodes. Metadata matters more than it looks: it is what filters use at query time, what citations are built from, and what you can prepend to the text before embedding so the vector knows where the chunk sits. Set it deliberately at load time rather than hoping the reader guessed well.

What is LlamaIndex workflow?

Workflows are LlamaIndex's event-driven way of building multi-step applications. You define steps as functions that accept an event type and emit others; the runtime routes events between steps, supports branching, loops and concurrency, and can be observed step by step. A RAG workflow might have steps for query rewriting, retrieval, re-ranking, evaluation and generation, with a loop back to retrieval when the evaluation step is unhappy. It plays the role LangGraph plays in the LangChain ecosystem: explicit control flow for agents and pipelines that are more than a straight line.

Difference between LangChain and LlamaIndex

Scope and centre of gravity. LangChain is broad: a standard interface over models, prompts, tools, memory and agents, with retrieval as one capability among many. LlamaIndex is deep on data: ingestion, indexing, retrieval and evaluation are the main product, with agents added around them. LangChain's abstractions are more general and more numerous; LlamaIndex's defaults for RAG are better tuned out of the box. They interoperate: LlamaIndex retrievers can be used as LangChain tools, and LangChain models can be used inside LlamaIndex. In practice teams pick one as the backbone and borrow from the other.

When to use LangChain vs LlamaIndex

  • Retrieval-first product, many document sources, you want advanced retrievers and evaluators ready-made: LlamaIndex.
  • Tool-using agent, many integrations, complex control flow with checkpoints: LangChain with LangGraph.
  • Your team already standardised on one: use that one; the switching cost outweighs the differences.
  • You are learning: build one RAG pipeline in plain Python first, then try either framework and notice what it did for you.
  • Production with strict latency and debugging needs: expect to rebuild the hot path in plain code whichever you chose.

Which is better LangChain or LlamaIndex?

Neither is better in general. For a student building a document assistant, LlamaIndex will give a better first result with less code. For someone building an agent that browses, calls APIs and writes files, LangGraph is the more natural fit. Both are well maintained, both change their APIs between releases, and both are easiest to use when you already understand what a retriever, a re-ranker and a tool call are. The honest answer is that the framework contributes less to the outcome than the chunking, the retrieval quality and the test set, which are yours to get right in either.

How to install LlamaIndex

In a virtual environment, install the core package with pip; it pulls in a default set of integrations. Then install the specific packages for your model provider, embedding model and vector store, which are published as separate small packages so you install only what you use. Set your provider API key as an environment variable, or configure a local model through Ollama for a free setup. Pin versions in your requirements file because the package layout has changed across major versions and older tutorials import from paths that no longer exist. Test with a five-line load-index-query script before building further.

02

Pick in two minutes

Match the framework to the shape of the problem.

  • Answers from documents

    Many sources, retrieval quality is the product, you want evaluators built in.

    LlamaIndex
  • An agent that acts

    Tools, loops, approvals, long-running state, tracing on every step.

    LangChain + LangGraph
  • Learning the mechanics

    One retriever, one re-ranker, one prompt, one test set, no framework.

    Plain Python
03

In the room

Where these systems get explained to students.

Stuck choosing a stack?

Tell me what the app must do and I will tell you what to build it with, and what to measure.