Spaces:
Running
Download docs/PLAN.md from space-cadet/ser: direct link, hf CLI and curl.
- Browser
- Download file 5.63 kB
-
https://huggingface.co/spaces/space-cadet/ser/resolve/main/docs/PLAN.md
- Command line
-
hf download hf://spaces/space-cadet/ser/docs/PLAN.md
-
curl -L -o PLAN.md https://huggingface.co/spaces/space-cadet/ser/resolve/main/docs/PLAN.md
Phase 1 β Foundations
Goal: calibrated, threshold-safe inference with a known latency number. Nothing here needs new infrastructure β it runs on data/checkpoints you already have.
- Export raw softmax scores + true labels for your existing validation
fold into a CSV (
true_label, prob_0..prob_7). python scripts/calibration_fit.py --predictions <csv> --method isotonicβ producesdata/calibration/calibration.jsonand the pre/post reliability diagrams. Use the diagrams as your evidence artifact that calibration actually improved things.- Confirm the app picks it up: start the service, hit
/, check"calibrated": truein the health response. - Tune
THRESHOLD_LOW/THRESHOLD_HIGHin.envagainst your validation set's calibrated confidence distribution β the cascade logic itself (app/inference/cascade.py) doesn't need to change. python scripts/benchmark_latency.py --audio-dir <sample clips>β record p50/p99 indocs/MODEL_CARD_TEMPLATE.md.- Run
scripts/baseline_classical_model.pyonce for the "WavLM beats classical baseline by X points" number β good for a model card / writeup, not on the serving path.
Exit criteria: /predict returns calibrated scores, the cascade
correctly defaults low-confidence predictions to neutral, and you have a
real p50/p99 latency number.
Phase 2 β Input & logging
Goal: chat-safe audio validation, and the start of the retraining data loop.
app/audio/validate.pyandapp/audio/vad.pyare already wired intopredict_from_pathβ tuneMIN_DURATION_SEC,MAX_DURATION_SEC,RMS_SILENCE_FLOORagainst real chat-audio samples if you have any yet, otherwise leave the defaults and revisit after Phase 3's drift check starts firing.- Choose a feature-log backend:
sqliteif the Space has persistent storage,hf_datasetotherwise (.env:FEATURE_LOG_BACKEND,HF_DATASET_REPO). - Before turning logging on, write and publish
docs/CONSENT_RETENTION_POLICY.md(template included β fill in the product-specific parts) and make sure your client sendsconsent=trueonly after real user consent/ToS disclosure is in place. - Build the drift reference once against your training set:
python scripts/build_drift_reference.py --data-csv <training labels csv>.
Exit criteria: requests are validated and VAD-trimmed before scoring; low-confidence requests are logged with review flags; consent policy is published before any real user audio is logged.
Phase 3 β Monitoring & alerting
Goal: know when reality diverges from your training data, automatically.
- Enable
.github/workflows/drift-check.ymlβ set repo secrets (HF_TOKEN,ALERT_WEBHOOK_URL) and variables (HF_DATASET_REPOif using that backend). - Set up a Slack or Discord incoming webhook, put the URL in
ALERT_WEBHOOK_URL. - Expect the drift check to fire early and often β chat audio diverging
from RAVDESS/IEMOCAP/CREMA-D is the expected gap, not a bug. Use early
alerts to tune
MIN_DURATION_SEC/RMS_SILENCE_FLOORrather than silencing the alert. - Start a weekly (or whatever cadence fits) manual review pass on
/admin/review-queue/exportβ export, label, track viaapp/logging_pipeline/review_queue.mark_reviewed.
Exit criteria: a Slack/Discord message fires automatically on real drift or a spiking low-confidence rate; someone is reviewing the queue on a fixed cadence.
Phase 4 β Registry, rollout & session state
Goal: safe promotion path for the next checkpoint, and multi-turn emotion context.
- Every checkpoint pushed to the Hub gets a filled-out model card
(
docs/MODEL_CARD_TEMPLATE.md) β training data version, retrain lineage, per-corpus metrics, latency. - Set
CHALLENGER_MODEL_ID/CHALLENGER_REVISION/CANARY_PCTin.envto test a new checkpoint against a slice of real traffic (seedocs/ROLLOUT.mdfor the full canary β blue-green β shadow playbook). SESSION_BACKEND=memoryworks for a single Space instance out of the box; move toredis(Upstash free tier) once you have >1 replica or want state to survive restarts.- Enable
.github/workflows/ci-eval-gate.yml's actual threshold checks once you have corpus-by-corpus prediction CSVs to gate on (it's a placeholder until then β don't let it silently pass).
Exit criteria: a challenger checkpoint can be promoted through canary β full rollout with a documented rollback path; session-level emotion state is live for multi-turn chats.
Ongoing β once enough labeled chat audio accumulates
- Pull the highest-value examples from the review queue
(
/admin/review-queue/export) into the next retrain set β these are the examples the model already struggled with, not a random sample. - Run
scripts/champion_challenger_eval.pyacross RAVDESS, IEMOCAP, CREMA-D, and the new chat-domain holdout. Promote only if the challenger clears the bar on all four. - Re-run
scripts/benchmark_latency.pyafter any architecture change, not just after accuracy changes.
What this plan deliberately does not solve
See docs/PLAN.md's companion section in the original guide β true
load-balancer-level traffic splitting with SLA-triggered rollback, on-call
paging with escalation, a real sub-10ms streaming feature store, fully
automated retraining triggered off drift alerts, and GPU inference at scale
all genuinely need paid infrastructure. This repo gets you a free,
reasonable approximation of each; it doesn't pretend to replace them.