A Retrieval-Augmented Generation (RAG) application that delivers context-aware Stoic guidance grounded in the teachings of Marcus Aurelius' Meditations. The system combines semantic search, conversation memory, and large language models to generate responses based on relevant source passages rather than relying solely on model knowledge.
Large language models are powerful conversational tools, but they often lack grounding in specific source material. This project addresses that limitation by implementing a RAG pipeline that retrieves relevant passages from Meditations and uses them as context for response generation.
The result is an AI assistant capable of providing practical Stoic insights while remaining anchored to the philosophical principles found in the original text.
- Retrieval-Augmented Generation (RAG) architecture
- Semantic search over Meditations
- Context-aware conversational responses
- Conversation memory for multi-turn interactions
- Vector similarity search using Pinecone
- Grounded responses based on retrieved passages
- CLI-based chat interface
- Modular and extensible codebase
I'm feeling anxious about a presentation tomorrow.
Marcus Aurelius frequently reminded himself that external events are not fully within our control, but our judgments about them are. Focus your energy on preparation, clarity, and effort rather than the outcome. The presentation itself is temporary; your character and response to it are what truly matter.
User Query
│
▼
CLI Interface
│
▼
Conversation Memory
│
▼
Retriever (Pinecone)
│
▼
Relevant Passages
│
▼
Prompt Construction
│
▼
Mistral LLM
│
▼
Grounded Response
- Python
- LangChain
- Mistral AI
- Pinecone
- Rich (CLI)
- Retrieval-Augmented Generation (RAG)
- Semantic Search
- Text Chunking
- Embeddings
- Vector Similarity Retrieval
- Conversational Memory
- Prompt Engineering
The PDF version of Meditations is loaded and divided into manageable text chunks suitable for embedding and retrieval.
Each chunk is converted into vector embeddings using Mistral AI's embedding models.
Generated embeddings are stored in Pinecone for efficient similarity search.
When a user submits a query, the system retrieves the most relevant passages from the vector database.
Retrieved passages are combined with conversation history to create an enriched prompt.
The language model generates a response grounded in both the retrieved content and ongoing conversation context.
.
├── Marcus-Aurelius-Meditations.pdf
├── db.py
├── main.py
├── ui_cli.py
├── pyproject.toml
└── .env.example
Ensuring responses remain aligned with Stoic principles while still addressing modern-day questions.
Selecting chunk sizes and retrieval strategies that maximize relevance without losing context.
Balancing retrieved passages and conversation memory within model context limits.
Grounding responses in retrieved source material to improve factual and thematic consistency.
- Python 3.12+
- Pinecone Account
- Mistral AI API Key
Clone the repository:
git clone https://github.com/khadarbashajilan/RAG.git
cd RAGInstall dependencies using uv:
uv syncCreate a .env file from the provided example:
cp .env.example .envUpdate the values inside .env with your credentials:
MISTRAL_API_KEY=your_mistral_api_key
PINECONE_API_KEY=your_pinecone_api_keyProcess Meditations, generate embeddings, and populate the Pinecone vector index:
uv run db.pyStart the interactive Stoic assistant:
uv run main.py- Web interface using Streamlit or React
- Source citations for retrieved passages
- Hybrid search (keyword + vector retrieval)
- Evaluation metrics for retrieval accuracy
- Support for additional Stoic philosophers
- Docker deployment
- API endpoint for external integrations
I've always been fascinated by how timeless philosophical ideas can remain relevant in modern life. While studying Stoicism, I realized that many people struggle to apply philosophical concepts to real-world situations despite their practical value.
This project allowed me to explore Retrieval-Augmented Generation while building something personally meaningful: an AI system that transforms a classic philosophical text into an interactive, conversational experience.
Beyond the technical implementation, the project reflects my interest in creating AI systems that are grounded, useful, and capable of making complex knowledge more accessible.
- Python Development
- Large Language Model Integration
- Retrieval-Augmented Generation (RAG)
- LangChain
- Vector Databases
- Prompt Engineering
- Semantic Search
- AI Application Development
- System Design
- Conversational AI
MIT License
"You have power over your mind — not outside events. Realize this, and you will find strength." — Marcus Aurelius