Sentences have different lengths. Matrices don't. Every NLP pipeline hits this wall immediately, and the fix is always the same: pick one length and force every sequence to match it.
Task: write pad_sequences(sequences, max_len, pad_value) that returns a list where every inner list has exactly max_len items.
max_len get pad_value appended until they fit.max_len are cut off at max_len.Which end you pad is a real modelling decision, not a detail. A plain RNN reading left to right finishes on whatever came last, so trailing pad tokens are the final thing it sees — which is exactly why front-padding used to be the norm.