← Master Index
Vol. 14 Module 14.3 Lecture

LlamaIndex

LangChain & Orchestration Frameworks

How This Lesson Fits the Module & Volume

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.
Definition

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

FrameworkCenter of gravityReach for it when…
LangChainComposable app glueMany integrations, mixed tools + RAG
LlamaIndexIndexes & query enginesData connectors and retrieval quality first
LangGraphStateful agent graphsCycles, HITL, durable workflows

Load → Index → Query

from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings from llama_index.llms.openai import OpenAI from llama_index.embeddings.openai import OpenAIEmbedding Settings.llm = OpenAI(model="gpt-4o-mini") Settings.embed_model = OpenAIEmbedding(model="text-embedding-3-small") documents = SimpleDirectoryReader("./docs").load_data() index = VectorStoreIndex.from_documents(documents) query_engine = index.as_query_engine(similarity_top_k=4) response = query_engine.query("What is our parental leave policy?") print(response)

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
Common Misconception

“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

  1. Short Answer: What is LlamaIndex optimized for? Answer: Connecting LLMs to your data via indexes and query engines (RAG).
  2. True/False: VectorStoreIndex.from_documents builds a searchable index. Answer: True.
  3. Multiple Choice: LangGraph is the better default for: (a) pure doc Q&A indexing, (b) cyclic durable agents, (c) CSV plotting only. Answer: (b).
  4. Short Answer: Name the three-step LlamaIndex flow. Answer: Load → index → query.
  5. True/False: LlamaIndex cannot use Qdrant/Pinecone backends. Answer: False—it integrates with external vector stores.
  6. Multiple Choice: A query engine typically: (a) only trains FAISS, (b) retrieves and synthesizes an answer, (c) renders CSS. Answer: (b).
  7. Short Answer: When prefer LangChain over LlamaIndex? Answer: Broad tool/integration composition beyond data indexing (any fair answer).
  8. Short Answer: What are nodes in LlamaIndex roughly analogous to? Answer: Chunks / document segments with metadata.
  9. Multiple Choice: Retrieval quality still depends on: (a) only the framework logo, (b) chunking, embeddings, eval, (c) browser themes. Answer: (b).
  10. 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.
Trainer’s Guide

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.