arabic-sentiment-lora-deploy

Deploy bundle for the arabic-sentiment-mlops LoRA sentiment classifier. Not a standalone model card — this repo holds the artifacts that the FastAPI serving container fetches at build time. The model card lives on the running Space.

Live demo: https://prajnashetty-arabic-sentiment-lora.hf.space — try GET /health and POST /predict (Arabic text in; positive / negative / neutral + confidence out).

What's in this repo

Path Size Purpose
models/arabert-lora-v1/ 2.8 MB LoRA adapter weights + tokenizer + labels. Used as the filesystem fallback if registry resolution fails in-container.
mlflow.db 892 KB SQLite-backed MLflow registry. Holds the arabert-lora v1 registered model + its run lineage.
mlruns/1/models/m-f9cac40424504a5a91d9449f38f5bd7c/ 523 MB MLflow 3.x logged-model artefacts — the pyfunc bundle (MLmodel, python_model.pkl, nested LoRA weights).

Total: 27 files, ~525 MB. LFS-tracked binaries handled by HF Hub automatically.

How it's consumed

The container's Dockerfile (cache-warm stage) fetches the whole repo via huggingface_hub.snapshot_download:

from huggingface_hub import snapshot_download

snapshot_download(
    "PrajnaShetty/arabic-sentiment-lora-deploy",
    repo_type="model",
    local_dir="/opt/deploy",
)

The runtime stage COPYs /opt/deploy into /app/, applies a build-time SQL rewrite over six columns in mlflow.db (the absolute build-host paths get retargeted to /app/…), and ships a torch compatibility shim that maps MPS-tagged tensor storage to CPU at deserialize time (the LoRA was logged on Apple Silicon; the runtime torch wheel is Linux CPU-only).

See Dockerfile and ADR-0008 in the source repo for the full mechanics.

Model card

The model itself is an AraBERT v2 classifier fine-tuned with LoRA on the HARD dataset for 3-class sentiment (positive / negative / neutral). Macro F1 on the held-out test split: 0.838 (positive 0.91, negative 0.85, neutral 0.76). Dialect breakdown (per Phase 5 in the source repo): 0.80 macro F1 on Gulf vs 0.85 on MSA — a ~5-point gap the repo documents rather than hides.

Hardware constraints: trained on Apple Silicon MPS (~80 min wall); served on CPU at ~600 ms per /predict call on HF Spaces' free tier (2 vCPU / 16 GB RAM).

Loading the LoRA outside the Space

If you want to use just the LoRA adapter without the FastAPI container:

from peft import PeftModel
from transformers import AutoTokenizer, AutoModelForSequenceClassification
from huggingface_hub import snapshot_download

bundle = snapshot_download(
    "PrajnaShetty/arabic-sentiment-lora-deploy",
    repo_type="model",
    allow_patterns="models/arabert-lora-v1/*",
)
base = AutoModelForSequenceClassification.from_pretrained(
    "aubmindlab/bert-base-arabertv2", num_labels=3
)
model = PeftModel.from_pretrained(base, f"{bundle}/models/arabert-lora-v1")
tokenizer = AutoTokenizer.from_pretrained(f"{bundle}/models/arabert-lora-v1")

Source

License

MIT. The base model (aubmindlab/bert-base-arabertv2) and the HARD dataset are under their own licenses; please check there if you intend to use this bundle outside personal / academic contexts.

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for PrajnaShetty/arabic-sentiment-lora-deploy

Adapter
(2)
this model