MLGuerrillaStart M1 →
Text and language·18 min read·Updated 23 September 2026

BERT and encoder models

These are small models that read text in both directions, which you can fine-tune on your own labels. They classify your text for a fraction of what an LLM costs, but they can't write a single word back to you.

BERT came out of Google in October 2018, and it set the pattern that encoder models still use today.

The pattern has two steps. The first one is pretraining. You take a model, show it billions of words of ordinary text, and mask some of the words, which means you hide them from the model and ask it to guess what they were.

That step takes a lot of compute, so almost nobody runs it themselves. For every model on this page, a lab has already done the pretraining and published the weights. Google did it for BERT, and Answer.AI and LightOn did it for ModernBERT. What you download is that finished model, and your own training starts from there.

The second step is fine-tuning. You take the pretrained model, put one small output layer on top of it, and train it again on your own labeled examples. The BERT paper makes the point that this is nearly all you have to do, saying the pretrained model "can be fine-tuned with just one additional output layer" without "substantial task-specific architecture modifications".

Eight years later, bert-base-uncased is still downloaded about 46 million times a month from Hugging Face. If the job is to decide which of your five teams a support ticket should go to, or whether a customer review is positive or negative, a 110M model fine-tuned on a few thousand of your own labeled examples can often do it, and it answers in milliseconds. A frontier model costs more because it can reason and write, and neither is needed here.

What it is

It turns text into vectors, and a head you train turns those into answers

An encoder takes a piece of text and gives you back one vector for every token in it. A token is a word or a piece of a word, and a vector is a list of numbers describing that token in the context of everything around it. Those vectors don't answer anything by themselves. To get an answer out of the model you attach a head, which is a small output layer with one slot for each of your labels, and you train that head on examples of the decision you want it to make.

BERT also puts a special [CLS] token in front of every input you hand it. The paper calls the final vector at that position "the aggregate sequence representation for classification tasks", which is a formal way of saying that one vector stands for the whole piece of text. If you are classifying, your head reads that single vector and picks a label. If you are pulling pieces out of a sentence, say every date in a contract, your head reads every token's vector and labels each one separately.

A five-step figure titled "One sentence becomes twelve vectors, and the head reads one of them", described as a real pass through the ModernBERT classifier fine-tuned further down the page, on one held-out message. Step one is the text, "My card was charged twice for the same order." Step two is tokens, showing twelve chips reading CLS, My, card, was, charged, twice, for, the, same, order, a full stop and SEP, with the CLS chip highlighted, and a note that there are 12 tokens with CLS added in front. Step three is the encoder, a box reading ModernBERT-base, 149M parameters, 22 layers, 768 wide, which reads all 12 tokens in one pass, with a note that nothing is generated here. Step four is one vector per token, a stack of rows labeled CLS, My, card, was, charged and twice, each marked 768 numbers, with a note that there are 6 more, one per token. The CLS row is highlighted and its first values are shown as +0.11, +0.12, +0.18 and so on, under a note saying the head reads this one. Step five is the head, a box reading one layer, 768 to 77 labels, which outputs transaction_charged_twice at 99.8% and getting_spare_card at 0.1%, with a note that the other 75 labels share 0.1% and that the head is trained on your labels. The caption reads: the encoder is the same for every task, and the head is the part you train and the only part that knows your labels.
Every step here is one forward pass. Nothing is written and nothing is sampled, so the same message always comes back with the same numbers.

Every position reads the whole input in both directions, so by the time the model judges a word it has already read the words that come after it. The word charge means one thing in "they charged my card twice" and a different thing in "the battery will not charge", and an encoder has read the rest of the sentence before it settles on either one. The encoder, decoder and encoder-decoder article draws that out with a figure, if you want to see the mechanism.

Keep reading

The rest of this article is free with an account

Create a free account to read the remaining 6 sections. It takes about twenty seconds and there's nothing to pay. The same account opens the slide decks and CV reviews.

  1. 02Encoders do the small jobs that run on every record
  2. 03Mask words to pretrain it, then add a head to fine-tune it
  3. 04These are the checkpoints you'll see, as of September 2026
  4. 05Choose an encoder when the labels are fixed and the volume is high
  5. 06How to try it
  6. and 1 more