The implementation of attention in vision transformers and language transformers differs mainly in the input representations and the sequence lengths.

In language transformers, the input is typically a sequence of discrete tokens, such as words or subwords, represented as one-hot vectors or embeddings. The sequence length can be quite long, up to several thousand tokens in some cases. The attention mechanism is used to selectively attend to different parts of the sequence, allowing the model to learn complex relationships between the tokens and generate output sequences, such as in natural language generation tasks.

In contrast, in vision transformers, the input is usually a set of image patches, each of which is represented as a high-dimensional vector. The sequence length is much shorter compared to language transformers, typically only a few hundred patches. The attention mechanism is used to attend to different patches and capture spatial relationships between them, allowing the model to learn representations that are suitable for downstream tasks, such as object detection or image classification.

Although the input representations and sequence lengths differ, the basic idea of the attention mechanism remains the same in both types of transformers: attend to different parts of the input with varying levels of importance, and use the attended information to generate output representations.
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence