Bidirectional Encoder Representations from Transformers (BERT)

BERT is a language model Google released in 2018 that reads text in both directions at once to represent its meaning, widely used for search, classification and other language-understanding tasks.

BERT was introduced by Jacob Devlin, Ming-Wei Chang, Kenton Lee and Kristina Toutanova of Google in a paper posted in October 2018, and Google open-sourced the code and pre-trained English models on November 2 that year. It is an encoder-only transformer: rather than generating text, it turns a passage into a set of numerical representations that capture what each word means in context.

Its key idea is in the name. Earlier models such as OpenAI's first GPT read text from left to right, so each word's representation could only draw on the words before it. BERT conditions on both sides at once. To make that trainable, it selects about 15 per cent of the tokens in its input, mostly replacing them with a mask, and learns to predict the originals from the surrounding words, a task called masked language modelling. It was also trained to judge whether one sentence actually follows another. The training data was BooksCorpus, about 800 million words, and English Wikipedia, about 2.5 billion words. The two original sizes had roughly 110 million and 340 million parameters.

A pre-trained BERT can be adapted to a specific task by adding a single output layer and fine-tuning briefly. The paper reported state-of-the-art results on eleven language tasks, including a score of 80.5 on the GLUE benchmark, a 7.7 point improvement. Google said that with BERT a strong question-answering system could be trained in about 30 minutes on a single Cloud TPU, which put high-quality language understanding within reach of ordinary research teams.

The best-known deployment was in Google Search. On October 25, 2019 Google said BERT would help it understand about one in ten English-language searches in the United States, and by October 2020 it was reported to be used on almost every English query. BERT also spawned a family of successors, including RoBERTa, DistilBERT and ALBERT in 2019 and ModernBERT in 2024.

BERT is not a chatbot and cannot easily write text, because it has no decoder to generate output word by word. That is why generative assistants are built on decoder-only models instead. But encoder models in the BERT mould remain a common choice for classification, search ranking and other tasks that need understanding rather than generation, and they are far cheaper to run than large language models.

Common questions

What is BERT used for?

BERT and its successors are used for tasks that require understanding text rather than generating it: classifying documents, detecting sentiment, recognising names and places, extractive question answering and ranking search results. Google used it to interpret search queries from 2019.

Is BERT a large language model?

BERT is a pre-trained transformer language model, and it was large for its time, but at 110 to 340 million parameters it is small by today's standards. It is also encoder-only, so unlike the large language models behind chatbots it does not generate text. It is usually discussed as a precursor to them.

What is the difference between BERT and GPT?

BERT is an encoder that reads text in both directions to build representations, trained by filling in masked words. GPT models are decoders that read left to right and are trained to predict the next word, which makes them natural text generators. BERT suits understanding tasks; GPT-style models suit generation and conversation.

Does Google still use BERT in Search?

Google announced BERT in Search in October 2019 for about one in ten US English queries, and reports in October 2020 said it was being used on almost every English query. Google's own Search announcements are the authoritative record of how its use has changed since.

Finding more

Search for "BERT paper Devlin 2018", "masked language model" or "encoder-only transformer" to understand how it works, and for "BERT Google Search 2019" for its use in search. The original paper on arXiv and Google's own research and product blogs are the primary sources. Documentation on Hugging Face covers how BERT-style models are used today; treat search-marketing articles that claim to explain how to rank for BERT with scepticism.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.