← Amazon Interview Insights

Amazon·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
Jun 2026

Summary

Amazon ML Engineer phone screen focused entirely on NLP fundamentals, specifically the math and intuition behind surprisal. Pretty niche topic for an interview but if you've done any language modeling work you'll recognize it immediately.

Questions Asked (4)

Q1

How do you define surprisal for a token or event with probability p?

Technical Trade-offs
Author's notes

Straightforward if you know it: negative log of p.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining surprisal as -log(p) and explain its role in information theory. Then connect it to machine learning applications like loss functions and anomaly detection, and discuss trade-offs such as choice of logarithm base and numerical stability.

Pro tip: Mention that surprisal is also known as self-information and that minimizing surprisal is equivalent to maximizing likelihood, which is fundamental to training many ML models.

1. Define surprisal

State that surprisal (or self-information) for an event with probability p is defined as -log(p). Clarify that the base of the logarithm determines the unit (e.g., base 2 for bits, base e for nats).

2. Explain intuition

Describe how surprisal quantifies the 'unexpectedness' of an event: rare events have high surprisal, while certain events have zero surprisal. This aligns with information content.

3. Connect to ML

Discuss how surprisal is used in machine learning, e.g., as cross-entropy loss (negative log-likelihood) for classification, and in anomaly detection where high surprisal indicates outliers.

4. Address trade-offs

Mention practical considerations: choice of base (bits vs nats) affects scale but not optimization; numerical stability when p is near 0 (use log-sum-exp tricks); and the relationship to entropy and KL divergence.

5. Summarize significance

Conclude by emphasizing that surprisal is a foundational concept linking probability, information theory, and ML objectives, and that understanding it helps in model design and evaluation.

Key Points to Mention

  • Definition: surprisal = -log(p)
  • Units: bits (base 2) or nats (base e)
  • Intuition: rare events have high surprisal
  • Connection to cross-entropy loss and maximum likelihood
  • Numerical stability: avoid log(0) by adding epsilon or using log-sum-exp
  • Relationship to entropy: expected surprisal is entropy

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

What units can surprisal be expressed in, and what determines which unit you're using?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

I knew bits vs nats but fumbled for a second on the precise answer.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining surprisal as -log(p) and explaining that the unit depends on the base of the logarithm. Then connect each base to its unit (bits for base 2, nats for base e, hartleys for base 10) and discuss how the choice is driven by context, such as information theory, machine learning, or communication systems.

Pro tip: Mention that while bits and nats are most common, the choice often reflects the mathematical convenience or the hardware/software ecosystem—for example, nats are natural in gradient-based ML because they simplify derivatives of log-likelihood.

1. Define surprisal

State that surprisal (self-information) is defined as -log(p) where p is the probability of an event, and that the unit is determined by the base of the logarithm.

2. List common units and bases

Enumerate the units: bits (base 2), nats (base e), and hartleys/dits (base 10). Optionally mention that any base b gives a unit sometimes called a 'b-ary unit'.

3. Explain determinants of unit choice

Discuss that the choice depends on the application domain: bits for digital communication and computer science, nats for mathematics and machine learning (due to natural log derivatives), and hartleys for some legacy or decimal-based systems.

4. Connect to trade-offs

Highlight trade-offs: bits are intuitive for storage and transmission, nats simplify calculus and are standard in ML frameworks, and hartleys are rarely used but illustrate base flexibility.

5. Summarize with practical implications

Conclude that the unit is a convention, and in ML, nats are typical for loss functions like cross-entropy, while bits are used when reporting compression rates or information content in a digital context.

Key Points to Mention

  • Surprisal is -log(p), and the base of the logarithm determines the unit.
  • Bits (base 2), nats (base e), and hartleys (base 10) are the standard units.
  • In machine learning, nats are common because natural log simplifies derivatives in optimization.
  • Bits are prevalent in information theory and digital communication for their alignment with binary encoding.
  • The choice of unit is often a matter of convention and convenience, not fundamental physics.
  • Conversion between units is straightforward: 1 nat = 1/ln(2) bits ≈ 1.4427 bits.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

Can you explain how surprisal connects to cross-entropy and perplexity in the context of language modeling?

Technical Trade-offsProduct Analytics & Metrics
Author's notes

This is where it got interesting.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining surprisal as -log p(x) for a token, then show how averaging surprisal over a sequence yields cross-entropy, and finally explain that perplexity is the exponential of cross-entropy. Use a concrete example (e.g., a single token with probability 0.5) to illustrate the relationships and connect to model evaluation.

Pro tip: Emphasize that perplexity is not just a metric but an interpretable measure: it represents the effective number of equally likely choices the model is uncertain about at each step. This shows you understand the intuition behind the math.

1. Define surprisal

Explain that surprisal (or information content) of an event with probability p is -log p. Higher surprisal means the event is less likely and thus more informative.

2. Connect to cross-entropy

Show that cross-entropy is the expected surprisal when using the model's predicted distribution q to encode data from true distribution p: H(p,q) = -Σ p(x) log q(x). In language modeling, it's the average negative log-likelihood per token.

3. Define perplexity

State that perplexity is exp(cross-entropy). It can be interpreted as the weighted average number of choices the model is considering for the next token.

4. Illustrate with an example

Use a simple example: if a model assigns probability 0.5 to the correct next token, surprisal = -log2(0.5) = 1 bit, cross-entropy for that token = 1, and perplexity = 2^1 = 2.

5. Discuss implications for language modeling

Explain that lower perplexity indicates better predictive performance, and that minimizing cross-entropy during training directly minimizes perplexity. Mention that perplexity is often used to compare models on held-out data.

Key Points to Mention

  • Surprisal is -log p, measured in bits or nats depending on log base.
  • Cross-entropy is the average surprisal over a dataset, equivalent to negative log-likelihood.
  • Perplexity is the exponentiation of cross-entropy: PP = exp(H).
  • Perplexity can be interpreted as the effective vocabulary size the model is choosing from at each step.
  • In language modeling, cross-entropy loss is minimized during training, which directly minimizes perplexity.
  • Perplexity is not comparable across different tokenizations or vocabularies.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

What are common mistakes or misunderstandings people make when interpreting surprisal values?

Technical Trade-offsRoot Cause Analysis
Author's notes

Blanked a bit here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining surprisal as -log P(event) and clarify that it measures information content, not probability. Then discuss common misinterpretations such as confusing surprisal with probability, ignoring base rates, and misapplying it in sequential or dependent settings. Finally, relate these to practical ML scenarios like anomaly detection or loss functions, emphasizing calibration and context.

Pro tip: Emphasize that surprisal is a relative measure and its interpretation depends on the model and data distribution; always validate with empirical results and consider the cost of errors in the application.

1. Define surprisal clearly

State that surprisal (self-information) is -log P(event), so rarer events have higher surprisal. Clarify that it is not a probability and ranges from 0 to infinity.

2. Identify common misinterpretations

List mistakes like treating surprisal as probability, assuming linearity, ignoring base rates, and confusing surprisal with entropy or cross-entropy.

3. Explain consequences in ML

Describe how these mistakes lead to poor decisions in anomaly detection, model evaluation, or feature engineering, such as overreacting to rare but expected events.

4. Provide mitigation strategies

Suggest using calibration, smoothing, and context-aware thresholds. Recommend validating surprisal-based decisions with domain knowledge and cost-sensitive analysis.

5. Relate to Amazon context

Tie the discussion to Amazon's scale and customer impact, emphasizing the need for robust, well-calibrated models and root cause analysis when surprisal signals anomalies.

Key Points to Mention

  • Surprisal is -log P(event), not the probability itself; high surprisal means low probability.
  • Common mistake: interpreting surprisal as a linear measure of 'surprise' without considering the logarithmic scale.
  • Ignoring base rates: a low-probability event may still be expected if the base rate is low.
  • Confusing surprisal with entropy: entropy is the expected surprisal over a distribution.
  • In sequential data, surprisal of an event depends on the model and previous events; independence assumptions can mislead.
  • Practical impact: misinterpreting surprisal can lead to false alarms in anomaly detection or misprioritized alerts.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.