AI-powered Q&A system for "Truyện Kiều" using advanced RAG techniques with hybrid search, multi-stage reranking, and quote verification.
An intelligent chatbot that answers questions about Vietnam's classic literary masterpiece "Truyện Kiều" (3,254 verses). Built with production-grade RAG architecture optimized for Vietnamese language and classical poetry.
Key Features:
Core: Python 3.10+ • MongoDB Atlas • Google Gemini API
ML/AI: Sentence Transformers (SBERT/E5) • Cross-encoder • RapidFuzz
Framework: Streamlit • PyMongo • Pytest
Architecture Highlights:
# 1. Setup
git clone https://github.com/yourusername/kieu-bot.git
cd kieu-bot
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # Add your MONGO_URI and GOOGLE_API_KEY
# 2. Prepare data
python scripts/01_build_chunks.py
python scripts/02_embed_and_index_mongo.py
# Create Vector Search Index in MongoDB Atlas (use scripts/03_create_mongo_vector_index.js)
# 3. Run
streamlit run app/ui_streamlit.py
Requirements: Python 3.10+, MongoDB Atlas (free tier), Google API key, 4GB RAM
# Character query
"Thúy Kiều là ai?" → Detailed character analysis
# Verse retrieval
"Trích 10 câu đầu" → First 10 verses with line numbers
# Literary analysis
"Phân tích ẩn dụ trong câu 100" → Deep analysis with citations
# Comparison
"So sánh câu 1 với câu 100" → Comparative analysis
| Metric | Value |
|---|---|
| Response Time | ~2-3s |
| Cache Hit Rate | ~40-50% |
| Quote Accuracy | ~95% |
| Retrieval Precision@5 | ~85% |
UI (Streamlit)
↓
Orchestrator → [FAQ|Chat|Poem|Generic|Domain]
↓
RAG Pipeline → Query Expansion → Hybrid Search → Rerank → Generate
↓
MongoDB Atlas + Gemini API + Quote Verifier
Key Components:
orchestrator.py - Intent routing & cachingrag_pipeline.py - Core RAG implementationhybrid_retriever.py - Vector + text search with RRFrerank.py - Multi-model rerankingverifier.py - Quote validation systemkieu-bot/
├── app/ # Core application
│ ├── orchestrator.py # Main coordinator
│ ├── rag_pipeline.py # RAG engine
│ ├── hybrid_retriever.py # Search layer
│ └── ...
├── scripts/ # Data processing
├── tests/ # Unit & integration tests
└── data/ # Raw, interim, chunks
pytest # Run all tests
pytest --cov=app --cov-report=html # With coverage
Current (v1.0): ✅ Core RAG • ✅ Hybrid search • ✅ Quote verification • ✅ UI
Next (v2.0): REST API • Multi-turn dialogue • Analytics • Mobile UI • TTS
[Minh Duc]
GitHub: mindu2kk • Email: minhducphan2005@gmail.com
MIT License
Made with ❤️ for Vietnamese Literature
⭐ Star this repo if you find it useful!
64 commits
Python
89.9%
HTML
8.8%
AI-powered Q&A system for "Truyện Kiều" using advanced RAG techniques with hybrid search, multi-stage reranking, and quote verification.
An intelligent chatbot that answers questions about Vietnam's classic literary masterpiece "Truyện Kiều" (3,254 verses). Built with production-grade RAG architecture optimized for Vietnamese language and classical poetry.
Key Features:
Core: Python 3.10+ • MongoDB Atlas • Google Gemini API
ML/AI: Sentence Transformers (SBERT/E5) • Cross-encoder • RapidFuzz
Framework: Streamlit • PyMongo • Pytest
Architecture Highlights:
# 1. Setup
git clone https://github.com/yourusername/kieu-bot.git
cd kieu-bot
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # Add your MONGO_URI and GOOGLE_API_KEY
# 2. Prepare data
python scripts/01_build_chunks.py
python scripts/02_embed_and_index_mongo.py
# Create Vector Search Index in MongoDB Atlas (use scripts/03_create_mongo_vector_index.js)
# 3. Run
streamlit run app/ui_streamlit.py
Requirements: Python 3.10+, MongoDB Atlas (free tier), Google API key, 4GB RAM
# Character query
"Thúy Kiều là ai?" → Detailed character analysis
# Verse retrieval
"Trích 10 câu đầu" → First 10 verses with line numbers
# Literary analysis
"Phân tích ẩn dụ trong câu 100" → Deep analysis with citations
# Comparison
"So sánh câu 1 với câu 100" → Comparative analysis
| Metric | Value |
|---|---|
| Response Time | ~2-3s |
| Cache Hit Rate | ~40-50% |
| Quote Accuracy | ~95% |
| Retrieval Precision@5 | ~85% |
UI (Streamlit)
↓
Orchestrator → [FAQ|Chat|Poem|Generic|Domain]
↓
RAG Pipeline → Query Expansion → Hybrid Search → Rerank → Generate
↓
MongoDB Atlas + Gemini API + Quote Verifier
Key Components:
orchestrator.py - Intent routing & cachingrag_pipeline.py - Core RAG implementationhybrid_retriever.py - Vector + text search with RRFrerank.py - Multi-model rerankingverifier.py - Quote validation systemkieu-bot/
├── app/ # Core application
│ ├── orchestrator.py # Main coordinator
│ ├── rag_pipeline.py # RAG engine
│ ├── hybrid_retriever.py # Search layer
│ └── ...
├── scripts/ # Data processing
├── tests/ # Unit & integration tests
└── data/ # Raw, interim, chunks
pytest # Run all tests
pytest --cov=app --cov-report=html # With coverage
Current (v1.0): ✅ Core RAG • ✅ Hybrid search • ✅ Quote verification • ✅ UI
Next (v2.0): REST API • Multi-turn dialogue • Analytics • Mobile UI • TTS
[Minh Duc]
GitHub: mindu2kk • Email: minhducphan2005@gmail.com
MIT License
Made with ❤️ for Vietnamese Literature
⭐ Star this repo if you find it useful!
64 commits
Python
89.9%
HTML
8.8%