for each token t: score = compare(query_t, keys) weights = softmax(score) output_t = sum(weights * values)