Skip to content
How-to GuideUnreviewed

Run few-shot recognition experiments

Select duration-budgeted training and validation subsets from an extracted feature cache, track Model A and Model B runs under matched annotation budgets, and optionally combine human labels with Phonsa pseudo-labels. Before starting, extract the full frozen feature cache once by following Train the onset/rime recognizer (or Extract XEUS features and train recognizers for XEUS). Experiment subsets reference those cached files without rerunning or unfreezing the encoder.

Select annotation budgets

Always select subsets from the same original feature cache so runs remain comparable across budgets and seeds. Validation uses its own fixed seed (--validation-seed, default 0), keeping the validation split unchanged when you vary --seed for repeated training draws. Because different budgets can pick different recordings, subsets are not guaranteed to be nested, and seeds only break equal-score ties.

Create a subset allowing five minutes of training audio and one minute of validation audio:

uv run --project research/phone-recognition phone-recognition recognizer subset \
  local/data/phone-recognition/onset-rime/manifest.json \
  --output local/data/phone-recognition/few-shot/5m-seed42 \
  --train-minutes 5 \
  --validation-minutes 1 \
  --seed 42

Both partitions use greedy coverage-aware selection within their original splits. Among recordings that fit the remaining budget, selection maximizes newly covered phone labels per second, breaking ties toward less-observed labels with seeded tie-breaking. Recordings remain whole and never exceed the budget, though greedy selection does not guarantee optimal coverage or a minimum count per label. Inspect the saved report (per-label counts and durations, covered totals, missing labels, and labels absent from the source partition) before interpreting an experiment.

Train Model A and track the run

Train Model A on the selected subset and log parameters, budgets, losses, and periodic validation metrics through ml_tracking:

uv run --project research/phone-recognition phone-recognition recognizer train \
  local/data/phone-recognition/few-shot/5m-seed42/manifest.json \
  --config research/phone-recognition/configs/base.toml \
  --runtime infra/runtime/local.toml \
  --title "Few-shot phone recognition" \
  --no-spam-features

The command allocates the experiment and run, prints the local run directory, and keeps checkpoints, training history, and selection records on disk without uploading Dashboard artifacts. Checkpoint events report only their path and size. The tracking endpoint in the runtime config controls Dashboard synchronization, and events stay local when no endpoint is configured. Only local execution is supported.

The default configuration evaluates validation every ten epochs and logs both total PER and content PER (excluding AP and SP). Checkpoint selection uses content PER so pause accuracy cannot mask missed or confused phones. Setting layers = 0 runs a framewise baseline without the temporal Transformer.

Calibrate and train Model B within the same budget

Calibration reads only training recordings present in the target subset, even when --count is larger than the subset size. Model B rejects SPAM projections fitted on other recordings or priors with unknown calibration provenance.

Calibrate a SPAM projection on the five-minute subset manifest:

uv run --project research/phone-recognition phone-recognition calibrate \
  --dataset local/data/phone-recognition/few-shot/5m-seed42/manifest.json \
  --output local/assets/spam/xeus-5m-seed42.pt \
  --count 500

Train Model B on the same subset with that calibrated checkpoint:

uv run --project research/phone-recognition phone-recognition recognizer train \
  local/data/phone-recognition/few-shot/5m-seed42/manifest.json \
  --config research/phone-recognition/configs/base.toml \
  --runtime infra/runtime/local.toml \
  --title "Few-shot phone recognition" \
  --use-spam-features \
  --spam-checkpoint local/assets/spam/xeus-5m-seed42.pt

Use Phonsa to label the larger training pool

You can combine a small human-labeled subset with Phonsa predictions on the remaining training recordings. Validation and test partitions always remain human-labeled: phonsa-pseudo-subset drops unannotated held-out recordings and copies the matching human-labeled samples into the output manifest. Before starting, complete the upstream Phonsa setup in Run phone recognition inference and alignment and prepare a target-free jobs.json for your unannotated pool containing the same phone vocabulary, encoder metadata, and validation/test sample IDs and splits as your human manifest.

  1. Extract frozen features from the unannotated jobs.json:
uv run --project research/phone-recognition phone-recognition recognizer extract \
  local/data/phone-recognition/unlabeled/jobs.json \
  --backbone local/assets/xeus \
  --layer-index -1 \
  --device mps
  1. Export Phonsa inference jobs (jobs.json) and the stable cache ID mapping (id-map.json) from the train split only:
uv run --project research/phone-recognition phone-recognition recognizer phonsa-jobs \
  local/data/phone-recognition/unlabeled/manifest.json \
  --output local/data/phone-recognition/phonsa-jobs \
  --split train
  1. Write an upstream Phonsa inference config file at local/data/phone-recognition/phonsa-jobs/infer.yaml referencing your repository root (<REPO_ROOT>), pretrained Phonsa model directory, and generated jobs.json:
base_config: configs/infer/base.yaml
test_data: <REPO_ROOT>/local/data/phone-recognition/phonsa-jobs/jobs.json
test_sample: []
for_test: 0
output_dir: <REPO_ROOT>/local/data/phone-recognition/phonsa-output
specific_logits_dir: ""
meta_save_filename: train_pseudo
model_dir: <REPO_ROOT>/local/assets/phonsa/Chinese_pretrained_model_Phonsa
model_name: best
language: zh
device: cpu
User_Warning_Checking: false
force_rerun: true
force_rerun_logits: true
phoneme_prediction:
  auto_split_audio_clips: false
  write_into_meta: false
  1. Run upstream Phonsa unsupervised segmentation from local/third_party/phonsa to generate local/data/phone-recognition/phonsa-output/meta/train_pseudo_phoneme_prediction.json:
(cd local/third_party/phonsa && \
  PYTHONPATH=. PHONSA_DEFAULT_CONFIG="" TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD=1 \
  .venv/bin/python bin/unsupervised_phoneme_segmentation.py \
  --config "<REPO_ROOT>/local/data/phone-recognition/phonsa-jobs/infer.yaml")
  1. Merge the human-labeled few-shot manifest with normalized Phonsa predictions on the remaining training recordings:
uv run --project research/phone-recognition phone-recognition recognizer phonsa-pseudo-subset \
  local/data/phone-recognition/unlabeled/manifest.json \
  --human-manifest local/data/phone-recognition/few-shot/5m-seed42/manifest.json \
  --phonsa-meta local/data/phone-recognition/phonsa-output/meta/train_pseudo_phoneme_prediction.json \
  --id-map local/data/phone-recognition/phonsa-jobs/id-map.json \
  --output local/data/phone-recognition/pseudo-mix
  1. Train the recognizer on the combined manifest:
uv run --project research/phone-recognition phone-recognition recognizer train \
  local/data/phone-recognition/pseudo-mix/manifest.json \
  --config research/phone-recognition/configs/ctc.toml \
  --output local/runs/phone-recognition/pseudo-mix \
  --runtime infra/runtime/local.toml \
  --device mps

Resume and compare

Pass --output with the printed run directory and --resume to continue from the last completed epoch under the same tracking identity. You may change total epochs and reporting intervals while keeping the model, optimization settings, subset, and annotation budgets unchanged.

Repeat the workflow for 5, 10, and 30 minutes across multiple training seeds while holding validation fixed. Compare Model A and Model B within each subset before comparing annotation budgets. Run held-out test evaluation on saved checkpoints by using the evaluation command.

Type to search…

↑↓ navigate↵ selectEsc close