Spaces:
Sleeping
A newer version of the Gradio SDK is available: 6.17.3
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
๐ Table of Contents
- Overview
- Features
- Technology Stack
- How It Works
- Project Structure
- Installation
- Usage
- Environment Variables
- Deployment
- Security
- License
- Contact
๐ 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
# 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
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
# 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
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
- Visit console.groq.com
- Create an account or sign in
- Navigate to API Keys
- Generate new key
- Copy and set as environment variable
๐ฆ Deployment
HuggingFace Spaces
This app is optimized for HF Spaces deployment:
# 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
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.
๐ง Contact
๐ค Acknowledgments
- Groq - LLM Inference
- Gradio - UI Framework
- HuggingFace - Infrastructure
โญ If you find this project useful, please consider giving it a star!