myanmar-ghost / api_reference.md
amkyawdev's picture
Add docs
723f202 verified
|
Raw
History Blame Contribute Delete
2.16 kB

API Reference

FastAPI Endpoints

Health Check

GET /health

Response:

{
  "status": "healthy",
  "model_loaded": true
}

Predict Sentiment

POST /predict

Request:

{
  "text": "ကျေးဇူးပါ",
  "include_prosody": false
}

Response:

{
  "text": "ကျေးဇူးပါ",
  "sentiment": "positive",
  "confidence": 0.95,
  "probabilities": {
    "negative": 0.01,
    "neutral": 0.02,
    "positive": 0.95,
    "sarcastic": 0.02
  }
}

Batch Predict

POST /predict_batch

Request:

{
  "texts": ["ကျေးဇူးပါ", "မကျေနပ်ပါဗျ"]
}

Python SDK

Installation

pip install myanmar-ghost

Usage

from myanmar_ghost import MyanmarGhost

# Initialize
model = MyanmarGhost()

# Predict
result = model.predict("ကျေးဇူးပါ")
print(result.sentiment)  # "positive"

# Batch predict
results = model.predict_batch([
    "ကျေးဇူးပါ",
    "မကျေနပ်ပါ"
])

Advanced Usage

XAI Explanations

from myanmar_ghost.xai import SHAPExplainer

explainer = SHAPExplainer(model)
shap_values = explainer.explain("ကျေးဇူးပါ")
explainer.visualize(shap_values)

Active Learning

from myanmar_ghost.active_learning import UncertaintySampler

sampler = UncertaintySampler(model)
selected = sampler.select_samples(unlabeled_data, n_samples=100)

CLI Commands

# Train model
python -m src.models.train --train_data data/train.csv --output_dir outputs/models

# Evaluate model
python -m src.models.evaluate --model_path outputs/models/best_model.pt --data_path data/test.csv

# Deploy
bash scripts/deploy_model.sh outputs/models/best_model.pt

Configuration

Environment Variables

Variable Description Default
MODEL_PATH Path to model files outputs/models
HF_TOKEN HuggingFace token None
DEVICE cuda or cpu cuda

Model Config

model:
  name: myanmar_ghost
  hidden_size: 768
  num_layers: 12
  dropout: 0.1