← Lesson
Lost in the Middle
Joeven
Run
Reset
Python loads on first run
chunks = ["spec", "old-1", "old-2", "GOLD", "old-3", "latest"] def end_bias(xs): n = len(xs) scored = [] for i, name in enumerate(xs): dist_end = min(i, n - 1 - i) score = 1.0 / (1.0 + dist_end) scored.append((score, i, name)) scored.sort(key=lambda t: (-t[0], t[1])) return scored print("if the model likes ends:") for s, i, name in end_bias(chunks): print(round(s, 3), "idx", i, name) print("GOLD is buried; spec and latest win the toy score") moved = ["spec", "old-1", "old-2", "old-3", "GOLD", "latest"] print("move GOLD next to latest:") for s, i, name in end_bias(moved): print(round(s, 3), "idx", i, name) print("repeat goal at end:") repeated = ["spec", "old-1", "old-2", "GOLD", "old-3", "latest", "spec"] for s, i, name in end_bias(repeated): print(round(s, 3), "idx", i, name)
Run to execute this in your browser. Nothing is sent to a server.