Generative AI & LLMs

Transformer (Architecture)

In shortThe neural network architecture behind BERT, GPT, Gemini and most modern language models, built around attention instead of reading text word by word.

Updated 24 Oct 2026· 2 min read

The transformer is a Neural Network architecture introduced by Google researchers in the 2017 paper “Attention Is All You Need”. Instead of processing text one word after another, it looks at all the words in a passage at once and learns how much each word should influence the others. Almost every model SEOs meet today, from BERT to ChatGPT and Gemini, is built on it.

How it works

Text is first split into tokens (see Tokenization) and each token becomes a vector. The core step is self-attention: for every token, the model scores how relevant every other token in the sequence is and blends their information together. Stacking many attention layers lets the model capture context, so “bank” next to “river” ends up with a different representation from “bank” next to “loan”.

There are three main families:

  • Encoder-only models such as BERT read the whole input in both directions. They are good at understanding tasks like classification, entity recognition and producing embeddings. See Encoder Model.
  • Decoder-only models such as GPT and Claude generate text one token at a time. Most chat assistants are decoder-only.
  • Encoder-decoder models such as T5 and BART turn one sequence into another, which suits summarisation and translation.

Because the architecture processes tokens in parallel, it trains efficiently on very large datasets, which is what made today’s large language models possible. The same idea has been applied to images: the Vision Transformer cuts an image into small patches and treats them like words.

How it’s used in SEO and marketing

  • Topic modelling and keyword clustering with transformer embeddings, as in BERTopic and KeyBERT.
  • Sentiment analysis and search intent classification with pre-trained or fine-tuned models from Hugging Face.
  • Summarisation and meta description generation, from BERT-based extractive summarisers to LLMs.
  • Understanding how Google reads queries: BERT was added to Google Search in 2019 to better interpret prepositions and context.

Example

In MLforSEO’s sentiment benchmark on 2,000 tweets, a transformer model (Twitter RoBERTa) scored 0.71 macro-F1 against 0.58 for a TF-IDF and logistic regression model and 0.52 to 0.53 for lexicon methods. The post also points out the transformer had a home advantage, because it was fine-tuned on similar tweets.

Limitations and things to watch

  • Attention cost grows quickly with input length, which is one reason models have a fixed context window.
  • Transformers learn patterns from their training data, including its gaps and biases.
  • Bigger is not always better for marketing tasks: a small fine-tuned encoder often beats a general LLM on a narrow, repeated classification job.

Learn it on MLforSEO

Where Transformer (Architecture) shows up on MLforSEO

Sources and further reading

Other terms from Generative AI & LLMs

See all 19 Generative AI & LLMs terms →