LlamaIndex
LlamaIndex (formerly GPT Index) is a data framework focused on RAG (retrieval-augmented generation). Unlike the all-in-one LangChain, it devotes all its effort to one thing: how to let an LLM use your private data efficiently.
Core concepts
Data Connector: supports 160+ data sources, including PDF, Word, Notion, Slack, databases, web pages, and APIs. Index: organizes data into a structure that is easy to retrieve, including vector indexes, keyword indexes, tree indexes, knowledge graph indexes, and document summary indexes. Retriever: recalls relevant content from an index, supporting similarity retrieval, hybrid retrieval, and recursive retrieval. Query Engine: links retrieval and generation, taking a question in and giving an answer out. Node: a smarter splitting unit than a chunk, preserving metadata and context relationships.
Advanced retrieval strategies
LlamaIndex goes deeper on retrieval quality than general frameworks:
Small-to-big retrieval: uses small blocks (sentences) for vector matching to ensure precision, then automatically expands to the containing large block (paragraph) to ensure full context.
Recursive retrieval: first retrieves document summaries to locate relevant documents, then retrieves specific passages inside them, which suits long documents.
Hybrid retrieval: fuses vector retrieval (semantic) with BM25 (keyword) to balance semantic similarity and exact matching.
Query rewriting and routing: automatically rewrites user questions into a form better suited to retrieval, or routes them to different indexes.
Auto-Merging Retriever: when multiple sub-blocks are hit, they are automatically merged into the parent block and returned.
Comparison with LangChain
LlamaIndex advantages: more professional RAG, rich index types, deeper retrieval strategies, and more concise code. LangChain advantages: a broader ecosystem, stronger agents and tool calling, a large community, and many tutorials.
Real projects often mix the two: LlamaIndex handles data ingestion and the retrieval layer, while LangChain or LangGraph handles upper-level orchestration.
Use cases
Enterprise knowledge base question answering, intelligent document analysis, contract review, retrieval over financial reports and research notes, customer service knowledge bases, and legal text retrieval. Wherever there are "large volumes of private documents plus precise question answering", LlamaIndex deserves priority.
Practical tips
When RAG performs poorly, 80% of the problem lies in splitting and retrieval rather than the model. The chunk size must match the question type - factual questions need small chunks, summary questions need large ones. Be sure to configure a reranker model, which significantly improves recall precision.