Microsoft·Software Engineer·Technical Phone Screen
- Given a function that returns log-probabilities for the next token given a prefix, implement both greedy decoding and beam search. Greedy should pick the highest log-prob token at each step and stop at EOS or max_len. Beam search should maintain the top-k candidate sequences by cumulative log-probability, expanding all beams each step and pruning back to k. Discuss edge cases like early-finished beams.
“This one took me a minute to even parse.”