amkyawdev-nlp / README.md
openhands
Enhance: Professional README with badges, TOC, and documentation
8bad5af
---
title: Amkyaw AI NLP
emoji: 🤖
colorFrom: blue
colorTo: gray
sdk: gradio
sdk_version: 5.29.0
python_version: "3.12"
app_file: app.py
pinned: false
license: mit
tags:
- chatbot
- myanmar
- burmese
- nlp
- llama
- groq
- llm
- conversational-ai
- local-ai
---
<div align="center">
<img src="https://huggingface.co/datasets/amkyawdev/AmkyawDev-Dataset/resolve/main/badge.svg" alt="Amkyaw AI Badge">
# 🤖 Amkyaw AI NLP
### မြန်မာစာ AI Chatbot - Powered by Groq & Llama 3.1
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Python: 3.12](https://img.shields.io/badge/Python-3.12+-green.svg)](https://www.python.org/)
[![Gradio: 5.29.0](https://img.shields.io/badge/Gradio-5.29.0+-orange.svg)](https://gradio.app/)
[![Spaces](https://img.shields.io/badge/HuggingFace-Spaces-white.svg)](https://huggingface.co/spaces/amkyawdev/amkyawdev-nlp)
[![Model: Llama-3.1-8b](https://img.shields.io/badge/Model-Llama--3.1--8b--instant-blueviolet.svg)](https://llama.com/)
<p>
<a href="https://huggingface.co/spaces/amkyawdev/amkyawdev-nlp">
<img src="https://img.shields.io/badge/🤗 Open in Spaces-white?style=for-the-badge&logo=huggingface&logoColor=white" alt="Try it on HuggingFace Spaces">
</a>
<a href="https://amkyawdev-amkyawdev-nlp.hf.space">
<img src="https://img.shields.io/badge/🚀 Live Demo-white?style=for-the-badge" alt="Live Demo">
</a>
</p>
</div>
---
## 📖 Table of Contents
- [Overview](#overview)
- [Features](#features)
- [Technology Stack](#technology-stack)
- [How It Works](#how-it-works)
- [Project Structure](#project-structure)
- [Installation](#installation)
- [Usage](#usage)
- [Environment Variables](#environment-variables)
- [Deployment](#deployment)
- [Security](#security)
- [License](#license)
- [Contact](#contact)
</div>
---
## 📝 Overview
Amkyaw AI NLP is a sophisticated conversational AI chatbot specifically designed for Myanmar (Burmese) language interactions. The system combines local knowledge base matching with advanced LLM capabilities to provide intelligent, contextually appropriate responses in Myanmar Unicode text.
### 🎯 Core Objectives
- ✅ Provide natural conversational experiences in Myanmar language
- ✅ Leverage local dataset for accurate responses to common queries
- ✅ Utilize Groq-powered Llama 3.1 for complex reasoning tasks
- ✅ Demonstrate production-grade AI chatbot architecture
---
## ✨ Features
| Feature | Description |
|---------|-------------|
| 🗣️ **Myanmar Language Support** | Full Unicode support for Burmese text input and output |
| 🔍 **Intelligent Matching** | Fuzzy search with 85% similarity threshold |
| ⚡ **Groq Integration** | High-performance inference with Llama 3.1 8B |
| 🎨 **Modern UI** | Dark-themed Gradio interface |
| 🔄 **Streaming Responses** | Real-time token-by-token output |
| 📚 **Extensible Knowledge** | CSV-based conversation database |
| 🛡️ **Error Handling** | Graceful fallback responses |
---
## 🛠️ Technology Stack
### Core Technologies
| Technology | Version | Purpose |
|------------|---------|---------|
| **Python** | 3.12+ | Runtime environment |
| **Gradio** | 5.29.0 | Web UI framework |
| **Groq** | Latest | LLM inference engine |
| **Pandas** | Latest | Data processing |
### AI/ML Libraries
| Library | Purpose |
|---------|---------|
| **Llama 3.1 8B Instant** | Large language model |
| **SequenceMatcher** | Fuzzy string matching |
---
## ⚙️ How It Works
### Architecture Flow
```
User Input → Fuzzy Match Check → [Match Found?] → Yes → Return Local Response
↓ No
Groq API (Llama 3.1) → Process → Streaming Response
```
### Response Logic
#### Step 1: Local Knowledge Base
- System loads conversation pairs from CSV dataset
- Implements fuzzy matching with SequenceMatcher
- Returns matching response if similarity > 85%
#### Step 2: LLM Fallback
- For unmatched queries, uses Groq API
- Converts chat history to Llama format
- Generates contextual response
---
## 📁 Project Structure
```
amkyawdev-nlp/
├── app.py # Main Gradio application
├── requirements.txt # Python dependencies
├── README.md # This file
├── LICENSE # MIT License
├── .gitignore # Git ignore rules
└── .gradioignore # Gradio ignore rules
```
### File Descriptions
| File | Description |
|------|-------------|
| `app.py` | Core application with UI and AI logic |
| `requirements.txt` | pip dependencies |
| `README.md` | Documentation |
| `LICENSE` | MIT License |
---
## 🚀 Installation
### Prerequisites
- Python 3.12+
- pip (包管理器)
### Local Setup
```bash
# Clone the repository
git clone https://huggingface.co/spaces/amkyawdev/amkyawdev-nlp.git
cd amkyawdev-nlp
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/macOS
# venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Set environment variable
export GROQ_API_KEY=your_api_key_here
# Run the application
python app.py
```
### Docker Deployment
```dockerfile
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY app.py .
EXPOSE 7860
CMD ["python", "app.py", "--share"]
```
---
## 💻 Usage
### Running Locally
```bash
# Set your Groq API key
export GROQ_API_KEY=your_key_here
# Launch the app
python app.py
```
The app will be available at `http://localhost:7860`
### Using on HuggingFace Spaces
Visit: **https://amkyawdev-amkyawdev-nlp.hf.space**
### API Example
```python
import requests
response = requests.post(
"https://amkyawdev-amkyawdev-nlp.hf.space/predict",
json={"data": ["ဟောက်ပန်းပါ"]}
)
print(response.json())
```
---
## 🔐 Environment Variables
| Variable | Required | Description |
|----------|----------|-------------|
| `GROQ_API_KEY` | Yes | Groq API authentication token |
### Getting Your Groq API Key
1. Visit [console.groq.com](https://console.groq.com)
2. Create an account or sign in
3. Navigate to API Keys
4. Generate new key
5. Copy and set as environment variable
---
## 📦 Deployment
### HuggingFace Spaces
This app is optimized for HF Spaces deployment:
```bash
# HF Spaces automatically handles:
# - Container management
# - HTTPS enforcement
# - Traffic distribution
# - Sleep scheduling (after 48h inactivity)
```
### Environment Details
| Setting | Value |
|---------|-------|
| Runtime | Gradio 5.29.0 |
| Python | 3.12 |
| Hardware | CPU Basic |
| Sleep Time | 48 hours |
---
## 🔒 Security
### Best Practices Implemented
- ✅ API keys stored as secrets (not in code)
- ✅ HTTPS enforced by Spaces
- ✅ Input validation
- ✅ Error message localization
- ✅ Rate limiting (via Spaces)
### Recommendations
- Never commit API keys to version control
- Rotate keys periodically
- Monitor usage in Groq dashboard
---
## 📜 License
<div align="center">
[MIT License](LICENSE)
Copyright (c) 2024 amkyawdev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
</div>
---
## 📧 Contact
<div align="center">
**amkyawdev**
<a href="https://huggingface.co/amkyawdev">
<img src="https://img.shields.io/badge/HuggingFace-Profile-blue?style=for-the-badge&logo=huggingface" alt="HuggingFace Profile">
</a>
</div>
---
<div align="center">
### 🤝 Acknowledgments
- [Groq](https://groq.com/) - LLM Inference
- [Gradio](https://gradio.app/) - UI Framework
- [HuggingFace](https://huggingface.co/) - Infrastructure
</div>
---
<div align="center">
⭐ If you find this project useful, please consider giving it a star!
</div>