()
| 13 | |
| 14 | |
| 15 | def main(): |
| 16 | model_to_round_steps = {} |
| 17 | |
| 18 | if not DATA_CACHE.exists(): |
| 19 | tournaments = [x.parent for x in LOCAL_LOG_DIR.rglob("metadata.json")] |
| 20 | for game_log_folder in tqdm(tournaments, desc="Scanning tournaments"): |
| 21 | try: |
| 22 | with open(game_log_folder / "metadata.json") as f: |
| 23 | metadata = json.load(f) |
| 24 | except Exception: |
| 25 | continue |
| 26 | |
| 27 | try: |
| 28 | p2m = { |
| 29 | x["name"]: x["config"]["model"]["model_name"].strip("@").split("/")[-1] |
| 30 | for x in metadata["config"]["players"] |
| 31 | } |
| 32 | except Exception: |
| 33 | # malformed metadata |
| 34 | continue |
| 35 | |
| 36 | # ensure models exist |
| 37 | for model in set(p2m.values()): |
| 38 | model_to_round_steps.setdefault(model, [[] for _ in range(ROUNDS)]) |
| 39 | |
| 40 | for player_name, model in p2m.items(): |
| 41 | traj_files = (game_log_folder / "players" / player_name).rglob("*.traj.json") |
| 42 | for traj_file in traj_files: |
| 43 | m = traj_file.name.rsplit("_r", 1) |
| 44 | if len(m) != 2: |
| 45 | continue |
| 46 | try: |
| 47 | round_part = m[1] |
| 48 | round_idx = int(round_part.split(".")[0]) |
| 49 | except Exception: |
| 50 | continue |
| 51 | if round_idx < 1 or round_idx > ROUNDS: |
| 52 | continue |
| 53 | |
| 54 | try: |
| 55 | with open(traj_file) as f: |
| 56 | traj = json.load(f) |
| 57 | except Exception: |
| 58 | continue |
| 59 | |
| 60 | num_steps = sum(1 for _ in traj.get("messages", []) if _["role"] == "assistant") |
| 61 | model_to_round_steps[model][round_idx - 1].append(num_steps) |
| 62 | |
| 63 | with open(DATA_CACHE, "w") as f: |
| 64 | json.dump(model_to_round_steps, f, indent=2) |
| 65 | |
| 66 | with open(DATA_CACHE) as f: |
| 67 | model_to_round_steps = json.load(f) |
| 68 | |
| 69 | # Compute averages per round and plot |
| 70 | model_to_avg = {} |
| 71 | for model, rounds_lists in model_to_round_steps.items(): |
| 72 | # pad/truncate |
no test coverage detected