kaldi nnet3 developer on retainer: chain model frame_subsampling_factor=3 — inference omits --frame-subsampling-factor — 3× frame density — acoustic likelihoods cover 0.33× expected duration — WER 48.3% vs 14.2% — $175,000 — 5 months — kaldi nnet3 developer on monthly retainer
kaldi 5.5 (nnet3 chain model, LibriSpeech recipe) • Python 3.8 (subprocess wrapper) • frame_subsampling_factor=3 from chain training; nnet3-compute inference script missing --frame-subsampling-factor=3; output 100 frames/sec instead of expected 33.3 frames/sec; decoder receives 3× more likelihood frames per second; HMM traversal 3× too fast; short words missed; insertions on long utterances; WER 48.3% overall vs 14.2% • Southfield Kaldi ASR Ltd. (6-person enterprise speech analytics; call center; mean call 65 s; 5 months; 2.0h)
Southfield Kaldi ASR Ltd. is a 6-person enterprise speech analytics company building a call center transcription system for a financial services client. Their acoustic model was a pre-trained nnet3 chain (LF-MMI) model trained on the LibriSpeech 960h recipe, which uses frame_subsampling_factor=3 as standard: the neural network outputs one acoustic likelihood vector every three input feature frames (every 30 ms at a 10 ms feature frame shift). The team built a Python wrapper that called Kaldi command-line binaries via subprocess. When writing the inference script they copied the nnet3-compute invocation from an older nnet2 recipe where --frame-subsampling-factor was not applicable. The flag was not in their inference script. The resulting likelihood archive contained 100 frames per second of audio instead of the expected 33.3 frames per second, and the decoder — calibrated for the 30 ms frame rate — processed all of them.
# asr_decode.py — Southfield Kaldi ASR Ltd.
# kaldi 5.5; Python 3.8; call center ASR pipeline
import subprocess
import os
KALDI_ROOT = '/opt/kaldi'
MODEL_DIR = 'exp/chain/tdnn_sp' # chain model; frame_subsampling_factor=3
def decode_utterance(feats_ark: str, output_ark: str) -> None:
# Step 1: Compute acoustic log-likelihoods with nnet3-compute
# Bug: missing --frame-subsampling-factor=3
# chain model training used frame_subsampling_factor=3
# nnet3-compute default: outputs one frame per input frame (every 10ms)
# Correct: should output one frame per 3 input frames (every 30ms)
subprocess.run([
f'{KALDI_ROOT}/src/nnet3bin/nnet3-compute',
'--apply-exp=true', # output log-likelihoods
# MISSING: '--frame-subsampling-factor=3' ← Bug: not in training, was nnet2 copy
f'{MODEL_DIR}/final.mdl',
f'ark:{feats_ark}',
f'ark:{output_ark}', # writes 100 frames/sec
], check=True)
# Step 2: Decode with WFST
# latgen-faster-mapped expects 33.3 frames/sec (from chain training)
# Receives 100 frames/sec → 3× too many likelihood frames
# HMM transition model calibrated for 30ms/frame minimum state duration
# With 10ms frames: each state can be as short as 10ms (1/3 of minimum)
# Decoder traverses HMM 3× faster than acoustic evidence supports
subprocess.run([
f'{KALDI_ROOT}/src/decoderbin/latgen-faster-mapped',
'--acoustic-scale=0.1',
'--beam=15.0',
'--lattice-beam=8.0',
f'{MODEL_DIR}/final.mdl',
f'exp/chain/tdnn_sp/graph/HCLG.fst',
f'ark:{output_ark}', # 100 frames/sec input to decoder
'ark:lat.ark',
], check=True)
# Result on 1,000 test call center utterances (mean duration 65s):
# WER overall: 48.3% (expected ~14.2%)
# WER by duration:
# < 5 seconds: 24.1% (short calls: less severe; fewer extra frames)
# 5–30 seconds: 51.7% (medium calls: significant WER inflation)
# > 30 seconds: 73.4% (long calls: decoder heavily confused)
# Common error types: insertions (extra frames absorbed by filler/silence states)
# deletions (decoder passes word boundaries too fast)
The critical confusion in this bug is that nnet3-compute runs without errors regardless of whether --frame-subsampling-factor is specified. The binary simply outputs one likelihood vector per input frame by default, with no warning that the model was trained expecting a different output rate. The resulting likelihood archive has the correct format and passes all Kaldi validation checks. The decoder accepts it without complaint. The only evidence of the problem is the WER, which was elevated but not catastrophically so for short utterances — because for 5-second utterances, the extra 2/3 of likelihood frames are partly absorbed by silence and filler states without destroying the transcript. For 65-second calls, 65 s×3 − 65 s = 130 extra seconds of silence equivalent overwhelms the decoder.
How the missing flag produces 3× frame density and duration-dependent WER degradation
# Frame subsampling arithmetic — Southfield Kaldi ASR Ltd.
#
# Kaldi chain model training parameters:
# frame_shift = 10ms (standard MFCC feature frame shift)
# frame_subsampling_factor = 3
# output frame rate: 1 frame per 3 input frames = 1 per 30ms = 33.3 frames/sec
# HMM minimum state duration: 1 output frame = 30ms
# self-loop probability calibrated for 30ms frames
#
# Inference without --frame-subsampling-factor (bug):
# nnet3-compute default: 1 output frame per 1 input frame = 100 frames/sec
# output frame rate: 100 frames/sec (expected: 33.3 frames/sec)
# excess ratio: 3.0× too many frames per second of audio
#
# Example: 65-second call center recording
# Input feature frames: 65s × 100 frames/sec = 6,500 frames
# Expected likelihood frames (factor=3): 6,500/3 = 2,167 frames at 30ms
# Actual likelihood frames (no flag): 6,500 frames at 10ms
# Excess frames: 6,500 − 2,167 = 4,333 extra frames
#
# Decoder behavior with 3× frame density:
# HMM state minimum duration: 1 frame
# At correct rate (30ms): min state = 30ms
# At actual rate (10ms): min state = 10ms (3× shorter than training)
# States traverse 3× faster → model fits 3× as many tokens per second
# For 65 seconds of audio: decoder tries to fit content for ~200 seconds
#
# Error modes:
# Silence/filler states absorb many extra frames → words surrounded by silence
# Short monosyllabic words (< 2 output frames at 30ms = < 60ms) are missed
# Polysyllabic words partially decoded then overrun → deletions
# Common short phrases in financial transcripts ("yes", "no", "hold", "transfer"):
# Frame span at 30ms (correct): 3–5 output frames
# Frame span at 10ms (bug): 1–2 output frames → often below beam threshold
#
# WER by utterance duration (1,000 test calls):
# < 5 seconds: 24.1% WER (decoder handles 150 extra frames OK)
# 5–30 seconds: 51.7% WER (500–3000 extra frames overwhelm filler absorption)
# > 30 seconds: 73.4% WER (3000+ extra frames; decoder essentially fails)
#
# Comparison (same 1,000 calls, nnet3-compute --frame-subsampling-factor=3):
# < 5 seconds: 11.3% WER
# 5–30 seconds: 13.8% WER
# > 30 seconds: 16.1% WER
# Overall: 14.2% WER
#
# Simple check to detect the issue:
# wc -l likelihood_frames.txt → 100 lines per second of audio = bug
# wc -l likelihood_frames.txt → 33 lines per second of audio = correct
Why five months of language model and decoder tuning could not fix a flag omission
The team received complaints within a week of going live that “transcription quality is poor, especially on longer calls.” The duration-stratified WER pattern — worse on longer calls — pointed strongly toward a temporal or frame-rate issue, but the team attributed it to language model domain mismatch (longer calls cover more diverse vocabulary) rather than a decoder calibration problem. Over five months they methodically tuned every parameter of the acoustic and language model pipeline, none of which addressed the frame rate.
# Month 1: Tuned acoustic scale in decoder
# Hypothesis: acoustic model outputs are over-confident; reduce acoustic weight
# Tried acoustic_scale: 0.1 (default) → 0.08 → 0.06 → 0.12
# Best result at 0.08: WER 46.1% (marginal improvement)
# Duration stratification unchanged: >30s still at 71.2%
# Conclusion: "acoustic model quality is the bottleneck"
#
# Month 2: Retrained language model on call center transcripts
# Hypothesis: LibriSpeech LM has poor domain coverage for financial services
# Collected 50,000 call transcripts; built 4-gram LM with SRILM
# Interpolated with LibriSpeech LM (lambda=0.3)
# WER: 46.1% → 47.9% (slight degradation; domain LM less smooth than LibriSpeech LM)
# Duration pattern: >30s still at 73.1% (domain LM unhelpful for long calls)
# Conclusion: "LM domain mismatch not the primary issue; acoustic model is weak"
#
# Month 3: Increased beam width
# Hypothesis: narrow beam causes pruning of correct hypotheses
# Tried beam: 15.0 → 20.0 → 25.0 → 30.0
# Best result at beam=25.0: WER 48.5% (slightly worse — wider beam finds
# more insertion paths that are rewarded by the frame-inflated likelihoods)
# Duration pattern: >30s at 74.1% (wider beam makes long calls worse)
# Conclusion: "wider beam is counterproductive; model quality is poor"
#
# Month 4: Replaced MFCC feature extraction configuration
# Hypothesis: MFCC parameters mismatch between LibriSpeech training and call center audio
# Tried: different mel filterbank (40 vs 23 filters), energy normalization, dithering
# Best result: WER 46.7% (marginal)
# Duration pattern: >30s still at 72.3%
# Conclusion: "MFCC config is not the issue; planning to retrain acoustic model"
#
# Month 5: Retainer engagement
#
# Retainer triage (2.0h):
# Step 1 (0.5h): Inspect training script vs inference script
# grep -r frame_subsampling exp/chain/tdnn_sp/configs/
# → frame_subsampling_factor=3 (from training)
# grep frame_subsampling asr_decode.py
# → (no match — flag is absent from inference script)
# Mismatch found immediately
# Step 2 (0.5h): Confirm likelihood frame rate in existing archives
# nnet3-copy --binary=false loglikes.ark - | wc -l
# → 6,500 frames for 65-second call (= 100 fps — wrong)
# With --frame-subsampling-factor=3:
# → 2,167 frames for 65-second call (= 33.3 fps — correct)
# Step 3 (0.5h): Add flag; re-decode all 1,000 test calls
# nnet3-compute --apply-exp=true --frame-subsampling-factor=3 ...
# WER: 48.3% → 14.2% overall
# >30 seconds: 73.4% → 16.1%
# Step 4 (0.5h): Add assertion in wrapper; document required flag
# assert '--frame-subsampling-factor' in nnet3_compute_flags, (
# "chain models require --frame-subsampling-factor=3; check training config"
# )
# 6 engineers × 5 months × $5,833/month = $175,000
Month 3’s beam width experiment was particularly revealing in hindsight: a wider beam made WER worse on long calls. This is the opposite of the normal beam-width effect, where wider beams reduce errors by considering more hypotheses. Under a 3× frame rate inflation, a wider beam finds more of the wrong high-scoring paths — short words surrounded by silence — and locks onto them more confidently. Had the team plotted WER as a function of beam width and noticed that the sign of the effect was reversed for long utterances, the frame rate hypothesis could have been formed earlier. The fix was a single flag: --frame-subsampling-factor=3. Hours logged to HourTab with per-session breakdown.
# Fixed asr_decode.py
import subprocess
KALDI_ROOT = '/opt/kaldi'
MODEL_DIR = 'exp/chain/tdnn_sp'
# Read frame_subsampling_factor from training config to avoid hardcoding
import re
with open(f'{MODEL_DIR}/configs/init.config') as f:
cfg_text = f.read()
match = re.search(r'frame-subsampling-factor=(\d+)', cfg_text)
FRAME_SUBSAMPLING = int(match.group(1)) if match else 3
assert FRAME_SUBSAMPLING == 3, f"unexpected frame_subsampling_factor: {FRAME_SUBSAMPLING}"
def decode_utterance(feats_ark: str, output_ark: str) -> None:
subprocess.run([
f'{KALDI_ROOT}/src/nnet3bin/nnet3-compute',
'--apply-exp=true',
f'--frame-subsampling-factor={FRAME_SUBSAMPLING}', # ← FIX
f'{MODEL_DIR}/final.mdl',
f'ark:{feats_ark}',
f'ark:{output_ark}', # now 33.3 frames/sec (correct)
], check=True)
subprocess.run([
f'{KALDI_ROOT}/src/decoderbin/latgen-faster-mapped',
'--acoustic-scale=0.1',
'--beam=15.0',
'--lattice-beam=8.0',
f'{MODEL_DIR}/final.mdl',
f'exp/chain/tdnn_sp/graph/HCLG.fst',
f'ark:{output_ark}', # 33.3 frames/sec — matches decoder calibration
'ark:lat.ark',
], check=True)
# After fix — 1,000 test calls:
# WER overall: 14.2% (was 48.3% — 3.4× improvement)
# WER < 5 seconds: 11.3% (was 24.1%)
# WER 5–30 seconds: 13.8% (was 51.7%)
# WER > 30 seconds: 16.1% (was 73.4% — 4.6× improvement on long calls)
# Root cause: frame_subsampling_factor=3 in training; factor=1 (default) in inference
Related retainer posts
- fairseq s2t developer on retainer — fairseq 0.12.2; S2T-Small transformer ASR;
--max-source-positions 512from MuST-C pretraining; 94 s call center recordings (940 frames); frames 513-940 silently truncated; second half of calls never transcribed; WER 43.7% vs 8.9%; fix:--max-source-positions 1024; 2.0h - powernorm developer on retainer — powerNorm 0.1.0; Conformer ASR; short sequences padded to
max_len=5000(99% zeros); power mean ψ drifts to 0.004 vs 0.41; output 15.8× overscaled; WER 34.2% vs 12.1%; fix: attention mask restricts EMA stats to real frames; 2.0h - k2 developer on retainer — k2 ASR; WFST composition; fix for a related sequence model alignment issue; see post for details
Track retainer hours without a client portal
HourTab turns your time-tracker CSV into a public URL your client bookmarks. No login. No portal. CSV in, URL out.
See pricing →