Overview
This guide covers the essential operations you’ll need to get started with Mini RAG. After installation, you can be up and running in just a few lines of code.Prerequisites
Before starting, ensure you have:Python 3.11+
Mini RAG requires Python 3.11 or higher
API Keys
OpenAI API key (or compatible provider)
Vector Database
Milvus instance (local or cloud)
Mini RAG
Install with
uv add mini-ragQuick Start
The fastest way to get started is with this minimal example:Core Operations
1. Initialize the System
Set up your RAG system with the necessary components:2. Index Documents
Add documents to your knowledge base:Single Document
Multiple Documents
With Metadata
3. Query the System
Ask questions and get answers:Basic Query
With Custom Parameters
Access Response Details
Working with Individual Components
Mini RAG’s modular design lets you use individual components:Document Loading
Text Chunking
Embedding Generation
Vector Operations
System Statistics
Monitor your RAG system:Environment Configuration
Create a.env file in your project root:
Error Handling
Handle common errors gracefully:Best Practices
Reuse RAG Instance
Reuse RAG Instance
Create the RAG instance once and reuse it for multiple operations. Initialization is expensive.
Use Metadata
Use Metadata
Add rich metadata to documents for better organization and filtering.
Tune Retrieval Parameters
Tune Retrieval Parameters
Adjust
top_k and rerank_top_k based on your needs:- Higher
top_k: Better recall, slower - Lower
rerank_top_k: Faster, more focused answers
Check Before Indexing
Check Before Indexing
Check if documents are already indexed to avoid duplicates.
