esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
Let’s talk

I’ll build the agent for it.

How Many Parameters Are in One Transformer Layer?

How to estimate the parameters in one transformer layer from the model's width, checked against GPT-3, explained simply for your AI interview.

In short

A transformer layer holds about 12 times the model width squared in parameters. Attention uses four square grids of that width, the feed-forward block uses two grids that reach four times the width, and GPT-3's 96 layers hold most of its 175 billion parameters.

9 min readAdvancedOccasional · estimateFacts checked 27 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

Roughly twelve times the model width, squared. A layer has an attention block with four square grids of that width, and a feed-forward block with two grids four times wider. For GPT-3, that comes to about 1.8 billion per layer, and its 96 layers hold almost all of its 175 billion parameters. The formula leaves out small terms, so I'd call it an estimate.

What is one transformer layer, in plain words?

A transformer is built from the same layer, stacked many times. Each layer holds parameters, which are the learned numbers the model uses to turn its input into an output. Training fills them in, and answering reads them.

Think of a bank's back office with 96 identical review desks in a row, each built from the same drawers and shelves. Count the parts on one desk, multiply by 96, and you know the room's total. In a model, the desks are the layers, and the drawers are the grids of weights.

Key words

Parameter
One learned number inside the model. A model's size is counted in these.
Model width
The length of the vector that stands for one word inside the model.
Weight grid
A rectangle of parameters that multiplies a vector. Its size is rows times columns.
Attention
The part of a layer where each word looks at the other words to pick up context.
Feed-forward block
The part of a layer that works on each word on its own, after attention.

How many parameters are in each block?

Each layer has two blocks. The paper that introduced the transformer describes them this way:

  • “The first is a multi-head self-attention mechanism, and the second is a simple, position-wise fully connected feed-forward network.”

    Vaswani et al. (2017)

  • “This consists of two linear transformations with a ReLU activation in between.”

    Vaswani et al. (2017)

Where one layer's weights sit

Input vectors

one list of numbers per word

Attention block

Q, K and V weights

three grids, each width × width

Output weights

one more grid, width × width

Feed-forward block

Up to 4 × width

a grid of width × 4 × width

Back down to width

a grid of 4 × width × width

Layer output

goes to the next layer

  1. 1Each word's vector enters the layer.
  2. 2The attention block mixes information between the words.
  3. 3The feed-forward block works on each word, then the result leaves the layer.
A layer has two blocks. The attention block holds four square grids of the model's width, and the feed-forward block holds two grids, one four times wider. Counting every entry gives about 12 times the width, squared.
  1. 1

    Count the attention block

    Four square grids of width × width: query, key, value and output. That is 4 × width², about 604 million for GPT-3.

  2. 2

    Count the feed-forward block

    Two grids: up to four times the width, then back down. That is 8 × width², about 1.21 billion for GPT-3.

  3. 3

    Add them, then multiply by the layers

    4 + 8 = 12, so one layer is about 12 × width², or 1.81 billion for GPT-3. Multiply by 96 layers for the layer total.

The feed-forward block is the bigger share, twice the attention block, because each of its grids holds four times as many numbers as one attention grid. The GPT-3 paper says it always uses a feed-forward layer four times the size of the model width, so check the settings of any model you are given.

Does the count match a real model?

Here is the same arithmetic in Python. It uses the width and layer count that the GPT-3 paper lists for its largest model.

Python
# One transformer layer, counted by hand. The width is GPT-3 175B's (table in the GPT-3 paper).
width = 12288          # model width, the size of each token's vector
inner = 4 * width      # feed-forward inner size: four times the width (GPT-3 paper)
attention = 4 * width * width   # the Q, K, V and output projections, each width x width
feed_forward = 2 * width * inner  # up to the inner size, then back down to the width
layer = attention + feed_forward
print(f"attention: {attention:,}")
print(f"feed-forward: {feed_forward:,}")
print(f"one layer: {layer:,}")
print(f"about {layer / 1e9:.2f} billion per layer")
print(f"96 layers: {96 * layer:,}")
# Stored as 16-bit numbers, 2 bytes each, so one layer's weights take:
print(f"one layer at 2 bytes each: {layer * 2 / 1e9:.1f} GB")
# A made-up 24 GB card, for the same question on a smaller budget.
print(f"96 layers at 2 bytes each: {96 * layer * 2 / 1e9:.0f} GB, far more than 24 GB")

Output

attention: 603,979,776
feed-forward: 1,207,959,552
one layer: 1,811,939,328
about 1.81 billion per layer
96 layers: 173,946,175,488
one layer at 2 bytes each: 3.6 GB
96 layers at 2 bytes each: 348 GB, far more than 24 GB
  • One layer

    About 1.81 billion

    Twelve times the width squared, with a width of 12,288.

  • All 96 layers

    About 174 billion

    Add the word tables and small terms, and the total lands close to the paper's 175 billion.

Tip

Say the rule, then check it against a real model's width and layer count, so you can redo it on paper.

How would you fit a model like this on a small GPU?

A team wants to run a GPT-3-sized model on one made-up 24 GB card, to search 40,000 contract files for a legal group. At two bytes per number, the 96 layers, about 174 billion numbers by this count, need about 348 GB, so one card cannot hold them.

The options are to split the model across many cards, to use a smaller model and test it on the team's own contracts, or to store each number in fewer bits. Fewer bits save memory but can cost answer quality, so pick by measuring on their own files.

Tip

Give the memory number first. It decides which hardware is possible before anyone argues about quality.

What does the interviewer want to hear?

A strong answer covers

  • A rule of thumb: about 12 times the width, squared, per layer.
  • Where it comes from: four attention grids and two feed-forward grids.
  • A real check: GPT-3's 96 layers and width of 12,288 give about 1.8 billion per layer.
  • Honest limits: biases and small terms are left out, so it is an estimate.
  • Why it matters: memory, cost and which hardware can run the model.
  • The whole model adds up its layers, plus the word tables.

Common traps

  • Trap"Every layer is about as big as the whole model."

    BetterOne layer is a small slice. GPT-3's 96 layers together hold almost all of its 175 billion.

  • Trap"Attention holds most of the parameters."

    BetterThe feed-forward block holds about twice as many: 8 × width² against 4 × width².

  • Trap"Adding more heads adds many parameters."

    BetterHeads split the same width into smaller pieces, so the grids stay the same size. The paper says the total cost stays similar.

Can you spot the wrong estimate?

Spot the wrong estimate

A capacity planner wrote four lines for a made-up claims model with width 4,096 and 32 layers. Which line uses the wrong formula?

Quick check

A platform team plans to run GPT-3-sized layers on its own servers. Roughly how many weights does one layer hold?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q018What are parameters (weights)?11 min
  2. Q046What is multi-head attention?10 min
  3. Q054What does the feed-forward block do?10 min
  4. Q311What is quantization?10 min
  5. Q327GPU basics: why does memory bandwidth limit decoding?11 min

Learn it in depth

Last updated on 27 November 2026

Sizing a model for your own servers?

I design and build AI products and agents, including the system and the UI behind them. Book a short call and tell me what hardware and model you are working with.