Question 5 of 5

Why does a model need padding and an attention mask?

One request takes two tokens and another takes three. The program sends them together and adds a filler position to the shorter row.

Put two phrases in a table to process them together. One has three words and the other has five. Add two placeholder cells to the short row. The rows now have the same length, but the placeholders say nothing about the sentence. A mask marks those positions so the model can skip them when computing attention.

WHERE TO START

Two phrases have different lengths. Which positions would you add to make them equal?

What to know before this question
Topic example · Prediction error

Move the prediction closer to the target and compare the numbers.

target = 4
prediction = 7
print(abs(target - prediction))
Line notes
  1. Set the known target value.
  2. Set one prediction.
  3. Print the distance from the prediction to the target.

How would you rate your understanding?

This is your self-assessment. Progress is saved in this browser.

Not rated yet

← Back to How a model works