Train several future-token objectives
Align several future-token heads and compute a weighted loss.
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
{"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}{"tokens":[0],"heads":[{"offset":2,"weight":1,"logits":[[1,2]]}]}{"counts":[0],"losses":[0],"loss":0}{"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.
Read the report, then sign in to start your investigation.