MAITRI is a fully local Retrieval-Augmented Generation (RAG) AI companion designed for emotionally intelligent, context-aware conversations while preserving user privacy.
The project combines a local Large Language Model (Qwen), semantic retrieval using ChromaDB, long-term conversational memory, and structured prompt engineering to create an AI assistant capable of maintaining context across conversations without relying on cloud services.
Status: π§ Active Development
- π Fully Offline AI Assistant
- π§ Retrieval-Augmented Generation (RAG)
- π¬ Long-Term Conversational Memory
- π Semantic Search using ChromaDB
- β‘ Streaming Token Generation
- π GPU Accelerated Embeddings (CUDA)
- π Token-Aware Document Chunking
- π Session Logging using JSONL
- π§© Modular Pipeline Architecture
- β€οΈ Emotion-Aware Prompt Engineering
- π Semantic Memory Retrieval
- π‘οΈ Crisis Detection & Safety Handling
User
β
βΌ
Maitri Chat
β
βΌ
Analyst Prompt
β
βΌ
Retriever
β
ββββββββββββββββΊ ChromaDB
β β
β βΌ
β Relevant Memories
β
βΌ
Context Builder
β
βΌ
Qwen Local LLM
β
βΌ
Streaming Response
β
βΌ
Conversation Logger
β
ββββββββββΊ JSONL History
β
ββββββββββΊ Session Summary
β
βΌ
Memory Indexer
β
βΌ
ChromaDB
.
βββ builder.py
βββ clean_memory.py
βββ config.py
βββ data
βββ embedding
β βββ embedder.py
β βββ model.py
βββ history
βββ LLM
β βββ llm_engine.py
βββ loader.py
βββ maitri_chat.py
βββ models.py
βββ pipeline
β βββ indexing.py
β βββ querying.py
β βββ rag_pipeline.py
βββ retrival
β βββ context_builder.py
β βββ router.py
β βββ search_service.py
βββ src
β βββ chunker.py
βββ system_prompt.py
βββ vectordb
β βββ base.py
β βββ chroma_store.py
β βββ retriever.py
βββ vector_db
βββ chroma.sqlite3
| Component | Technology |
|---|---|
| Language | Python 3.13+ |
| LLM | Qwen 2.5 (Ollama) |
| Vector Database | ChromaDB |
| Embedding Model | SentenceTransformers |
| Chunking | tiktoken |
| Storage | JSON / JSONL |
| Hardware | NVIDIA CUDA (optional) |
- User sends a message.
- The Analyst prompt classifies the conversation.
- Relevant memories are retrieved from ChromaDB.
- Context Builder prepares the final prompt.
- Qwen generates a streamed response.
- Conversation is logged.
- Session summaries are periodically indexed into the vector database for future retrieval.
Responses are streamed token-by-token instead of waiting for the entire generation to finish.
Past conversations are summarized, embedded, and stored inside ChromaDB, allowing MAITRI to retrieve relevant memories using semantic similarity.
Documents are split according to tokenizer limits instead of arbitrary word counts, improving retrieval quality.
Conversation history uses append-only JSONL storage for scalable and efficient logging.
Sentence embeddings automatically utilize CUDA when available.
- High inference latency depending on hardware
- Memory summarization can still be improved
- Prompt engineering is continuously evolving
- Multi-user support is not yet implemented
- No graphical user interface (CLI only)
- Reduce inference latency
- Hybrid retrieval (BM25 + Vector Search)
- Memory ranking and decay
- Function calling
- Voice interaction
- Web interface
- Agentic workflow
- Multi-modal support
- Quantized model benchmarking
- Docker deployment
Clone the repository
git clone https://github.com/<your_username>/<repository>.git cd <repository>
Create a virtual environment
python -m venv venv
Activate it
Linux
source venv/bin/activateInstall dependencies
pip install -r requirements.txt
Start Ollama
ollama serve
Pull Qwen if necessary
ollama pull qwen2.5:7b
Run the chatbot
python maitri_chat.py
Current observations
| Metric | Value |
|---|---|
| Embedding | GPU Accelerated |
| Memory Search | ChromaDB |
| Response Streaming | Yes |
| Average Latency | 3β75 seconds |
| Offline Support | Yes |
This project was created to explore Retrieval-Augmented Generation, prompt engineering, semantic memory, and local Large Language Models while building an AI companion that prioritizes privacy and contextual understanding.
The primary objective is educational: to gain hands-on experience designing scalable AI systems rather than relying solely on existing frameworks.
This project is licensed under the MIT License.
Vicky
Bachelor's Student β Artificial Intelligence & Machine Learning
Interested in:
- Artificial Intelligence
- Retrieval-Augmented Generation
- Robotics
- Computer Vision
- Deep Learning
- Large Language Models