Best RAG Frameworks in 2026
The RAG frameworks worth building on in 2026 — LlamaIndex, LangChain, LangGraph, DSPy, Dify and Mastra — plus the retrieval layer that decides answer quality.
By Imtiaz RayhanUpdated 7 min read
On this page
- The summary table
- The frameworks, one at a time
- LlamaIndex — the data framework
- LangChain — orchestration with retrieval attached
- DSPy — optimize the pipeline, do not tune prompts
- Dify — the visual knowledge pipeline
- Mastra — the TypeScript answer
- One name to strike off the 2025 shortlist
- The layer that actually decides your answers
- Check your evaluation library's pulse
- The verdict, by situation
Start with LlamaIndex if retrieval and documents are the hard part, LangChain when RAG is one piece of a larger agent, DSPy when you would rather optimize the pipeline than hand-tune prompts, Dify when a visual knowledge pipeline beats writing one, and Mastra if your stack is TypeScript. Then spend your real time on parsing, chunking, reranking and evaluation, which move answer quality far more.
Steps at a glance
- Decide whether retrieval is the hard part. Write down which of two problems you have. If the model keeps missing relevant context in messy documents, retrieval is the problem and the framework should be chosen for indexing and parsing depth. If retrieval is basically working and the difficulty is orchestration, tools and state, choose the agent framework instead and treat retrieval as one node inside it.
- Match the framework to the language your product is in. This is a harder constraint than any feature list. LlamaIndex, LangChain and DSPy are Python-first, Mastra is TypeScript-native, and Dify is a platform you configure rather than a library you import. Fighting your runtime to get a marginally better abstraction is a trade that never pays off in maintenance.
- Fix the parsing layer before comparing frameworks. Most bad RAG is bad extraction. Run your ugliest real documents through a dedicated parser and read the output as text before you index anything. If the tables come out scrambled, no retrieval strategy and no framework will rescue the answers downstream.
- Build a small labelled evaluation set first. Collect thirty to fifty real questions with the passages that should be retrieved and the answers you would accept. Without this, every subsequent decision about chunk size, embedding model or reranker is a matter of opinion, and framework comparisons collapse into whichever demo felt nicer.
- Add reranking before adding cleverness. Retrieve generously, then rerank to a small, high-precision context. A cross-encoder reranking pass is usually a larger quality jump than switching frameworks, changing embedding models, or adopting a more elaborate retrieval strategy, and it is a handful of lines in every option here.
- Only then choose the framework, and keep the seams clean. Pick the library that gets out of your way, and keep parser, chunker, embedding model, vector store and reranker behind interfaces you control. Every one of those components will be swapped at least once, and the framework you chose should never be the reason a swap is expensive.
Key takeaways
- LlamaIndex is the data-centric pick, and the company's centre of gravity has moved to document processing — LlamaParse, LlamaCloud and the new open-source LiteParse.
- LangChain 1.x is now an agent framework first: create_agent is a configurable harness running on LangGraph, with the largest integration ecosystem behind it.
- DSPy 3.x compiles prompts against a metric instead of hand-tuning them, with GEPA and MIPROv2 as the current optimizers and real production users.
- Dify is the visual option: a Knowledge Pipeline that extracts, cleans, chunks and indexes, self-hostable under a source-available licence.
- Retrieval quality — parsing, chunking, embeddings, reranking — decides RAG outcomes far more than which library wires them together.
- Check your evaluation library's pulse: Ragas changed hands and its repository has been quiet since February 2026, while DeepEval ships weekly.
A RAG framework is the wiring between your documents and your model: it loads and chunks data, builds an index, retrieves the right context, and hands it to the LLM. You can hand-roll all of that against a vector database and a model SDK, and for a single index it is worth it. Frameworks earn their keep once you need multiple retrieval strategies, reranking, evaluation and agentic retrieval. If the pattern is new to you, start with how RAG works. This page describes pricing models rather than prices; the tool pages carry the numbers.
Last reviewed: September 2026.
The summary table
| Framework | What it's for | Pricing model | Best for |
|---|---|---|---|
| LlamaIndex | Indexing, querying and document processing | Open source (MIT); paid cloud parsing | Retrieval quality over messy documents |
| LangChain | Provider-agnostic agents with RAG built in | Open source (MIT) | RAG as one piece of a larger app |
| LangGraph | Stateful, durable orchestration under an agent | Open source (MIT) | Multi-step retrieval you need to control |
| DSPy | Compiling prompts against a metric | Open source (MIT) | Optimizing a pipeline instead of tuning it |
| Dify | Visual knowledge pipelines and agent workflows | Source-available; cloud and enterprise plans | Teams who would rather configure than code |
| Mastra | TypeScript-native agents, tools and workflows | Open source (Apache-2.0 core) | Keeping the whole stack in TypeScript |
The frameworks, one at a time
LlamaIndex — the data framework
If retrieval quality is what makes or breaks your app, LlamaIndex is still the default. It remains the toolkit that takes indexing and querying most seriously: pluggable loaders, several index types, query engines, routers, and a deep bench of retrieval strategies beyond plain vector search, all under an MIT licence.
What has changed is where the company's weight sits. LlamaIndex now presents itself as a document-intelligence business: LlamaParse for parsing, extraction and indexing, LlamaCloud as the hosted platform, Workflows for pipelines, and a newer open-source local parser, LiteParse, for teams who want the parsing to stay on their own machines. Parsing has a free monthly credit allowance with paid plans above it.
Verdict: choose it when the sentence "the model keeps missing the relevant context" describes your problem, and especially when your corpus is PDFs rather than clean text. The trade is that you are adopting an ecosystem whose commercial centre is parsing, which is fine if parsing is your bottleneck and noise if it is not.
LangChain — orchestration with retrieval attached
Reach for LangChain when RAG is one component of a larger system rather than the whole system. In 1.x it reorganized around agents: create_agent is a minimal, highly configurable harness assembled from a model, tools, a prompt and middleware, and agents run on top of LangGraph, which is where durable execution, persistence and human-in-the-loop control come from. The integration ecosystem — loaders, vector stores, retrievers — remains the largest in the category and is the honest reason most teams end up here.
Verdict: the pragmatic default for applications, not the deepest tool for retrieval. The trade against LlamaIndex is breadth of application against depth of retrieval, worked through in LangChain versus LlamaIndex. If your retrieval is multi-step and needs to be inspectable, drop to LangGraph directly rather than fighting the harness.
DSPy — optimize the pipeline, do not tune prompts
DSPy is the answer to "I am tired of hand-tuning prompts in my RAG pipeline." From the Stanford NLP group and MIT-licensed, it inverts the workflow: declare typed signatures, compose modules such as Predict, ChainOfThought and ReAct, define a metric, and let an optimizer compile the prompts and few-shot examples that maximize it. The current line is 3.x, and the optimizers to know are GEPA for reflective prompt evolution, MIPROv2 for instruction and demonstration search, and BootstrapFinetune when you want weights involved. DSPy's own site names production users including Shopify, Dropbox, AWS, JetBlue, Replit and Databricks.
Verdict: the highest-leverage option when you already have an evaluation metric, and close to useless before you do. It composes with the others rather than replacing them — optimizing a retrieval-and-generation pipeline you built elsewhere is the common pattern.
Dify — the visual knowledge pipeline
Dify is the option for teams who would rather configure a pipeline than write one. Its Knowledge Pipeline builds repeatable ingestion from files, websites, online documents and drives, extracting, cleaning, chunking and indexing before the content reaches an agent or workflow. The Community Edition is source-available under an Apache-2.0-derivative licence and self-hosts with Docker; Dify Cloud is the managed path, and Dify Enterprise adds SSO and SAML, role-based access control, and SOC 2 Type II and ISO 27001 compliance.
Verdict: strong when non-engineers need to own the corpus and the workflow, and when self-hosting is a requirement. Read the licence before embedding it in a commercial product, since source-available is not the same as open source.
Mastra — the TypeScript answer
Mastra is the TypeScript-native framework, Apache-2.0 at the core with source-available enterprise features and free to start with no seat tiers. Its positioning leads with agents, tools, workflows, memory and observability, but its RAG helpers include chunking, vector stores and reranking; what you still bring yourself is a parser for PDFs and other messy documents.
Verdict: the right call when keeping one language across the product outweighs retrieval depth. Teams that need both often keep a Python retrieval service behind an API and call it from the TypeScript app.
One name to strike off the 2025 shortlist
Flowise, the drag-and-drop builder that appeared on nearly every RAG shortlist a year ago, had its repository archived in August 2026. Treat an inherited Flowise deployment as frozen rather than maintained, and read Dify as the closest live equivalent if a visual builder is what you actually wanted.
The layer that actually decides your answers
The honest caveat outranks the entire comparison above: the framework matters less than your retrieval quality. Four decisions move answer quality more than the library does.
Parsing. Most bad RAG is bad extraction. Unstructured, Docling, Marker, Reducto and LlamaParse turn messy PDFs, documents and images into clean text before anything else happens. Read the output yourself before indexing it, and see the document parser roundup for how they differ.
Chunking. Boundaries decide what can be retrieved at all. Chonkie is the lightweight, MIT-licensed library for the job if you would rather not write splitters by hand.
Embeddings. Model choice is a measurable decision, not a matter of taste — choosing embeddings covers how to make it against your own data.
Reranking. The cheapest large improvement most pipelines have not made. Retrieve generously, then rerank down to a small, high-precision context with a cross-encoder such as Cohere Rerank, whose Rerank 4 model shipped in December 2025, or Voyage AI. Hybrid search and reranking is the pattern to copy.
Underneath all of it sits the store itself, which is its own decision — see the vector database roundup.
Check your evaluation library's pulse
Evaluation is not optional; without it every choice above is opinion. Two things worth knowing as of September 2026: Ragas has changed hands, its repository now living under a new organization with no commits since February 2026, while DeepEval remains actively developed under Apache-2.0. If you are starting fresh, that difference matters more than the metric lists, and DeepEval versus Ragas compares them directly.
The verdict, by situation
Retrieval over messy documents is the problem. LlamaIndex, with a dedicated parser in front of it.
RAG is a feature inside a larger agent. LangChain, dropping to LangGraph when the retrieval flow needs explicit control.
You have a metric and want the pipeline tuned for you. DSPy, layered on whatever you already built.
Non-engineers own the corpus, or self-hosting is mandatory. Dify.
The product is TypeScript and staying that way. Mastra, with retrieval assembled from components.
You are not sure RAG is the right approach. Weigh it against long context first — RAG versus long context is the version of that argument with the numbers in it. Pick the framework that gets out of your way, then spend your real time on the retrieval layer underneath it.
Sources and further reading
Primary documentation used to verify this guide.
- LlamaIndex — LlamaIndex
- LangChain overview (Python, 1.x) — LangChain
- DSPy — Stanford NLP
- Dify — Dify
- Mastra — Mastra
- Cohere Rerank — Cohere
- Ragas repository — Ragas
Frequently asked questions
- Do I even need a RAG framework?
- Not always. A single index, a vector store and a prompt is a few dozen lines written directly against a vector database SDK, and for one corpus that is worth it. Reach for a framework when you need pluggable loaders, several retrieval strategies, reranking, evaluation, or agentic retrieval, which are tedious and error-prone to hand-roll and then maintain.
- LlamaIndex or LangChain for RAG?
- Choose LlamaIndex when retrieval and messy documents are the core problem, because it has the richest indexing and querying primitives and a parsing product line behind it. Choose LangChain when RAG is one part of a larger application that also needs agents, tools and orchestration. A common production pattern is LlamaIndex for the retrieval layer with LangChain and LangGraph for orchestration around it.
- What happened to LangChain in version 1.x?
- It reorganized around agents. The headline API is create_agent, described by LangChain as a minimal, highly configurable agent harness composed from a model, tools, a prompt and middleware, and agents run on top of LangGraph so they inherit durable execution, persistence and human-in-the-loop control. Retrieval is still first-class through the integration ecosystem, but it is no longer the framing of the library.
- Where do embeddings and reranking fit in?
- Every framework here is a thin layer over the same primitives: a parser, a chunker, an embedding model, a vector store and usually a reranker. The framework wires them together but their quality determines your answers, so invest there first. Reranking in particular is the cheapest large improvement most pipelines have not made yet.
- Which RAG framework should a TypeScript team use?
- Mastra is the TypeScript-native agent framework, open source under Apache-2.0 for the core with source-available enterprise features. Its RAG helpers cover chunking, embeddings, vector stores and reranking, but document loading stops at text, HTML, Markdown and JSON, so plan on bringing your own parser for PDFs. Teams that want retrieval depth in TypeScript often keep the retrieval service in Python and call it from the TypeScript app.
Filed under
listicle · rag · frameworks · llamaindex · langchain
Related
- LangChain vs LlamaIndex in 2026: Agents or Data?The classic framework confusion resolved — LangChain's agent loop and ecosystem vs LlamaIndex's data-and-documents depth — and when you'd genuinely use both.
- Best Vector Database in 2026: pgvector vs Pinecone vs Qdrant vs Weaviate vs Milvus vs Chroma vs LanceDBA decision guide to vector databases — embedded, server, or managed; whether you already run Postgres; and which fits your scale, filtering, and RAG needs.
- LlamaindexThe data framework for LLM apps — ingestion, indexing, query engines, and document agents — now centered on document processing with LlamaParse and LlamaCloud.
- Agentic RAG: When Retrieval Needs an Agent in the LoopWhat agentic RAG is — retrieval as a tool an agent uses iteratively, with query planning, self-correction, and multi-source routing — and when the upgrade pays.
- DifyThe visual platform for LLM apps and agentic workflows — canvas-built chatflows, RAG pipeline, agent nodes with 50+ tools, and LLMOps, self-hosted via Docker.
- DSPyProgram language models instead of prompting them: declare tasks as typed signatures and let optimizers compile the prompts and few-shot examples for you.
- Choosing Embeddings in 2026: OpenAI vs Cohere vs Voyage vs Open-SourceA decision guide for picking an embedding model for retrieval — accuracy, dimensions, cost, multilingual and domain fit, self-hosting, and lock-in.
- How RAG Actually Works: Ingestion, Chunking, Retrieval & RerankingA clear, practical walkthrough of the retrieval-augmented generation pipeline — what each stage does, where it fails, and how the pieces fit together.