Technical Overview
Evaluating speech adaptation using only the training loss can lead to overfitting on accent patterns. We need to calculate and track the Word Error Rate (WER) and Character Error Rate (CER) on accented test sets at regular evaluation intervals.
Affected Modules
- File:
src/train.py
- Target Classes:
Seq2SeqTrainer and its evaluation hooks.
Acceptance Criteria
- Automated Computation: Calculates WER and CER metrics automatically at each designated
eval_steps interval.
- Performance Constraints: Metric evaluation must not increase total step duration by more than 10%.
- Accurate Tracking: Decodes model tokens back to clean string predictions to calculate error rates, ignoring special tokens.
Proposed Implementation Approach
Implement a metric calculation function and register it within the trainer constructor:
import evaluate
import numpy as np
wer_metric = evaluate.load("wer")
cer_metric = evaluate.load("cer")
def compute_metrics(pred):
pred_ids = pred.predictions
label_ids = pred.label_ids
# Replace -100 to ignore pad tokens
label_ids[label_ids == -100] = tokenizer.pad_token_id
pred_str = tokenizer.batch_decode(pred_ids, skip_special_tokens=True)
label_str = tokenizer.batch_decode(label_ids, skip_special_tokens=True)
wer = wer_metric.compute(predictions=pred_str, references=label_str)
cer = cer_metric.compute(predictions=pred_str, references=label_str)
return {"wer": wer, "cer": cer}
Severity & Priority
- Severity: Medium (Improves validation monitoring)
- Priority: P2
Technical Overview
Evaluating speech adaptation using only the training loss can lead to overfitting on accent patterns. We need to calculate and track the Word Error Rate (WER) and Character Error Rate (CER) on accented test sets at regular evaluation intervals.
Affected Modules
src/train.pySeq2SeqTrainerand its evaluation hooks.Acceptance Criteria
eval_stepsinterval.Proposed Implementation Approach
Implement a metric calculation function and register it within the trainer constructor:
Severity & Priority