LlamaIndex: Core Concepts and Data-First Frameworks
While LangChain was built from the ground up as a general-purpose agent orchestration framework, LlamaIndex (formerly GPT Index) took a radically different path: a data-first framework specialized in ingesting, indexing, and querying complex private data.
If your primary engineering challenge is parsing complex enterprise PDFs, maintaining hierarchical document graphs, or building advanced RAG retrieval engines, LlamaIndex is the gold standard.
1. The LlamaIndex Data Architecture
flowchart TD
subgraph DataIngestion["1. Ingestion & Connectors (LlamaHub)"]
Sources["Data Sources: PDFs, Snowflake, S3, Confluence, Slack"] --> Loader["Data Connector (Reader)"]
Loader --> Docs["Documents (Raw text + file metadata)"]
end
subgraph IndexingLayer["2. Indexing Layer"]
Docs --> NodeParser["Node Parser / Sentence Splitter"]
NodeParser --> Nodes["Nodes (Atomic chunks with parent/child relationships)"]
Nodes --> Index["Index Structure (VectorStoreIndex, SummaryIndex)"]
end
subgraph QueryLayer["3. Query Engine"]
Index --> Retriever["Retriever (Cosine / Hybrid)"]
Retriever --> NodePostProcessor["Node Post-Processor (Reranker, Filter)"]
NodePostProcessor --> ResponseSynth["Response Synthesizer + LLM"]
ResponseSynth --> FinalResponse["Grounded Response with Node Citations"]
end
style DataIngestion fill:#1e293b,color:#fff
style IndexingLayer fill:#064e3b,color:#fff
style QueryLayer fill:#1e1b4b,color:#fff
style Index fill:#d97706,color:#fff
style FinalResponse fill:#059669,color:#fff
2. Documents vs. Nodes: The Relational Graph
In LlamaIndex, the fundamental unit of data is not just a raw string chunk—it is a Node:
- A Document represents an entire file (e.g., a 40-page PDF).
- A Node represents a single chunk (e.g., 500 characters), but it retains explicit metadata pointers:
ref_doc_id: Pointer to the parent Document.prev_node_id: Pointer to the preceding paragraph in the text.next_node_id: Pointer to the subsequent paragraph.
flowchart LR
Doc["Parent Document: 'PySpark_Architecture.pdf'"]
Doc --> N1["Node 1: Spark Driver"]
Doc --> N2["Node 2: Cluster Manager"]
Doc --> N3["Node 3: Worker Executors"]
N1 <-->|Sequential Pointer| N2
N2 <-->|Sequential Pointer| N3
style Doc fill:#2563eb,color:#fff
style N1 fill:#059669,color:#fff
style N2 fill:#059669,color:#fff
style N3 fill:#059669,color:#fff
This linked graph structure enables Window Retrieval: when Node 2 matches a search query, LlamaIndex can automatically fetch Node 1 and Node 3 to provide full surrounding context to the LLM!
3. The 3 Query Abstractions
LlamaIndex provides clean, progressively powerful interfaces for querying data:
Retriever: Takes a string query, returns a ranked list of relevantNodeWithScoreobjects.QueryEngine: Takes a query, retrieves nodes, passes them to an LLM, and returns a single grounded answer.ChatEngine: A multi-turn conversational agent with chat history memory that maintains context across multiple queries.
# The 3-Line LlamaIndex Quickstart
# index = VectorStoreIndex.from documents(documents)
# query engine = index.as query engine(similarity top k=3)
# response = query engine.query("What is our Snowflake data retention policy?")
Key Takeaways
- LlamaIndex is data-first: Built specifically for document ingestion, parsing, and advanced RAG search.
- Nodes maintain relationships: Preserves parent-child and previous/next pointers to prevent context loss.
- LlamaHub provides 300+ pre-built connectors to enterprise databases, cloud storage, and SaaS tools.