bugger.
All challenges/Pythonmediumllm-multi-token-loss-v1
THE INVESTIGATION

Train several future-token objectives

Align several future-token heads and compute a weighted loss.

LLM ArchitectureFrontier variants

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 tokens is one sequence of class IDs or -1 for ignored positions. Each item in heads provides offset ≥ 1, logits (one row per input token) and nonnegative weight. A position i predicts tokens[i+offset] when in range and not ignored. Return counts, losses (each head’s mean over its eligible positions, zero for an empty head) and loss (weighted sum of those means). Mask the target position, not the source.

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

Align several future-token heads and compute a weighted loss.

Reproduction

01 Two heads supervise different target populations
{"tokens":[0,1,0],"heads":[{"offset":1,"weight":1,"logits":[[4,0],[2,1],[0,1]]},{"offset":2,"weight":0.5,"logits":[[1,2],[1,0],[0,1]]}]}
{"counts":[2,1],"losses":[2.165706,1.313262],"loss":2.822337}
02 Offset longer than the sequence
{"tokens":[0],"heads":[{"offset":2,"weight":1,"logits":[[1,2]]}]}
{"counts":[0],"losses":[0],"loss":0}
03 Ignored token at target position
{"tokens":[0,-1,1],"heads":[{"offset":1,"weight":1,"logits":[[1,2],[2,1],[0,1]]}]}
{"counts":[1],"losses":[1.313262],"loss":1.313262}

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.