RobertaForMaskedLM
RobertaForMaskedLM at 6 layers and hidden size 384. One published checkpoint has this shape.
The pass (wrapper only)
The order of operations for one forward. ×N marks a position that fires once per layer.
One step. The model's forward was entered and nothing inside it was recorded, so this says the model ran and says nothing about the order of anything. It is not comparable to the fuller traces on other sheets. Recorded from a complete forward of this shape in the author's independent implementation — the structure is what that run emitted, not a reading of the configuration.
encodeManyIds
The same thing in canonical form:
1(2 3*N(4 5 6 7 8))
Numbers are positions in the pass, not layer indices. Two passes count as the same structure when these strings match.
Implementing it
One forward, written out, per checkpoint whose arithmetic actually differs. A shape groups checkpoints by class, depth, width and layer stack — none of which decides an activation, a rope base or a routing rule — so where the members of this shape disagree there is a block each, and each names the checkpoint it was generated from.
It is not the recorded pass above, which is captured from a real forward; it is what the published configuration says the arithmetic is. Where the configuration does not say, the line says that instead of guessing.
The names are the ones the published checkpoint uses where a name is published, and canonical otherwise. A checkpoint loader may store them differently — fusing a gate/up pair into one matrix, or splitting one published projection in two — and those are that loader's names, not the model's. Everything spelled here is what the download contains.
Generated from granite-embedding-30m-sparse.
x = layernorm(word[ids] + position[2..2+T] + token_type[0]) # [T, 384]
# Positions start at 2, not 0: RoBERTa offsets by pad_token_id + 1
# (`pad_token_id: 1`). Row 0 and row 1 of the table are never read.
for i in 0 .. 5:
h = x
q = x @ layers[i].attention.self.query.T
k = x @ layers[i].attention.self.key.T
v = x @ layers[i].attention.self.value.T
a = softmax(q @ k.T / sqrt(32), mask=bidirectional) @ v
# Not causal. Every position sees every other one — that is the whole
# difference between this and the decoders above, and it is why these
# models embed a sequence rather than continue it.
x = layernorm(x + a @ layers[i].attention.output.dense.T,
layers[i].attention.output.LayerNorm) # post-norm
h = gelu(x @ layers[i].intermediate.dense.T)
x = layernorm(x + h @ layers[i].output.dense.T, layers[i].output.LayerNorm)
logits = x @ decoder.T # one distribution per position
The position table is read from row 2, not row 0. RoBERTa derives position ids as pad_token_id + 1 + i (pad_token_id: 1 here), so rows 0..1 are never read and the table is 2 rows longer than the context to pay for it. Starting at row 0 is a lookup that succeeds and an embedding shifted by 2 positions everywhere.
The attention here is bidirectional, which is the one difference that matters: there is no causal mask, so a position may read the whole sequence. Running this stack causally is fluent and is not the model's function.
This lineage is post-norm — the norm comes after the residual add, not before it, which is the opposite of every decoder on these pages.
Geometry
| layers | 6 |
| hidden size | 384 |
| attention heads | 12 |
| feed-forward width | 1,536 |
| vocabulary | 50,265 |
| trained context | 514 tokens |
| largest checkpoint | 30.3M |
Weight structure
The tensors one element of the repeating stack holds, by the names the published checkpoint uses.
| repeating stack | depth | what one element holds |
|---|---|---|
roberta.encoder.layer.# | 6 | attention.output.LayerNorm.bias, attention.output.LayerNorm.weight, attention.output.dense.bias, attention.output.dense.weight, attention.self.key.bias, attention.self.key.weight, attention.self.query.bias, attention.self.query.weight, attention.self.value.bias, attention.self.value.weight, intermediate.dense.bias, intermediate.dense.weight, output.LayerNorm.bias, output.LayerNorm.weight, output.dense.bias, output.dense.weight |
How this was checked
implemented, evidence grade recorded-forward, per the assessment: a converted copy of this checkpoint was loaded and completed a forward pass; the recorded pass on this page came from such a run. The implementation meant here and below is an unpublished independent inference implementation by the author.
What stands behind the block above, beyond the published configuration it is read from:
- an encoder implemented from the published configuration
- a checkpoint loader, which is where published tensor names are read
- an independent reference implementation of this architecture in Python, driving the published modelling code — an executable statement of what the model should compute, written against the publication rather than against any one implementation of it
Where an independent implementation and the published configuration disagree, the configuration is what this page reports and the disagreement is what it says.
Checkpoints with this architecture
| model | parameters | context |
|---|---|---|
granite-embedding-30m-sparse | 30.3M | 514 |