Search Tutorials
--Ads--Build from Scratch or Use a Framework?
The trade-offs, and a recommended path for teams.
Most of this tutorial builds RAG components from scratch in plain Python, and the previous three lessons showed the same ideas in frameworks. Which should you use for a real project? There is no universal answer, but there is a sensible way to decide, and a middle path that works for many teams.
What frameworks give you
- Speed to a first prototype. A working RAG demo in an afternoon.
- Integrations. Loaders for Confluence, Notion, SharePoint and Google Drive; adapters for dozens of vector stores and model providers.
- Ready-made techniques. Parent-child retrieval, multi-query, rerankers and agents behind one class.
- Shared vocabulary. New team members may already know the framework.
- Ecosystem tools. Tracing, evaluation and deployment tools designed around the framework.
What frameworks cost you
- Hidden prompts and behaviour. Default prompts and settings you did not write affect your answers; debugging means reading framework source code.
- Abstraction mismatch. When your needs differ from the framework's model (custom permissions, unusual retrieval logic), you fight the abstraction.
- Churn. Fast-moving APIs mean breaking changes and upgrade work.
- Lag. New model features (structured outputs, citations, caching options, new parameters) may reach the framework later than the model provider's own SDK.
- Dependencies. Large dependency trees increase install size and security review effort.
The core of RAG is small
As Build a Minimal RAG System from Scratch showed, the essential pipeline is around 50 lines. Even a production system with hybrid search, reranking, citations and evaluation is a few thousand lines of code you fully understand. The hard parts of RAG (parsing your documents well, chunking them sensibly, evaluating honestly, handling permissions) are specific to your data, and no framework does them for you.
Decision guide
| Situation | Lean towards |
|---|---|
| Hackathon, proof of concept, exploring techniques | A framework |
| Many data sources that need connectors | A framework's loaders (at least) |
| Complex agent workflows with state, retries and human approval | LangGraph or a similar workflow tool |
| Long-lived product where answer quality and debugging matter most | Your own core pipeline |
| Strict security, permissions or compliance requirements | Your own core pipeline |
| A team already experienced with one framework | That framework |
The middle path
Many successful teams do this:
- Prototype with a framework to learn what works for your data.
- Own the core loop in production: retrieval, prompt construction and generation, written against the model provider's SDK, so every prompt and parameter is visible.
- Borrow components where they save real effort: document loaders, text splitters, parsers. Most framework components can be used standalone, without adopting the whole framework.
- Hide external pieces behind your own interfaces (as in Choosing a Vector Database), so each one stays replaceable.
# Borrow a framework component without adopting the framework
from langchain_text_splitters import RecursiveCharacterTextSplitter
splitter = RecursiveCharacterTextSplitter(chunk_size=800, chunk_overlap=100)
chunks = splitter.split_text(text) # plain strings in, plain strings out
# ...then use your own embedding, retrieval and generation code
Make sure you can print the exact final prompt sent to the model for any request. If you cannot see it, you cannot debug it. Combine that with an evaluation set (Module 12), and the framework question becomes a matter of convenience, not quality.
Key takeaways
- Frameworks speed up prototypes and integrations, at the cost of hidden behaviour, churn and abstraction mismatch.
- The core RAG loop is small enough to own; the hard, data-specific parts are yours either way.
- A common middle path: prototype with a framework, own the core loop, borrow components.
- Always be able to see the exact prompt sent to the model.