Where LangChain is a general orchestration toolkit, LlamaIndex specializes in connecting LLMs to your data: loaders, indexes, retrievers, and query engines. It maps cleanly onto Module 14.1 RAG concepts and Module 14.2 vector stores.
Use LlamaIndex when the product is retrieval quality; use LangGraph/CrewAI when the product is multi-step agency.
Learning Objectives
By the end of this lesson, students should be able to:
- Describe LlamaIndex’s data-centric RAG workflow (load → index → query).
- Build a VectorStoreIndex over documents and ask questions via a query engine.
- Contrast LlamaIndex vs LangChain vs LangGraph selection criteria.
- Attach an external vector store (Qdrant/Chroma/Pinecone) as the backend.
- Explain nodes, indexes, and retrievers in LlamaIndex vocabulary.
- Know when agents/workflows in LlamaIndex still defer to Volume 15 patterns.
LlamaIndex (formerly GPT Index) is a framework for building LLM applications over private or domain data. It emphasizes document ingestion, indexing structures, retrieval strategies, and query engines that ground model answers in your corpus.
LangChain vs LlamaIndex vs LangGraph
| Framework | Center of gravity | Reach for it when… |
|---|---|---|
| LangChain | Composable app glue | Many integrations, mixed tools + RAG |
| LlamaIndex | Indexes & query engines | Data connectors and retrieval quality first |
| LangGraph | Stateful agent graphs | Cycles, HITL, durable workflows |
Load → Index → Query
Mental Model
Documents / Nodes
- Parsed chunks
- Metadata attached
- Feed indexes
Indexes
- Vector, keyword, …
- Store embeddings
- Pluggable backends
Query engines
- Retrieve + synthesize
- Chat engines too
- RAG in one call
Strengths
- Data-first RAG DX
- Rich loaders/indexes
- Clear query abstractions
- Works with Module 14.2 stores
Tradeoffs
- Less “everything app” than LangChain
- Agent graphs still elsewhere
- New abstractions to learn
- Eval still your job
“LlamaIndex and LangChain are mutually exclusive.” Teams often use LlamaIndex for indexing/retrieval and LangChain/LangGraph for broader tool orchestration—or pick one stack and go deep. Choose by team skill and problem shape.
Knowledge Check
- Short Answer: What is LlamaIndex optimized for? Answer: Connecting LLMs to your data via indexes and query engines (RAG).
- True/False:
VectorStoreIndex.from_documentsbuilds a searchable index. Answer: True. - Multiple Choice: LangGraph is the better default for: (a) pure doc Q&A indexing, (b) cyclic durable agents, (c) CSV plotting only. Answer: (b).
- Short Answer: Name the three-step LlamaIndex flow. Answer: Load → index → query.
- True/False: LlamaIndex cannot use Qdrant/Pinecone backends. Answer: False—it integrates with external vector stores.
- Multiple Choice: A query engine typically: (a) only trains FAISS, (b) retrieves and synthesizes an answer, (c) renders CSS. Answer: (b).
- Short Answer: When prefer LangChain over LlamaIndex? Answer: Broad tool/integration composition beyond data indexing (any fair answer).
- Short Answer: What are nodes in LlamaIndex roughly analogous to? Answer: Chunks / document segments with metadata.
- Multiple Choice: Retrieval quality still depends on: (a) only the framework logo, (b) chunking, embeddings, eval, (c) browser themes. Answer: (b).
- True/False: LlamaIndex alone completes all of Volume 15 agent design. Answer: False.
Key Takeaways
- LlamaIndex centers RAG on loaders, indexes, and query engines.
- Pick it when data connectivity and retrieval structure dominate.
- Compare deliberately with LangChain (glue) and LangGraph (graphs).
- Vector DB choice from 14.2 still plugs in underneath.
- Next: CrewAI for role-based multi-agent crews.
Lab: Index a small folder; compare similarity_top_k and cite sources in answers.
Decision drill: Given three product briefs, pick LangChain, LlamaIndex, or LangGraph and justify in one sentence each.
Recap: LlamaIndex is the data-and-index specialist for RAG. Continue with CrewAI.