Skip to main content

LlamaIndex: Data Framework for LLM Applications & RAG

LlamaIndex is the leading data framework for building LLM applications over custom data. It excels at the ingestion-to-retrieval pipeline: loading from 100+ data sources, intelligent chunking into Nodes, building vector/summary/keyword indexes, and powering sophisticated query engines for RAG, multi-document Q&A, and agent tool use.

✓ 100+ data source loaders ✓ Advanced RAG patterns ✓ Multiple index types ✓ Query routing & synthesis ✓ Local HuggingFace support
Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →

Core Pipeline: Load, Index, and Query

The fundamental LlamaIndex workflow — load documents, build a VectorStoreIndex, and query with natural language.

pip install llama-index llama-index-embeddings-openai llama-index-llms-openai

from llama_index.core import (
    SimpleDirectoryReader,
    VectorStoreIndex,
    Settings,
    StorageContext,
    load_index_from_storage
)
from llama_index.llms.openai import OpenAI
from llama_index.embeddings.openai import OpenAIEmbedding

# Global settings — applied to all indexes and query engines
Settings.llm = OpenAI(model="gpt-4o-mini", temperature=0)
Settings.embed_model = OpenAIEmbedding(model="text-embedding-3-small")
Settings.chunk_size = 1024
Settings.chunk_overlap = 128

# Load documents from a directory (supports PDF, DOCX, MD, TXT, HTML, CSV...)
documents = SimpleDirectoryReader("./data").load_data()
print(f"Loaded {len(documents)} documents")

# Build a VectorStoreIndex (embeddings auto-generated for each chunk)
index = VectorStoreIndex.from_documents(documents, show_progress=True)

# Persist to disk
index.storage_context.persist(persist_dir="./index_storage")

# Later: reload from disk (no re-embedding needed)
storage_context = StorageContext.from_defaults(persist_dir="./index_storage")
loaded_index = load_index_from_storage(storage_context)

# Create a query engine and ask questions
query_engine = loaded_index.as_query_engine(similarity_top_k=4)
response = query_engine.query("What is the main architecture of the system?")
print(response)
# Access source nodes used for the answer
for node in response.source_nodes:
    print(f"  score={node.score:.3f} | {node.text[:100]}...")

Custom Node Parsing & Metadata Enrichment

Control how Documents are split into Nodes and enrich Nodes with metadata for better retrieval.

from llama_index.core.node_parser import (
    SentenceSplitter,
    SemanticSplitterNodeParser,
    HierarchicalNodeParser
)
from llama_index.core.extractors import (
    TitleExtractor,
    QuestionsAnsweredExtractor,
    SummaryExtractor
)
from llama_index.core.ingestion import IngestionPipeline

# Build an ingestion pipeline with custom transformations
pipeline = IngestionPipeline(
    transformations=[
        # Hierarchical splitter: creates parent (512) + child (128) chunks
        HierarchicalNodeParser.from_defaults(chunk_sizes=[512, 128]),

        # Auto-extract metadata using LLM
        TitleExtractor(nodes=3),               # extract document titles
        QuestionsAnsweredExtractor(questions=3), # what questions does this answer?
    ]
)

nodes = pipeline.run(documents=documents)
print(f"Created {len(nodes)} nodes from {len(documents)} documents")
for node in nodes[:2]:
    print(f"  chars={len(node.text)} | metadata={list(node.metadata.keys())}")

# Auto-merging retriever (retrieves child chunks, merges to parent context)
from llama_index.core.retrievers import AutoMergingRetriever
from llama_index.core.storage.docstore import SimpleDocumentStore

docstore = SimpleDocumentStore()
docstore.add_documents(nodes)
index = VectorStoreIndex(nodes)

base_retriever = index.as_retriever(similarity_top_k=12)
auto_merging_retriever = AutoMergingRetriever(
    base_retriever, storage_context=index.storage_context, verbose=True
)

Query Routing & Multi-Document Synthesis

Route queries to different indexes automatically, or break complex questions into sub-questions.

from llama_index.core.tools import QueryEngineTool
from llama_index.core.query_engine import SubQuestionQueryEngine, RouterQueryEngine
from llama_index.core.selectors import LLMSingleSelector

# Create specialized indexes for different document sets
qdrant_index = VectorStoreIndex.from_documents(qdrant_docs)
milvus_index  = VectorStoreIndex.from_documents(milvus_docs)

# Wrap as tools with descriptions for routing
tools = [
    QueryEngineTool.from_defaults(
        query_engine=qdrant_index.as_query_engine(),
        name="qdrant_guide",
        description="Information about Qdrant vector database, payload filtering, and sparse vectors"
    ),
    QueryEngineTool.from_defaults(
        query_engine=milvus_index.as_query_engine(),
        name="milvus_guide",
        description="Information about Milvus distributed database, DiskANN, and billion-scale search"
    ),
]

# RouterQueryEngine — LLM picks which tool to use
router_engine = RouterQueryEngine(
    selector=LLMSingleSelector.from_defaults(),
    query_engine_tools=tools,
    verbose=True
)
response = router_engine.query("How does Qdrant's payload filtering compare to SQL WHERE clauses?")
print(response)

# SubQuestionQueryEngine — breaks complex queries into sub-questions
sub_engine = SubQuestionQueryEngine.from_defaults(query_engine_tools=tools, verbose=True)
response = sub_engine.query(
    "Compare the index types supported by Qdrant and Milvus, and which is better for 1B vectors?"
)

LlamaIndex vs LangChain vs Haystack

Dimension LlamaIndex LangChain Haystack
Primary strengthData ingestion + RAGAgents + chainingNLP pipelines
RAG sophisticationExcellent (hierarchical, multi-doc)GoodGood
Agent supportGoodExcellentBasic
Data loaders100+ (LlamaHub)80+40+
PDF parsingLlamaParse (best-in-class)PyPDF2 / UnstructuredHaystack PDF converters
ObservabilityLlamaCloudLangSmithHayhooks
Best forComplex RAG, doc Q&AGeneral AI apps, agentsProduction NLP systems

Frequently Asked Questions

What is LlamaIndex and what problems does it solve?▼

LlamaIndex (formerly GPT Index) is a data framework for building LLM applications that need to reason over custom data. Its core strength is the ingestion, structuring, and retrieval layer — it handles loading data from 100+ sources, chunking, embedding, storing in vector indexes, and building sophisticated query engines. It is the go-to choice for complex RAG patterns like multi-document synthesis, hierarchical retrieval, and query routing.

What is the difference between Documents, Nodes, and Indexes?▼

Documents are the raw data containers — loaded from files, web pages, or databases. Nodes are the chunked, processed units derived from Documents — each Node has text, metadata, and an embedding. Indexes organize Nodes for retrieval: VectorStoreIndex stores Nodes as embeddings for semantic search, SummaryIndex chains Nodes for sequential processing, KeywordTableIndex enables keyword lookup. The Document → Node → Index pipeline is the core LlamaIndex data model.

What are query engines in LlamaIndex?▼

A QueryEngine is the interface that takes a natural language query and returns a response using the data in an index. VectorIndexQueryEngine does similarity search + LLM synthesis. SummaryIndexQueryEngine iterates through all nodes to synthesize an answer. RouterQueryEngine dynamically selects which sub-engine to use based on the query. SubQuestionQueryEngine breaks complex queries into sub-questions, queries multiple indexes, then synthesizes a combined answer.

How does LlamaIndex integrate with HuggingFace models?▼

LlamaIndex supports HuggingFace for both LLMs and embeddings. For embeddings, use HuggingFaceEmbedding with any sentence-transformer model — the embedding runs locally with no API cost. For LLMs, use HuggingFaceLLM to run open-source models (Llama 3, Mistral, Qwen) locally via transformers. This enables fully local RAG pipelines with zero API costs and complete data privacy.

LlamaIndex vs LangChain: which should I choose for RAG?▼

LlamaIndex excels at sophisticated RAG — advanced chunking strategies, multi-document synthesis, hierarchical indexes, query routing, and retrieval evaluation. LangChain excels at agent orchestration, multi-step tool use, diverse LLM integrations, and general application chains. For pure RAG with complex retrieval requirements, LlamaIndex is the stronger choice. For agentic workflows with tools, LangChain wins. Many teams use both: LlamaIndex for the retrieval layer, LangChain for agent orchestration.

What is LlamaCloud?▼

LlamaCloud is LlamaIndex's managed platform providing hosted parsing (LlamaParse — best-in-class PDF/document parsing), managed indexing pipelines, and observability. LlamaParse handles complex PDFs with tables, images, and multi-column layouts far better than PyPDF2 or pdfminer. It is available on a free tier (1000 pages/day) and paid plans for production use.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

AI Hallucination Detector AI Safety Checklist Generator CrewAI Agent Config Generator Embedding Storage Calculator RAG Chunk Size Optimizer AI Model Comparator Test Coverage Calculator AI Agent Memory Planner AI Model Comparison Tool Jotai Atom Explorer LLM Cost Calculator CSS Container Query Builder LLM Context Window Calculator AI Prompt Cost Calculator LLM JSON Schema Builder AI Agent Run Cost Tracker AI Pipeline DAG Builder LLM Benchmark Calculator Prompt Injection Tester LangChain PromptTemplate Builder AI Token Cost Calculator MySQL Query Explainer PostgreSQL EXPLAIN Analyzer GraphQL Fragment Generator Jest Coverage Config Generator AI Model Benchmark Comparator Cron Expression Explainer Font Pairing Preview LLM Prompt Cost Calculator AI Model Context Window Visualizer RAG Chunking Calculator OpenAI Prompt Tester AI Rate Limit Calculator LLM System Prompt Analyzer Vibe Coding Prompt Optimizer AI IDE Comparator RAG Chunking Calculator Token Counter & Cost Estimator AI Model Comparison Table LLM Prompt Template Builder AI Commit Message Generator AI Doc Generator — Pro Tool AI Regex Explainer — Pro Tool AI System Guardian Vitest Configuration Generator Mermaid Diagram Generator Elasticsearch Query Tester mTLS Certificate Chain Builder Prompt Token Estimator JS Prototype Chain Visualizer OpenAI Token Counter System Prompt Builder Token Context Calculator LLM Prompt Caching Calculator Multi-Agent Orchestration Planner AI Prompt Token Estimator OpenAI Function Calling Generator AI Context Window Visualizer AI API Rate Limit Calculator HTTP Headers Analyzer AI Code Review — Pro Tool AI Error Explainer — Pro Tool AI SQL Builder — Pro Tool AI Unit Test Generator — Pro Tool Color Palette Generator Docker Compose Generator Free Developer Tools JWT Decoder Prompt Template Builder Regex Tester RSA Key Pair Generator SMTP Server Tester Biome Config Generator Terraform Variable Validator Haproxy Config Validator SBOM Generator AI Variable Namer AI PR Description Generator AI JSDoc Generator K8s Resource Limits Calculator Regex Flags Explainer LLM Token Counter OAuth2 Flow Visualizer Jest Testing Framework Guide Vitest Guide — Vite-native Testing Playwright E2E Testing Guide Core Web Vitals Calculator Solana Program ID Generator Multi-Chain Wallet Address Validator AI Embeddings Dimension Explorer Bezier Curve Editor Embedding Similarity Calculator TypeScript Discriminated Union Builder Core Web Vitals Budget Calculator JWT Decoder & Validator Blockchain Transaction Fee Calculator Database Query Cost Analyzer

Related Articles

Mar 28, 2026 · 14 min read

Building Production RAG Systems with LlamaIndex and Vector Databases 2026

Complete guide to building production-ready RAG systems with LlamaIndex v0.10+. Covers chunking strategies, embedding models, Chroma, Pinecone, Weaviate integration, and advanced retrieval patterns.

Mar 28, 2026 · 18 min read

Building a Production RAG Pipeline: Complete Implementation Guide 2026

A comprehensive guide to building production-ready RAG pipelines in 2026. Covers chunking strategies, embedding models, vector store selection, retrieval techniques, reranking, evaluation with RAGAS/TruLens, and LangChain vs LlamaIndex vs custom implementations.

Apr 1, 2026 · 12 min read

Vector Database Comparison 2026: Pinecone vs Weaviate vs Qdrant vs Chroma

In-depth comparison of the top vector databases in 2026. Evaluate Pinecone, Weaviate, Qdrant, and Chroma on performance, scalability, filtering, pricing, and self-hosting for production AI applications.

Apr 1, 2026 · 13 min read

Vector Databases Explained: Pinecone vs Weaviate vs Qdrant vs Chroma (2026 Guide)

A complete comparison of the best vector databases in 2026: Pinecone, Weaviate, Qdrant, Chroma, and pgvector. Pricing, code examples, performance benchmarks, and a clear decision framework for AI and LLM applications.

Mar 28, 2026 · 12 min read

Building a RAG Pipeline from Scratch: Embeddings, Vector Databases, and Retrieval

Step-by-step guide to building a production-ready RAG pipeline in Python. Covers embeddings, chunking strategies, Chroma and Pinecone setup, hybrid search, reranking, and evaluation with RAGAS.

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →