Online softmax across score chunks
Maintain a stable softmax normalizer across chunks of logits.
What’s going wrong
Original LLM Architecture lab. Implement the missing behavior in solve(data) and keep the supplied JSON interface. Use Python’s standard library.
Input chunks is a list of finite score lists. After each chunk return {max, denominator} where denominator = sum(exp(score − max)) across all scores seen so far. Empty prefixes use null and 0. Carry forward only the running maximum and scaled sum between chunks.
Small, well-formed JSON inputs and standard-library Python arithmetic. Keep full precision during computation. The supplied output wrapper rounds results to six decimal places.
Expected behavior
Maintain a stable softmax normalizer across chunks of logits.
Reproduction
{"chunks":[[1,2],[5,6]]}[{"max":2,"denominator":1.367879},{"max":6,"denominator":1.392933}]{"chunks":[[5,6]]}[{"max":6,"denominator":1.367879}]{"chunks":[[],[3,2],[0]]}[{"max":null,"denominator":0},{"max":3,"denominator":1.367879},{"max":3,"denominator":1.417667}]Before you begin
- Python functions, lists and dictionaries
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
Read the report, then sign in to start your investigation.