Lesson 11 / Unit 3: First Recognizer
Greedy Decoding
Convert frame scores into strings, then test repeated digits and padded frames explicitly.
Greedy decoding takes the most likely token at each frame and collapses the resulting path. It is easy to inspect and makes a useful baseline. It does not necessarily find the output string with the greatest total probability across all paths.
Decode Once
def collapse(path): return ''.join(VOCAB[v] for i, v in enumerate(path) if v and (i == 0 or v != path[i - 1]))
path = log_probs.argmax(-1)[:, batch_index].tolist()text = collapse(path[:output_length])Truncate to the real output length before collapsing. Otherwise padded frames can add characters that were never part of the utterance. The blank check uses the token ID, so the spoken zero is preserved.
Edge Cases
assert collapse([8, 8, 0, 8]) == '77'assert collapse([1, 1, 0, 1]) == '00'assert collapse([0, 0, 0]) == ''assert collapse([8, 8, 8]) == '7'These cases inspect semantics, not model quality. Run them before training; an incorrect decoder can make a good model look broken or conceal repeated-digit failures.
Inspect Errors
Keep reference, hypothesis and source filenames for every decoded sequence. The lab writes them into results.json. An empty output is a real hypothesis and must remain in the scoring denominator.
During the short pilot, most early validation outputs were empty even while training loss decreased. This is why Learning Curves pairs loss with decoded errors.
The CTC path explanation clarifies why a best path and a best collapsed string can differ. Beam Search explores that difference later; first run the Training Loop.
We do this work for teams shipping voice agents: Self-Hosted Voice Agent .
Edit this lesson on GitHub ↗Discussion
Questions, corrections and war stories welcome. Sign in with GitHub to comment.