The rapid advancement of Large Language Models (LLMs) such as GPT, BERT, and LLaMA is built upon one key innovation: the Transformer architecture. The Transformer has become the backbone of modern natural language processing (NLP).
What is Transformer?
The Transformer is a sequence-to-sequence architecture originally designed for machine translation. Transformers use self-attention to process all tokens in parallel.
It has two major components:
Encoder → processes and contextualizes input.
Decoder → generates or transforms output.
Types of Transformers
Encoder-only models → BERT (context understanding, classification).
Decoder-only models → GPT (causal language modeling, text generation).
Encoder–Decoder models → T5, BART (translation, summarization, sequence-to-sequence).
1. Embeddings: Numerical Representation of Tokens
Transformers operate on continuous vectors, not raw text. Thus, text must be transformed into dense vector embeddings.
Steps
Tokenization
User writes:“I ate an apple.”
“Apple released a new iPhone.”
Text → split into tokens.
Sentence 1 → [I, ate, an, apple]
Sentence 2 → [Apple, released, a, new, iPhone]
Embedding Lookup
Each token is converted to a dense vector."apple" → [0.12, -0.87, 0.45, ...]
“iPhone" → [1.23, 0.65, -0.44, ...]
Positional Encoding
Transformers don’t know the order of words because self-attention looks at all tokens in parallel. For example: “I ate an apple” vs “Apple ate I” → same words but the meaning changes because of order. Positional Encoding (PE) gives each word a unique "position signal" so the model knows the sequence order.
Now the input vector is Embedding(tokens) + Positional Encoding
Now, the model knows both what the word is and where it appears.
This embedding stage is crucial in word sense disambiguation. The same token "apple" may evolve differently depending on context during subsequent encoder/decoder processing.


Join the conversation! Your thoughts help the community grow.