Open-Source RAG Framework Comparison and Understanding the RAG Stack from Scratch
This article compares three common categories of open-source RAG frameworks and explains why starting with a lightweight RAG implementation helps developers understand the core technology stack. It covers document loading, text splitting, embedding, vector storage and retrieval, reranking, generation, dependency-management challenges, and practical optimization directions.
1. Why Reproduce a Minimal RAG Pipeline Before Using Packaged Frameworks
Open-source AI application development frameworks built around Retrieval-Augmented Generation (RAG) can generally be divided into three categories:
- Highly packaged all-in-one platforms: These provide visual orchestration, plugin ecosystems, and multi-model integration. They are suitable for quickly building applications such as knowledge-base question answering and intelligent customer service.
- Mid-level abstraction development frameworks: These expose programmable interfaces for retrieval pipelines and document-processing workflows. They are suitable for teams with some engineering capability that need customization.
- Lightweight scaffold projects: These present the full RAG workflow with minimal runnable code. They are suitable for learning and secondary development.
Packaged frameworks have clear advantages: they are ready to use, support fast iteration, and often have active communities. However, they also have obvious drawbacks: high opacity, difficult debugging, heavy dependencies, and design constraints that can limit deep customization.
For this reason, before working with highly packaged RAG frameworks, it is recommended to first reproduce and extend a lightweight RAG project. The value of doing so includes:
- Understanding core RAG components: Gaining hands-on experience with text loading, splitting, embedding, vector storage and retrieval, such as local vector retrieval with FAISS, and large language model integration.
- Understanding the basic RAG workflow: Observing how data moves through a RAG system at the script level, rather than only calling a few abstract APIs.
- Performing initial optimization and testing: Trying different chunk sizes, replacing embedding models, and refining prompts to see how these choices affect retrieval quality and answer accuracy.
After mastering these fundamentals, using advanced framework APIs for targeted tuning or custom development becomes much more focused.
2. Core Components of a RAG System
A typical RAG pipeline includes the following components, and each one directly affects the final result:
- Document loading and preprocessing: Parsing multiple formats such as PDF, Markdown, and web pages, while handling encoding, noise removal, and deduplication.
- Text splitting: Splitting documents by fixed length, semantic boundaries, or recursive strategies. Chunks that are too large dilute meaning, while chunks that are too small lose context. Overlap windows are often needed to balance these tradeoffs.
- Embedding: Using an embedding model to encode text chunks into dense vectors, so semantically similar texts are closer in vector space.
- Vector storage and retrieval: Local projects can use lightweight vector index libraries, while production environments typically use dedicated vector databases that support approximate nearest-neighbor search and metadata filtering.
- Reranking: Using a cross-encoder to refine the initial retrieval results, which can significantly improve Top-K quality.
- Generation: Combining retrieved passages into a prompt and passing them to a large language model to generate an answer, optionally with citation sources.
3. Advantages and Drawbacks of Highly Packaged Frameworks
Advantages:
- Engineering completeness: Built-in document parsing, splitting strategies, retrieval fusion, caching, and evaluation capabilities save substantial infrastructure work.
- Low-code orchestration: Business users can participate in application building, shortening delivery cycles.
- Ecosystem and extensibility: Multi-model integration, plugin-based tool calling, and API publishing make it easier to integrate with enterprise systems.
Drawbacks:
- Opacity and debugging cost: When retrieval fails, it is difficult to determine whether the issue comes from splitting, embedding, or reranking.
- High resource usage: Full-stack dependencies can be large, making installation and deployment slow and unfriendly to low-spec environments.
- Customization ceiling: When a business needs special recall strategies or multi-route retrieval fusion, it may be necessary to bypass the framework or even modify its source code.
- Version and dependency drift: Rapid framework iteration creates compatibility risks that require continuous attention.
4. Practical Advice for Dependency Management and Slow Installation
Many users report that lightweight RAG projects take too long to install. This is usually caused by a few heavy components:
- Deep learning frameworks and pretrained model libraries: These are the foundation for embedding computation and cross-encoder reranking. The former is large, while the latter carries many pretrained models and tools, making the overall installation size large.
- Implicit dependencies of vector databases: Some vector libraries internally introduce additional inference runtimes to execute default embedding models or optimize computation. These dependencies may still be installed even if the project explicitly specifies a custom embedding model.
Practical recommendations:
- Install on demand: Install only the minimal dependencies required for core inference, avoiding training-related components.
- Lock versions: Use dependency lock files to fix versions and reduce repeated downloads and dependency resolution overhead.
- Use mirror sources and caching: This can significantly reduce download time.
- Decouple optional components: Make nonessential capabilities such as rerankers and multi-format parsers pluggable, and do not install them by default.
- Use prebuilt containers: Preinstall dependencies in an image and reuse it within the team to avoid the time cost of rebuilding environments repeatedly.
5. Advanced and Extension Directions
After getting the basic pipeline running, you can explore the following directions:
- Retrieval quality optimization: Hybrid retrieval combining keywords and vectors, query rewriting, multi-route recall fusion, and reranking strategy comparison.
- Chunking strategy experiments: Semantic splitting, hierarchical splitting, and parent-child chunk retrieval.
- Evaluation system building: Creating a question-answering test set and measuring iteration results through metrics such as recall rate, answer faithfulness, and citation accuracy.
- Engineering deployment: Managing documents with object storage, processing parsing tasks asynchronously with message queues, deploying services on container platforms, and using logging, monitoring, and alerting to track online retrieval and generation quality.
- Security and permissions: Document-level permission filtering, sensitive-information masking, and answer traceability auditing.
6. Conclusion
Highly packaged RAG frameworks and lightweight scaffolds are not opposed. The former improves delivery efficiency, while the latter helps build a deeper understanding of underlying principles. The recommended path is to first run a minimal pipeline, understand the role and cost of each component, and then return to mature frameworks for targeted tuning.
At the same time, it is important to acknowledge the installation and deployment costs caused by heavy dependencies. By using minimal installation, version locking, and modular decoupling, teams can control these costs and balance RAG application effectiveness with engineering maintainability. Readers interested in this approach can start by putting these ideas into practice and gradually building a knowledge-base enhancement system suited to their own business needs.
