bugger.
All challenges/Pythonmediumllm-online-softmax-v1
THE INVESTIGATION

Online softmax across score chunks

Maintain a stable softmax normalizer across chunks of logits.

LLM ArchitectureML systems

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

01 A rising maximum rescales the old sum
{"chunks":[[1,2],[5,6]]}
[{"max":2,"denominator":1.367879},{"max":6,"denominator":1.392933}]
02 Single nonempty chunk
{"chunks":[[5,6]]}
[{"max":6,"denominator":1.367879}]
03 A falling peak contributes small mass
{"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.

    The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.