|
--- |
|
title: Personal ChatBot |
|
emoji: ๐ฌ |
|
colorFrom: yellow |
|
colorTo: purple |
|
sdk: gradio |
|
sdk_version: 5.0.1 |
|
app_file: app.py |
|
pinned: false |
|
license: apache-2.0 |
|
short_description: Krishna's Persona Chat Bot using Multi RAG network |
|
--- |
|
|
|
# ๐ง Krishna's Personal AI Chatbot |
|
|
|
A memory-grounded, retrieval-augmented AI assistant built with LangChain, FAISS, BM25, and Llama3 โ personalized to Krishna Vamsi Dhulipallaโs career, projects, and technical profile. |
|
|
|
> โก๏ธ Ask me anything about Krishna โ skills, experience, goals, or even what tools he used at Virginia Tech. |
|
|
|
--- |
|
|
|
## ๐ Features |
|
|
|
- โ
**Hybrid Retrieval**: Combines dense vector search (FAISS) + keyword search (BM25) for precise, high-recall chunk selection |
|
- ๐ค **LLM-Powered Pipelines**: Uses OpenAI GPT-4o and NVIDIA NIMs (e.g. LLaMA-3, Mixtral) for rewriting, validation, and final answer generation |
|
- ๐ง **Memory Module**: Stores user preferences, recent topics, and inferred tone using a structured `KnowledgeBase` schema |
|
- ๐ ๏ธ **Custom Architecture**: |
|
- Query โ Rewriting โ Hybrid Retriever โ Scope Validator โ LLM Answer |
|
- Fallback humor model (Mixtral) for out-of-scope queries |
|
- ๐งฉ **Document Grounding**: Powered by Krishnaโs actual markdown files like `profile.md`, `goals.md`, and `chatbot_architecture.md` |
|
- ๐ **Enriched Vector Store**: Chunks include LLM-generated summaries and synthetic queries for better search performance |
|
- ๐๏ธ **Gradio Frontend**: Responsive, markdown-formatted interface for natural, real-time interaction |
|
|
|
--- |
|
|
|
## ๐๏ธ Architecture |
|
|
|
```text |
|
User Query |
|
โ |
|
[LLM1] โ Rephrase into 3 diverse subqueries |
|
โ |
|
Hybrid Retrieval (BM25 + FAISS) |
|
โ |
|
[LLM2] โ Classify: In-scope or Out-of-scope |
|
โ |
|
โโ In-scope โ Top-k Chunks โ GPT-4o |
|
โโ Out-of-scope โ Mixtral (funny fallback) |
|
โ |
|
Final Answer + Async Memory Update |
|
``` |
|
|
|
--- |
|
|
|
## ๐ Project Structure |
|
|
|
``` |
|
. |
|
โโโ app.py # Main Gradio app and pipeline logic |
|
โโโ Vector_storing.py # Chunking, LLM-based enrichment, and FAISS store creation |
|
โโโ requirements.txt # Python package dependencies |
|
โโโ faiss_store/ # Saved FAISS vector index |
|
โโโ all_chunks.json # JSON of enriched document chunks |
|
โโโ personal_data/ # Source markdown files (right now excluded) |
|
โโโ README.md |
|
``` |
|
|
|
--- |
|
|
|
## ๐ง Knowledge Sources |
|
|
|
All answers are grounded in curated markdown files: |
|
|
|
| File Name | Description | |
|
| ------------------------- | ---------------------------------------------- | |
|
| `profile.md` | Krishnaโs full technical profile and education | |
|
| `goals.md` | Short- and long-term personal goals | |
|
| `chatbot_architecture.md` | System-level breakdown of this AI assistant | |
|
| `personal_interests.md` | Hobbies, cultural identity, food preferences | |
|
| `conversations.md` | Sample queries and expected response tone | |
|
|
|
--- |
|
|
|
## ๐งช How It Works |
|
|
|
1. **User input** is rewritten into subqueries (LLM1) |
|
2. **Retriever** fetches relevant chunks using BM25 and FAISS |
|
3. **Classifier LLM** decides if results are relevant to Krishna |
|
4. **GPT-4o** generates final answer using top-k chunks |
|
5. **Memory is updated** asynchronously with every turn |
|
|
|
--- |
|
|
|
## ๐ฌ Example Queries |
|
|
|
- What programming languages does Krishna know? |
|
- Tell me about Krishnaโs chatbot architecture |
|
- Can this chatbot explain Krishna's work at Virginia Tech? |
|
- What tools has Krishna used for data engineering? |
|
|
|
--- |
|
|
|
## ๐ Setup & Usage |
|
|
|
```bash |
|
# 1. Clone the repo |
|
git clone https://github.com/krishna-creator/krishna-personal-chatbot.git |
|
cd krishna-personal-chatbot |
|
|
|
# 2. Install dependencies |
|
pip install -r requirements.txt |
|
|
|
# 3. Set your API keys (OpenAI, NVIDIA) |
|
export OPENAI_API_KEY=... |
|
export NVIDIA_API_KEY=... |
|
|
|
# 4. Launch the chatbot |
|
python app.py |
|
``` |
|
|
|
--- |
|
|
|
## ๐ฎ Model Stack |
|
|
|
| Purpose | Model Name | Provider | |
|
| ------------------ | ------------------------ | -------- | |
|
| Query Rewriting | `phi-3-mini-4k-instruct` | NVIDIA | |
|
| Scope Classifier | `llama-3-70b-instruct` | NVIDIA | |
|
| Answer Generator | `gpt-4o` | OpenAI | |
|
| Fallback Humor LLM | `mixtral-8x22b-instruct` | NVIDIA | |
|
|
|
--- |
|
|
|
## ๐ Acknowledgments |
|
|
|
- Built as part of Krishna's exploration into **LLM orchestration and agentic RAG** |
|
- Inspired by LangChain, SentenceTransformers, and NVIDIA RAG Agents Course |
|
|
|
--- |
|
|
|
## ๐ License |
|
|
|
MIT License ยฉ Krishna Vamsi Dhulipalla |
|
|