Role of decoder in Transformer?
Yes, you are right in your understanding of the role of the decoder.
However, your use of &quot;query&quot; here, while somewhat technically correct, seems a bit strange. You are referring as &quot;query&quot; to the partially decoded sentence. While the partially decoded sentence is actually used as query in the first multihead attention block, people normally do not refer to it as &quot;query&quot; when describing stuff from the conceptual level of the decoder.
About needing the decoder in classification or regression tasks: the decoder is used when the output of the model is a sequence. If the output of the model is a single value, e.g. for a classification task or a single-value regression task, the encoder would suffice. If you want to predict multiple values of a time series, you should probably use a decoder that lets you condition not only on the input but also on the partially generated output values.