Home/AI/ML Notes/GenAI and LLMs Summary/GPT vs. BERT & Encoder Models
⌂ Main Page
GenAI and LLMs Summary

GPT vs. BERT & Encoder Models

GPT vs. BERT, base vs. large BERT, fine-tuning BERT, inference in masked language models, symbolic logic, and BERT varieties.

On this page

BERT vs. GPT

Encoder-decoder architecture (T5, BART) – complex mapping from one text sequence to another for machine translation, summarization.

Decoder-only architecture (Generative Pretrained Transformers (GPT)). The model was trained using generative pre-training – it autocompletes the sequence by iteratively predicting the most probable next word (as a softmax distrib. over the entire vocab.). Text generation, Q&A. The computed representation for each token depends only on the left context = causal or autoregressive attention.

Encoder-only architecture (Bidirectional Encoder Representations from Transformers (BERT) – converts input text into a rich numerical representation for further text classification, NER, Q&A, summary, etc. The computed representation for each token depends both on the left (before the token) and the right (after the token) contexts – bidirectional attention.

BERT developers created two models:

Fine-tuning BERT - adding small layer to the core model:

A close-up of a computer screen AI-generated content may be incorrect. A close-up of a computer screen AI-generated content may be incorrect.

Both decoder LMs and MLMs generate proba distrib. over entire vocabulary at each position. Difference:

MLM is usually part of encoder-only models, but it can also be adapted in encoder–decoder setups (like T5, BART) into denoising or span-masking objectives for pretraining. Decoder-only models normally don’t use MLM — they use causal LM (next token prediction).

Statistical Model (ChatGPT) + Symbolical Logic (Wolfram Alpha). WA - computational knowledge engine developed by Wolfram Research: answers factual queries by computing answers from externally sourced data.

BERT Varieties

  1. How it’s trained

    • Uses knowledge distillation: learns to mimic a full BERT (“teacher”)

    • Optimized to match teacher outputs and hidden representations

  2. Why it exists

    • ~40% fewer parameters

    • ~60% faster inference

    • ~95–97% of BERT’s performance