Sequence models practice problems
18 problems · 0 solved
Sequence models process data where order matters, such as text, speech and sensor readings. Before transformers, recurrent networks read a sequence one step at a time and carried a hidden state forward, a bit like reading a sentence while keeping a running summary in your head. These ideas still matter for speech, streaming and newer state-space models. In these problems you will run a vanilla RNN, implement one step of an LSTM cell and a GRU cell, pick the last real hidden state of each sequence, build teacher-forcing decoder inputs, compute Bahdanau additive attention, backpropagate through time in a linear RNN, decode a CTC output greedily, compute the CTC loss with the forward algorithm in log space, decode the best HMM path with Viterbi, and compute HMM state posteriors with forward-backward. Start with the Easy problems on the vanilla RNN, teacher forcing and CTC greedy decoding. Then do LSTM, GRU, attention and Viterbi, and finish with backprop through time, CTC loss and forward-backward. Speech and time-based products still use these models, and interviewers use them to test your grasp of recurrence and dynamic programming.
Easy 5
Medium 7
- Implement one step of an LSTM cellPro
- Run one step of a GRU cell on a batchPro
- Decode the best HMM path with ViterbiPro
- Compute Bahdanau additive attentionPro
- Run a stacked (multi-layer) RNN over a sequencePro
- Carry RNN state through padding with a maskPro
- Compute a Luong attention step with dot or general scoringPro
Hard 6
- Backpropagate through time in a linear RNNPro
- Compute the CTC loss with the forward algorithm in log spacePro
- Compute HMM state posteriors with forward-backwardPro
- Run a bidirectional RNN on padded sequences of different lengthsPro
- Unroll a seq2seq decoder with scheduled teacher forcingPro
- Implement the backward pass of one LSTM cell stepPro