Free How much of your firm runs on you? Take the 2-minute Key Man Score.
Lesson reading
0%

Lesson 20 / Unit 6: Model Improvements

Beam Search

Compare greedy paths with a bounded search that aggregates alternative CTC paths.

Several frame paths can collapse to the same digit string. A greedy decoder follows only the largest probability at each frame. A beam decoder keeps alternatives and aggregates paths that represent the same output.

Search State

The lab’s educational decoder stores a state as (text, last_frame_token). Keeping the last token is necessary because appending the same digit after blank differs from repeating it directly.

output = text + (str(token - 1) if token and token != last else '')
key = (output, token)
next_scores[key] = np.logaddexp(next_scores.get(key, -np.inf), score + logp)

After each frame, it groups scores by output prefix and keeps the ten best prefixes. This is a small, inspectable implementation, not an optimized production decoder. Read beam_decode() in probes.py before increasing its width.

Recorded Probe

ReferenceGreedyBeam (width 10)
183183183
Recorded CPU experiment · custom FSDD speaker split · development evidence. Download source and logs.

The probe covers one development example. Agreement with greedy decoding on that example would not make beam search useless; disagreement would not prove it is better. A useful decision requires the fixed evaluation set and decoding-time measurements.

Search Tradeoff

Increasing width retains more alternatives but does more work. It does not add missing acoustic information or enlarge the model’s vocabulary. Start with acoustic probabilities only; vocabulary priors introduce another factor to evaluate separately.

The CTC explanation motivates path aggregation. Compare with Greedy Decoding, and retain paired results using the Evaluation Harness before adding Vocabulary Biasing.

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.

Free guide

Be The 10x Entrepreneur

Get the firm out of your head.

  • 8 chapters
  • 7 worksheets
  • 30 day plan