Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
Oracle · OCI AI Foundations

Transformers

OCI AI Foundations · Lesson 7 of 16 · 45:28

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the Oracle Cloud Infrastructure AI Foundations Associate exam (1Z0-1122-26). In this lesson: attention and self-attention (from the 2017 paper Attention Is All You Need), encoder-only, decoder-only, and encoder-decoder models, tokens and the context window, and embeddings that capture meaning in context. Includes three original practice questions, with Willowmere Motors, a fictional network of car dealerships and repair shops, as the example.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

Words far apart

Willowmere's assistant gets questions like this one: my car, which I bought at your Northgate dealership last spring, makes a noise when it brakes, so is that covered? The words that matter, car, noise, brakes, and covered, are far apart, and an older recurrent network would struggle to link them. Transformers solve this, and nearly every large language model today is built on them.

Attention

The transformer architecture was introduced in twenty seventeen, in a research paper titled Attention Is All You Need. Its key idea is self-attention: for each word, the model weighs how much every other word in the text matters to it. In the sentence the car would not start because its battery was dead, attention links its to car, and dead to battery. And unlike a recurrent network, which reads one word after another, a transformer looks at the whole text at once, in parallel, which makes training much faster on GPUs.

Encoders and decoders

A transformer has two kinds of blocks. An encoder reads the text, and turns it into embeddings: vectors that capture the meaning of each token in its context. A decoder generates text, one token at a time, each new token depending on the ones before it. Models built only from encoders, like BERT, are used for embeddings, search, and classification, decoder only models, like GPT or Llama, generate text, and encoder decoder models suit tasks like translation. Most of today's chat models are decoder only.

Tokens

Language models do not read words: they read tokens. A token can be a whole word, part of a word, or a punctuation mark: a common word like car is usually one token, a longer word like friendship can be two, and a comma is a token too. On average, a token is about four characters of English text. Tokens matter, because models have limits on how many tokens they read and write, and cloud services often charge by the token. A model's context window is the maximum number of tokens that it can handle in one request, the prompt and the answer together.

Embeddings in context

Inside a transformer, every token becomes an embedding, a vector of numbers. Words with similar meanings get vectors that point in similar directions, so the model can compare meanings with math, like cosine similarity. A transformer also adds the position of each token, because attention alone does not know the word order. Then each layer of attention refines the embeddings with context: the word bank gets a different vector in river bank and in bank loan. That meaning in context is what makes transformers so good with language.

Recap

Let's recap. Self-attention weighs how much every word matters to every other word, and transformers process the whole text in parallel. Encoders turn text into embeddings, decoders generate text one token at a time, and encoder decoder models suit translation. Models read tokens, about four characters each, and limits and prices are counted in tokens. The context window is the maximum number of tokens in one request. And attention gives every token an embedding that depends on its context.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. Willowmere needs vectors that capture the meaning of each service note, so that staff can search the notes by meaning. Which kind of transformer model fits best?

    • A decoder only model, like GPT
    • An encoder model, like BERT
    • An encoder decoder model for translation
    • A recurrent neural network
    Show the answer

    An encoder model, like BERT

    Encoder models turn text into embeddings, vectors that capture meaning, which is exactly what search by meaning needs. “A decoder only model, like GPT” is built to generate text, one token at a time. “An encoder decoder model for translation” is built for tasks like translation, where text goes in and new text comes out. And “A recurrent neural network” is not a transformer at all, and struggles with long notes.

  2. Willowmere’s team wants to estimate how much of a model’s capacity its long prompts use. Why does the number of tokens in those prompts matter?

    • Tokens decide which language the model uses
    • Each token needs a GPU of its own
    • Tokens only count for images, not for text
    • Limits and pricing are counted in tokens
    Show the answer

    Limits and pricing are counted in tokens

    Limits, like the context window, and often the price, are counted in tokens. “Tokens decide which language the model uses” is wrong, because the language comes from the text itself, not from how many tokens it has. “Each token needs a GPU of its own” is wrong too, because tokens are units of text, not units of hardware. And “Tokens only count for images, not for text” has it backwards: tokens are the units in which models read and write text.

  3. In two of Willowmere’s notes, the word bank appears: the car is parked by the river bank, and the bank approved the car loan. How does a transformer represent bank in these two notes?

    • With one fixed number for every use
    • As a small image of the word
    • With a vector shaped by its context
    • As the token that ends the sequence
    Show the answer

    With a vector shaped by its context

    Attention refines each embedding with its context, so bank gets a different vector in each note. “With one fixed number for every use” would lose the difference between the two meanings. “As a small image of the word” confuses text with images, and transformers read tokens, not pictures of words. And “As the token that ends the sequence” is the special token that ends a generated text, not a way to represent a word.