Compare Encoder-Only, Decoder-Only, and Encoder-Decoder Transformers

Last updated: November 29, 2026

Quick Overview

Explain the differences between encoder-only models like BERT, encoder-decoder models like T5, and decoder-only models like Gemini, including attention masks and training objectives, and say which you would pick for three Google tasks.

Google
Machine Learning
Software Engineer
Google
November 29, 2026
Software Engineer
Phone Screen
Machine Learning
Easy

0

0

0 solved


Explain the differences between encoder-only models like BERT, encoder-decoder models like T5, and decoder-only models like Gemini, including attention masks and training objectives, and say which you would pick for three Google tasks.

Google built several of the canonical architectures in this space, and interviewers on Search, Translate, and Gemini teams use this to confirm a candidate's mental model of how attention masks define each family. They check whether choices are justified by task shape and serving cost.

What the Interviewer Expects
  • Describes bidirectional attention in encoders and causal attention in decoders
  • Describes cross-attention in encoder-decoder models
  • Names the typical pretraining objective for each family
  • Matches architectures to tasks with justification
  • Mentions serving cost differences such as encoding once versus autoregressive decoding
  • Explains why decoder-only became the general-purpose default
Key Topics to Cover
Transformer architectures
BERT
T5
Decoder-only models
Attention masks
How to Approach This
  1. Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
  2. Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
  3. Feature engineering is often more impactful than model selection.
  4. Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
  5. Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
  • What is a prefix language model, and where does it sit between these families?
  • Why are encoder-only models still used for retrieval and classification at scale?
  • How does the KV cache differ between encoder-decoder and decoder-only serving?
  • Can you fine-tune a decoder-only model to produce embeddings, and how?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Explore ML Interview Prep
Sample Answer
Clarify

All three use the same Transformer blocks; they differ in attention masks, objectives, and how inputs and outputs are wired. I will compare them and then choose for query-document relevance scoring, t...

Approach

Encoder-only (BERT): full bidirectional self-attention, every token sees every other. Trained with masked language modeling. Produces contextual representations, not text. Encoder-decoder (T5): a bidi...


Submit Your Answer
Markdown supported