Lumen RAG Framework
Lumen is a high-performance, modular, and database-agnostic RAG (Retrieval-Augmented Generation) framework written in Rust.
It abstracts the complexity of vector storage and retrieval, allowing you to switch seamlessy between MongoDB, CosmosDB, and Qdrant, while providing built-in support for state-of-the-art embeddings (BERT) via candle.
🚀 Features
- 🔌 Modular Backends: Switch between MongoDB (Atlas/Local) and Qdrant with Feature Flags.
- ⚡ High Performance: Built on
Tokio,Actix-web, andRayonfor async and parallel processing. - 🧠 Local Embeddings: Integrated BERT support using Hugging Face's
candle(no external API needed for embeddings). - 📄 Smart Chunking: Intelligent text segmentation preserving semantic context.
- 🤖 LLM Agnostic: Compatible with any OpenAI-compatible API (Ollama, vLLM, OpenAI, Mistral, etc.).
📦 Installation
Add lumen-rag to your Cargo.toml. Select the database backend you need:
[]
# For MongoDB or CosmosDB support
= { = "0.1.0", = ["mongodb"] }
# OR for Qdrant support
= { = "0.1.0", = ["qdrant"] }
🛠️ Configuration
Lumen uses environment variables for configuration. Create a .env file in your project root:
# --- LLM Settings ---
# URL to your LLM provider (Ollama, OpenAI, Groq, etc.)
LLM_URI=[https://api.openai.com/v1/chat/completions](https://api.openai.com/v1/chat/completions)
# Model name
MODEL=gpt-3.5-turbo
# (Optional) API Key if using a cloud provider
LLM_API_KEY=sk-your-api-key-here
# --- Database Settings ---
# MongoDB / CosmosDB
COSMOS_URI=mongodb://admin:password@localhost:27017
DATABASE=lumen_db
COLLECTION=knowledge_base
# Qdrant
QDRANT_URI=http://localhost:6334
⚡ Quick Start
1. Setup Infrastructure
You can easily start the required databases using Docker:
# Start MongoDB and Qdrant
2. Run the Examples
We provide full server examples in the examples/ folder.
Using MongoDB:
Using Qdrant:
3. Test the API
Ingest a Document (Indexing)
) \
Ask a Question (RAG)
) \
🏗️ Architecture
Lumen is built around the VectorStore trait, enabling easy integration of new vector databases.
Supported Stores
| Database | Feature Flag | Search Type |
|---|---|---|
| MongoDB | mongodb |
Hybrid (Fetch + In-memory Cosine Similarity) |
| CosmosDB | mongodb |
Hybrid (Mongo API Compatible) |
| Qdrant | qdrant |
Native HNSW Vector Search |
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
📄 License
Distributed under the MIT License. See LICENSE for more information.