Compare Encoder-Decoder and Decoder-Only Transformer Architectures

Quick Overview

Compare encoder-decoder and decoder-only transformer architectures: how each attends over input and output, how each is trained and run at inference, and the strengths and weaknesses that decide which one to use. Tests understanding of attention masks, training signal, KV caching, inference cost and task fit.

Compare Encoder-Decoder and Decoder-Only Transformer Architectures

Company: Roblox

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Technical Screen

Compare encoder-decoder transformer models with decoder-only transformer models. Explain how each architecture processes its input and produces its output, then discuss the advantages and disadvantages of each and when you would choose one over the other. ```hint Follow the attention masks Trace which tokens each position can attend to in each architecture, during training and during generation. ``` ### Clarifying Questions - Is the comparison for a specific task, such as translation, summarization or open-ended chat, or in general? - Should the comparison cover training and inference cost as well as quality? ### What a Strong Answer Covers - The mechanics: bidirectional encoder self-attention, causal decoder self-attention and cross-attention, versus one causal stack over the prompt and the output. - The training objectives typically used with each, and how much training signal each gets per sequence. - Inference behavior: how the input is processed, what is cached, and how cost grows with input length. - Strengths and weaknesses tied to tasks: fixed sequence-to-sequence mappings versus general-purpose generation and learning from examples in the prompt. - Related variants such as prefix language models, with encoder-only models for contrast. ### Follow-up Questions - Why have most large general-purpose language models been decoder-only? - For a task with long inputs and short outputs, which architecture is cheaper at inference, and why? - How does the KV cache differ between the two architectures? - How would you adapt a decoder-only model to a task that benefits from bidirectional attention over the input?

Overview: Compare encoder-decoder and decoder-only transformer architectures: how each attends over input and output, how each is trained and run at inference, and the strengths and weaknesses that decide which one to use. Tests understanding of attention masks, training signal, KV caching, inference cost and task fit.

Read the full Roblox Machine Learning Engineer interview experience this question came from

Roblox logo
Roblox
Nov 25, 2026
mediumMachine Learning EngineerTechnical ScreenMachine Learning
0
0

Compare encoder-decoder transformer models with decoder-only transformer models. Explain how each architecture processes its input and produces its output, then discuss the advantages and disadvantages of each and when you would choose one over the other.

Clarifying Questions Guidance

  • Is the comparison for a specific task, such as translation, summarization or open-ended chat, or in general?
  • Should the comparison cover training and inference cost as well as quality?

What a Strong Answer Covers Guidance

  • The mechanics: bidirectional encoder self-attention, causal decoder self-attention and cross-attention, versus one causal stack over the prompt and the output.
  • The training objectives typically used with each, and how much training signal each gets per sequence.
  • Inference behavior: how the input is processed, what is cached, and how cost grows with input length.
  • Strengths and weaknesses tied to tasks: fixed sequence-to-sequence mappings versus general-purpose generation and learning from examples in the prompt.
  • Related variants such as prefix language models, with encoder-only models for contrast.

Follow-up Questions Guidance

  • Why have most large general-purpose language models been decoder-only?
  • For a task with long inputs and short outputs, which architecture is cheaper at inference, and why?
  • How does the KV cache differ between the two architectures?
  • How would you adapt a decoder-only model to a task that benefits from bidirectional attention over the input?