All models

modernbert

ModernBERT, a modernized BERT encoder that supports sequences of up to 8192 tokens.

Language · 1,094 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (23 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
149.7M
Operations
1,094
Framework
PyTorch
Recurrent
No
Published
2024
License
Apache-2.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m7384
Graph hash
a2b522cedd88ec6d28df0a22cdbb6ced2302b9351b3a71d067fe77710b3626c4
Skeleton hash
8a72f8f083d06d29a30630108983d43afa694b428f9db172187475bfefa15537
Architecture hash
d16768dfa615a3b32fd23bba7affd375724e851aba397415793642bea3f6d822
Diagram SHA-256
6af4e574d2bb436895ad66165761b128f122f9b2d616cdfee6c0008d1407c850
TorchLens version
2.35.3
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

How this diagram was made

transformers.AutoModelForMaskedLM.from_config()

What it is

ModernBERT is a modernized version of BERT trained on 2T tokens. As a masked language model it predicts the [MASK] token in a sentence.

Its changes to the original architecture include rotary positional embeddings to support sequences of up to 8192 tokens, unpadding to avoid wasting compute on padding tokens, GeGLU layers, and alternating attention. ModernBERT also supports padding-free inference and training. That mode requires FlashAttention2 as the attention implementation, which ModernBERT no longer uses by default and which must therefore be set explicitly. Besides masked-token prediction, the library provides versions of the model for sequence classification, token classification, multiple choice and question answering.

Key idea. ModernBERT modernizes the BERT architecture with rotary positional embeddings for sequences of up to 8192 tokens, unpadding, GeGLU layers and alternating attention.

  • modernbert
  • modern bert
  • masked language model
  • fill-mask
  • text encoder
  • encoder-only transformer
  • long context encoder
  • rotary positional embeddings

AI-written summary, based on the model's documentation and checked automatically against it; not reviewed by a person. Corrections welcome.