We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
hard
end_to_end
Beam Search
Implement beam search decoding.
Given a log-probability matrix where log_probs[t][v] is the log-probability
of token v at time step t, find the top-k highest-scoring sequences.
At each time step:
- Expand each beam with all possible next tokens
-
Score each candidate:
beam_score + log_probs[t][v] -
Keep only the top
beam_widthcandidates
Input:
-
log_probs: shape(T, V)— log-probabilities at each time step -
beam_width: number of beams to keep (int)
Output: A dict with:
- “sequences”: the best sequence (list of token indices, length T)
- “score”: the log-probability score of the best sequence (scalar)
Hints
beam-search
decoding
sequence-generation
search
Sign in to attempt this problem and view the solution.