Skip to content

Commit e695136

Browse files
committed
.
1 parent 39c8f5a commit e695136

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

codeclash/analysis/llm_as_judge/get_instances.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
"""Get instances based on specific pattern."""
44

55
import argparse
6-
from pathlib import Path
76
from collections import defaultdict
8-
from pyexpat import model
7+
from pathlib import Path
98

109
from codeclash.analysis.llm_as_judge.utils import InstanceBatch, get_instances
1110

@@ -16,14 +15,19 @@
1615
args = parser.parse_args()
1716

1817
SELECTED_ROUNDS = [1, 2, 3, 5, 10, 12, 14, 15]
19-
SELECTED_GAME = "BattleSnake"
20-
NUMBER_OF_INDEPENDENT_GAMES = 3
18+
SELECTED_GAMES = ["BattleSnake"] # Set to None to select all games
19+
NUMBER_OF_TOURNAMENTS = 3
2120

2221
# first get all instances, then filter
2322
instances = sorted(get_instances(args.input_dir), key=lambda x: x.instance_id)
2423
print(f"Found {len(instances)} instances")
25-
instances = [instance for instance in instances if SELECTED_GAME in instance.tournament_name]
26-
print(f"Filtered to {len(instances)} instances because of game name")
24+
if SELECTED_GAMES is not None:
25+
instances = [
26+
instance for instance in instances if any(game in instance.tournament_name for game in SELECTED_GAMES)
27+
]
28+
print(f"Filtered to {len(instances)} instances because of game name")
29+
else:
30+
print("No game filtering applied (SELECTED_GAMES is None)")
2731
instances = [instance for instance in instances if instance.round_number in SELECTED_ROUNDS]
2832
print(f"Filtered to {len(instances)} instances because of round number")
2933

@@ -34,17 +38,19 @@
3438
continue
3539
key = (model_name_player, model_name_opponent, instance.round_number)
3640
grouped[key].append(instance)
37-
41+
3842
selected_instances = []
3943
for key, instance_list in grouped.items():
40-
if len(instance_list) < NUMBER_OF_INDEPENDENT_GAMES:
41-
print(f"Warning: Only found {len(instance_list)} instances for {key}, need {NUMBER_OF_INDEPENDENT_GAMES}")
42-
selected_count = min(len(instance_list), NUMBER_OF_INDEPENDENT_GAMES)
44+
if len(instance_list) < NUMBER_OF_TOURNAMENTS:
45+
print(f"Warning: Only found {len(instance_list)} instances for {key}, need {NUMBER_OF_TOURNAMENTS}")
46+
selected_count = min(len(instance_list), NUMBER_OF_TOURNAMENTS)
4347
selected_instances.extend(instance_list[:selected_count])
44-
48+
4549
instances = selected_instances
46-
unique_models = set([instance.get_lm_name_self_opponent()[0] for instance in instances])
47-
print(f"Filtered to {len(instances)} instances after keeping {NUMBER_OF_INDEPENDENT_GAMES} for game repetitions for {len(unique_models)} unique model matchups")
50+
unique_models = {instance.get_lm_name_self_opponent()[0] for instance in instances}
51+
print(
52+
f"Filtered to {len(instances)} instances after keeping {NUMBER_OF_TOURNAMENTS} for game repetitions for {len(unique_models)} unique model matchups"
53+
)
4854

4955
batch = InstanceBatch(instances=instances)
5056
args.output_file.write_text(batch.model_dump_json())

0 commit comments

Comments
 (0)