← Questions

Stable softmax and multi-head attention in NumPy

0
AmazonCodingLast asked Jul 2026

A coding interview question asked in Amazon's technical phone screen, last asked Jul 2026. It tests numpy, attention and numerical stability.

Implement the building blocks of attention in NumPy from scratch: a sigmoid and a softmax that never overflow or return NaN on extreme inputs, then scaled dot-product attention with an optional mask, then multi-head attention built on it…

Sign in to unlock this question

The full prompt, the worked answer and your own canvas or code with the AI tutor. New accounts get 5 credits: each one unlocks a question for good.

Where it's asked

  • Amazon · Technical phone screen · Last asked Jul 202660 min · Live coding in a shared editor that does not run code, plus Leadership Principles questions · No AI

What it tests

numpy · attention · numerical stability

Your code and the AI tutor open when you unlock this question.