PracHub
QuestionsLearningGuidesInterview Prep
|Home/Machine Learning/Amazon

Explain attention and Transformers

Last updated: Mar 29, 2026

Quick Overview

Explain attention and Transformers evaluates core ML concepts, assumptions, math intuition, training/evaluation trade-offs, and practical failure modes in a realistic interview setting. A strong answer states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.

  • hard
  • Amazon
  • Machine Learning
  • Software Engineer

Explain attention and Transformers

Company: Amazon

Role: Software Engineer

Category: Machine Learning

Difficulty: hard

Interview Round: Technical Screen

Derive the scaled dot-product self-attention: define Q, K, V, the scaling factor, masking, and softmax; discuss complexity. Explain the Transformer encoder/decoder architecture, residual connections, normalization strategy, and positional encoding. Compare BERT and GPT pretraining objectives, architectures, and typical downstream usage; discuss how these choices affect transfer and inference.

Quick Answer: Explain attention and Transformers evaluates core ML concepts, assumptions, math intuition, training/evaluation trade-offs, and practical failure modes in a realistic interview setting. A strong answer states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.

Related Interview Questions

  • Use a Fitted Line to Predict a Future Data Point - Amazon (hard)
  • Implement Stable Sigmoid, Softmax, and Scaled Dot-Product Attention - Amazon (medium)
  • GRPO Deep Dive: Critic-Free RL, Parallelism, MLA, and Reward Design for a Reasoning LLM - Amazon (hard)
  • LLM Fundamentals: Tokenization Design and KL-Regularized SFT - Amazon (medium)
  • Predicting the Next Elevator Call Location - Amazon (medium)
|Home/Machine Learning/Amazon

Explain attention and Transformers

Amazon logo
Amazon
Jul 15, 2025, 12:00 AM
hardSoftware EngineerTechnical ScreenMachine Learning
7
0

Explain attention and Transformers

Scaled Dot-Product Self-Attention, Transformer Architecture, and BERT vs GPT

You are interviewing for a software engineer role focused on machine learning. Explain the core math and design choices behind Transformers and how they translate to practical trade-offs in transfer learning and inference.

1) Scaled Dot-Product Self-Attention

Derive and define the following:

  • Queries (Q), Keys (K), Values (V) and how they are computed from inputs
  • The scaling factor and why it is needed
  • Masking (padding and causal)
  • Softmax over attention logits
  • Time and memory complexity (including multi-head and autoregressive decoding)

2) Transformer Architecture

Explain the encoder–decoder Transformer architecture, including:

  • Encoder vs decoder stacks and their sublayers
  • Residual connections and the normalization strategy (pre-norm vs post-norm)
  • Positional encoding (sinusoidal and alternatives)

3) BERT vs GPT

Compare BERT and GPT in terms of:

  • Pretraining objectives
  • Architectural differences
  • Typical downstream usage
  • How these choices affect transfer learning and inference behavior/performance

Constraints & Assumptions

  • Preserve the scope, facts, inputs, and requested outputs from the prompt above.
  • If the prompt leaves a detail unspecified, state a reasonable assumption before relying on it.
  • Keep the answer interview-ready: concise enough to present, but concrete enough to implement or evaluate.

Clarifying Questions to Ask Guidance

  • Clarify the task, data shape, labels, constraints, and evaluation metric.
  • State assumptions behind the math or modeling technique you choose.
  • Connect theory to practical training, debugging, and deployment implications.

What a Strong Answer Covers Guidance

  • Correct definitions and formulas where the prompt requires them.
  • A practical explanation of how the method behaves on real data.
  • Trade-offs, failure modes, diagnostics, and mitigation strategies.
  • Evaluation choices that match the product or modeling objective.

Follow-up Questions Guidance

  • How would noisy labels, class imbalance, or distribution shift affect the answer?
  • What would you monitor after deployment?
  • Which baseline would you compare against first?
Loading comments...

Browse More Questions

More Machine Learning•More Amazon•More Software Engineer•Amazon Software Engineer•Amazon Machine Learning•Software Engineer Machine Learning

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

Master your tech interviews with 9,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.