# API Reference ## FastAPI Endpoints ### Health Check ``` GET /health ``` Response: ```json { "status": "healthy", "model_loaded": true } ``` ### Predict Sentiment ``` POST /predict ``` Request: ```json { "text": "ကျေးဇူးပါ", "include_prosody": false } ``` Response: ```json { "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: ```json { "texts": ["ကျေးဇူးပါ", "မကျေနပ်ပါဗျ"] } ``` ## Python SDK ### Installation ```bash pip install myanmar-ghost ``` ### Usage ```python 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 ```python from myanmar_ghost.xai import SHAPExplainer explainer = SHAPExplainer(model) shap_values = explainer.explain("ကျေးဇူးပါ") explainer.visualize(shap_values) ``` #### Active Learning ```python from myanmar_ghost.active_learning import UncertaintySampler sampler = UncertaintySampler(model) selected = sampler.select_samples(unlabeled_data, n_samples=100) ``` ## CLI Commands ```bash # 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 ```yaml model: name: myanmar_ghost hidden_size: 768 num_layers: 12 dropout: 0.1 ```