TinyRAG  by KMnO4-zx

TinyRAG is a hands-on RAG implementation for learning

created 1 year ago
317 stars

Top 86.5% on sourcepulse

GitHubView on GitHub
Project Summary

This repository provides a hands-on, from-scratch implementation of Retrieval-Augmented Generation (RAG) for Large Language Models (LLMs). It targets developers and researchers seeking to understand and experiment with RAG components without the complexities of integrating with frameworks like LlamaIndex or LangChain. The primary benefit is a simplified, modular codebase for learning and rapid prototyping of RAG pipelines.

How It Works

The RAG process is broken down into three core steps: indexing, retrieval, and generation. Documents are chunked and converted into vector embeddings using various methods (Zhipu, Jina, OpenAI). Retrieval is performed using a custom implementation that stores document chunks and their corresponding vectors in JSON files, accelerated by NumPy for cosine similarity calculations. The generation step utilizes supported LLMs (OpenAI, InternLM2) to produce answers based on the retrieved context. This approach emphasizes clarity and ease of modification for educational purposes.

Quick Start & Requirements

  • Install dependencies: pip install -r requirements.txt
  • Requires Python 3.10+
  • Supports OpenAI, ZhipuAI, and Jina embedding models.
  • OpenAI chat models are supported for generation.
  • Official documentation and demo are available within the README.

Highlighted Details

  • Custom vector store implementation using JSON and NumPy for simplicity.
  • Supports multiple embedding models and LLMs with a clear extension mechanism.
  • Focuses on educational value and ease of modification for experimentation.
  • Includes references to key RAG research papers.

Maintenance & Community

The repository appears to be a personal project with no explicit mention of maintainers, community channels, or a roadmap.

Licensing & Compatibility

The repository's license is not explicitly stated in the README.

Limitations & Caveats

The implementation is explicitly stated as not being suitable for production environments and is intended solely for learning purposes. The custom vector store lacks the robustness and scalability of dedicated vector databases.

Health Check
Last commit

1 month ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
26 stars in the last 90 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems) and Elie Bursztein Elie Bursztein(Cybersecurity Lead at Google DeepMind).

LightRAG by HKUDS

1.0%
19k
RAG framework for fast, simple retrieval-augmented generation
created 10 months ago
updated 21 hours ago
Feedback? Help us improve.