Hugging Face Agent Course Practice Test

Access More Questions
What role does attention play in transformer models?
Correct Answer:
It helps models focus on relevant parts of input sequences for better contextual understanding.
Explanation:
Attention in transformer models lets the model decide which parts of the input to emphasize when forming representations for each position. By computing weights over all tokens, it creates a context vector that blends information from the most relevant tokens, enabling better understanding of meaning and relationships, including long-range dependencies. In self-attention, each token uses a query to compare with keys from all tokens and then mixes the corresponding values according to those learned weights. Multiple attention heads let the model capture different kinds of relations at once, enriching the representation. This approach focuses on what matters rather than treating every token the same, and it does not sort tokens or collapse all scores into a single value.

Access more questions from this quiz

Continue to Hugging Face Agent Course Practice Test for more practice questions and the full quiz experience.

Access More Questions