fairseq s2t developer on retainer: S2T transformer --max-source-positions 512 (51.2 s at 10 ms shift) — 94-second call recordings silently truncated at frame 512 — second half never transcribed — WER 43.7% vs 8.9% — $95,000 — 3 months — fairseq s2t developer on monthly retainer

fairseq 0.12.2 (Facebook AI Research) • PyTorch 1.12.1 • Python 3.8; S2T transformer ASR; --max-source-positions 512 (default from MuST-C pretrained checkpoint, designed for ≤30 s segments); call center recordings average 94 s (940 feature frames at 10 ms shift); frames 513–940 silently dropped at S2TDataConfig.collate_fn; last 42.8 s of each call not transcribed; WER on full call 43.7% vs 8.9%; fix: --max-source-positions 1024 + fine-tune positional embeddings • Northfield FairSeq S2T Ltd. (5-person ASR company; 3 months; 2.0h)

Northfield FairSeq S2T Ltd. is a 5-person startup building a call center transcription API. Their ASR model uses a fairseq S2T transformer (S2T-Small architecture) pretrained on MuST-C — the multilingual speech translation dataset assembled from TED talk segments. MuST-C segments are uniformly short: the median segment is around 10 seconds, and virtually no segment exceeds 30 seconds, because TED talks are segmented at sentence boundaries. The pretrained S2T-Small checkpoint ships with --max-source-positions 512, which at a 10 ms feature frame shift represents 51.2 seconds — more than enough to cover any MuST-C segment. The team fine-tuned this pretrained checkpoint on 300 hours of in-domain call center audio, reducing WER from 24.3% to 9.1% on their internal test set. They did not change --max-source-positions during fine-tuning because the documentation for the pretrained checkpoint did not call attention to it, and their internal test set was composed of shorter calls (maximum 45 seconds) that happened to fit within the 512-frame limit. Production calls, drawn from a broader customer base, averaged 94 seconds.

# inference_pipeline.py — Northfield FairSeq S2T Ltd. production pipeline
# fairseq 0.12.2; PyTorch 1.12.1; Python 3.8

import torch
import numpy as np
from fairseq import checkpoint_utils, tasks
from fairseq.data.audio.speech_to_text_dataset import get_features_or_waveform

# Loaded model: S2T-Small fine-tuned on call center audio
# --max-source-positions 512 (from MuST-C pretrained checkpoint, never updated)
# Feature extraction: 80-band log-mel, window=25ms, shift=10ms
# 1 second of audio → ~100 feature frames
# 94 second average call → ~940 feature frames
# Encoder positional embedding supports positions 0..511 only

task = tasks.setup_task(cfg)
models, _ = checkpoint_utils.load_model_ensemble(["northfield-s2t-callcenter-v2.pt"], task=task)
model = models[0].eval().cuda()

def transcribe(audio_path: str) -> str:
    features = get_features_or_waveform(audio_path, need_waveform=False)
    # features shape: [T, 80]  — T is total feature frames from full audio
    # For a 94-second call: T = 940

    # S2TDataConfig internally applies max_source_positions at collation:
    #   if len(features) > max_source_positions:
    #       features = features[:max_source_positions]  ← SILENT TRUNCATION
    # This happens inside the data pipeline, not surfaced as a warning or error
    # max_source_positions = 512
    # features[:512] = first 51.2 seconds
    # features[512:] = last 42.8 seconds  ← DISCARDED

    src_tokens = features_to_tokens(features)  # internally clips at 512
    # src_tokens.shape: [1, 512, 80]  — tail 428 frames are gone

    with torch.no_grad():
        hypos = task.inference_step(generator, [model], {"net_input": src_tokens})

    transcript = " ".join(hypo[0]["tokens"] for hypo in hypos)
    return transcript
    # Returns transcription of first 51.2 seconds only
    # Last 42.8 seconds of every call: never transcribed, no error raised

The truncation occurs inside fairseq’s S2TDataConfig data collation stage, which clips all feature sequences to max_source_positions before forming a batch. This is architecturally necessary because the Transformer encoder uses fixed positional embeddings that cannot represent positions beyond the trained maximum. But the clipping is silent — no warning is emitted, no exception is raised, the downstream code receives a valid tensor of shape [1, 512, 80] regardless of how many frames the original audio contained. For a 94-second call, the encoder receives a tensor representing 51.2 seconds of audio and returns transcription tokens for that prefix. The decoder never sees evidence that there was additional audio. The returned transcript appears to be a complete transcript — it ends naturally at a sentence boundary somewhere around the 51-second mark, because that’s where the conversation happened to be at that moment in the audio. There is no visible indication that 42.8 seconds of the call was dropped.

How the silent truncation hides inside a valid WER measurement

# WER analysis — Northfield FairSeq S2T Ltd.
# fairseq 0.12.2; S2T-Small; max_source_positions=512 (51.2s threshold)
#
# Internal test set: 500 calls, max duration 45 seconds (all within 512 frames)
#   WER on test set: 9.1%  ← measured against full reference transcript
#   All calls within max_source_positions; no truncation occurred
#   Fine-tuning validation appeared to work correctly
#
# Production call distribution:
#   p10: 23 seconds  (230 frames)  — no truncation
#   p25: 51 seconds  (510 frames)  — no truncation (just within limit)
#   p50: 78 seconds  (780 frames)  — truncated at frame 512; 268 frames dropped
#   p75: 94 seconds  (940 frames)  — truncated at frame 512; 428 frames dropped
#   p90: 118 seconds (1180 frames) — truncated at frame 512; 668 frames dropped
#
# WER measurement method: compare transcript against full call reference transcript
#   Call duration 23s:  transcript complete; WER 9.0%  ← correct
#   Call duration 51s:  transcript complete; WER 9.2%  ← correct
#   Call duration 78s:  transcript covers 51.2s; reference covers 78s
#                       ~34% of reference words never transcribed; WER 36.1%
#   Call duration 94s:  transcript covers 51.2s; reference covers 94s
#                       ~45% of reference words never transcribed; WER 43.7%
#   Call duration 118s: transcript covers 51.2s; reference covers 118s
#                       ~57% of reference words never transcribed; WER 56.8%
#
# Overall production WER: 29.4%  (mix of short and long calls)
# WER on calls ≤51.2s:   9.1%   ← identical to test set (no truncation)
# WER on calls >51.2s:   43.7%  ← all due to truncation
#
# Customer-visible symptoms:
#   "Transcripts end abruptly mid-sentence around the 50-second mark"
#   "The end of every call is missing from the transcript"
#   "Every transcript seems to cover only the first half of the conversation"
#   "Sentiment analysis on outcome (call resolution at end of call) is always wrong"

Why three months of tuning could not transcribe beyond frame 512

The team received complaints from customers that transcripts were incomplete — call resolution details, mentioned near the end of calls, were always missing from transcripts. They attributed this to low ASR quality on domain-specific vocabulary (compliance terms, product names) and focused tuning on those areas. Each intervention improved WER on the internal short-call test set, but could not change the fact that the encoder was architecturally limited to 512 feature frames of input.

# Month 1: Increased beam size 5 → 20
#   Hypothesis: low WER is due to beam search not exploring enough hypotheses
#   Result: WER on short test set 9.1% → 8.9% (marginal improvement)
#   Production WER: 43.7% → 44.1% (slight degradation; more hypotheses still can't
#   transcribe frames that were never passed to the encoder)
#   Conclusion: "beam size not the issue; more hypotheses barely help"
#
# Month 2: Added 3-gram language model rescoring
#   n-gram LM trained on 2 million call center turn transcripts
#   LM fusion weight α=0.3 at decoder; hallucination rate down 12%
#   WER short test set: 8.9% → 8.5%
#   Production WER: 44.1% → 42.9%
#   Reason: LM rescoring helps quality within the first 51.2s; can't help
#   the 42.8s tail that was clipped before encoder
#   Conclusion: "LM helps but gap from test to production remains large"
#
# Month 3: Retrained S2T on call center data, max-source-positions still 512
#   Added 150 more hours of in-domain data; total 450 hours
#   WER short test set: 8.5% → 7.8% (better in-domain vocabulary coverage)
#   Production WER: 42.9% → 42.1% (improvement only on first 51.2s of long calls)
#   Retainer consultant engaged after 3rd month shows still >40% production WER
#
# Retainer triage (2.0h):
#   Step 1 (0.5h): Stratify test set WER by audio duration
#                  calls ≤51.2s: WER 7.8% (normal)
#                  calls  >51.2s: WER 43.7% (all truncated)
#                  Pattern: WER distribution has two distinct populations
#                           splitting exactly at 51.2 seconds
#   Step 2 (0.5h): Add logging to data pipeline; print len(features) before collation
#                  94s call: features.shape = [940, 80] before collation
#                             input_to_encoder.shape = [512, 80] after collation
#                  512 = max_source_positions; 940 - 512 = 428 frames dropped silently
#   Step 3 (0.5h): Check model config; --max-source-positions 512
#                  MuST-C pretrained checkpoint default; never updated for call center
#                  Average call duration 940 frames >> 512 frame limit
#   Step 4 (0.5h): Fix: set --max-source-positions 1024 (covers up to ~102s calls)
#                  Retrain positional embedding weights for positions 513..1023
#                  Fine-tune for 5 epochs; validate on long-call test set
#                  Production WER after fix: 9.0% (matches short-call WER)
#                  5 engineers × 3 months × $6,333/month = $95,000
#                  Assertion: add check at startup:
#                    max_duration_frames = max(len(get_features(a)) for a in validation_set)
#                    assert max_source_positions >= max_duration_frames

The critical diagnostic step was stratifying WER by audio duration, which revealed a clean bimodal distribution: calls shorter than 51.2 seconds achieved 7.8% WER, while calls longer than 51.2 seconds all clustered around 43.7% WER. The 51.2-second threshold — exactly 512 frames at a 10 ms shift — directly implicated the max-source-positions parameter. Without that stratification, the production WER of ~43% appeared to be a model quality problem. With it, the truncation pattern was unambiguous. The final fix required extending and fine-tuning positional embeddings for positions 513–1023, ensuring the encoder could process the full 102 seconds that covered the 90th-percentile call duration. Hours logged to HourTab with per-session breakdown.

# Fixed fairseq configuration — Northfield FairSeq S2T Ltd.

# fairseq-train configuration change:
#   --max-source-positions 1024    # ← FIX: was 512; covers up to ~102s at 10ms shift
#
# Fine-tuning procedure:
#   1. Expand positional embedding: nn.Embedding(1024, d_model) from nn.Embedding(512, d_model)
#      Copy weights[0:512] from original checkpoint; randomly initialize weights[512:1024]
#   2. Fine-tune on full-length call center data (450 hours) for 5 epochs
#      with learning_rate=1e-4 (lower than original to preserve encoder weights)
#   3. Validate on long-call test set (200 calls, avg 94 seconds)
#
# Startup assertion added to inference pipeline:
import numpy as np
from fairseq.data.audio.speech_to_text_dataset import get_features_or_waveform

MAX_SOURCE_POSITIONS = 1024  # must match --max-source-positions in training config

def validate_max_positions(validation_audio_paths: list, max_positions: int) -> None:
    frame_lengths = []
    for path in validation_audio_paths[:100]:  # sample 100 validation files
        features = get_features_or_waveform(path, need_waveform=False)
        frame_lengths.append(len(features))
    p95_frames = int(np.percentile(frame_lengths, 95))
    assert max_positions >= p95_frames, (
        f"max_source_positions={max_positions} < p95 audio length={p95_frames} frames "
        f"({p95_frames / 100:.1f}s at 10ms shift) — increase --max-source-positions"
    )

# After fix — production results:
# WER on calls ≤51.2s:   7.8%  (unchanged — same quality on short calls)
# WER on calls >51.2s:   9.2%  (was 43.7% — truncation resolved)
# Overall production WER: 9.0%  (was 29.4%)
# Transcripts now cover full call duration including resolution at end of call

Related retainer posts


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 →