A text encoder converts textual input into an internal representation. In a transformer, it receives inputs and builds representations that support tasks such as sentence classification and named entity recognition. section 3.1
Figure 3.1 The transformer architecture (Source: “Attention Is All You Need” paper)
Use the transformer architecture to locate the encoder alongside the decoder and understand their distinct roles. section 3.1
A transformer encoder combines several processing elements:
- Input embeddings convert tokens into dense numerical vectors, while positional encodings preserve token order during parallel processing. section 3.1 section 3.4
- Multiple identical encoder layers use multi-head attention to capture relationships between tokens and feed-forward networks to transform the results. section 3.1
- Self-attention assigns different importance to words while representing each word, including words separated by long distances. section 3.1 section 3.4
Using a text encoder with CLIP
CLIP uses a transformer-based text encoder and a separate image encoder. A processor receives labels such as cat, dog, tiger, and train alongside an image; the model computes image-text scores, softmax converts them to probabilities, and the highest-scoring label is selected. For the demonstrated dog image, the result is dog. section 6.2.2




















