File size: 2,143 Bytes
1ffffb3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
"""Minimal SciAgentTrace download, trace lookup, and matched analysis."""

from itertools import islice

from datasets import load_dataset


REPO_ID = "AgentsSci/scientific-agent-protocol-traces"
MATCHED_PROTOCOLS = {
    "baseline_llm",
    "single_agent",
    "per",
    "broadcast",
}
ACTOR_MODELS = {"gemma_4_31b", "gpt_oss_120b"}


def main() -> None:
    trajectories = load_dataset(REPO_ID, "trajectories", split="test")
    matched = load_dataset(REPO_ID, "matched_outcomes", split="test")

    comparison = trajectories.filter(
        lambda row: row["protocol_id"] in MATCHED_PROTOCOLS
        and row["actor_model_id"] in ACTOR_MODELS
        and row["slice_id"]
        in {"competition_math_4181", "text_only", "llm_strict"}
    )
    frame = comparison.to_pandas()
    summary = (
        frame.groupby(["actor_model_id", "benchmark_id", "protocol_id"])
        .agg(
            trajectories=("trajectory_uid", "size"),
            accuracy=("final_correct", "mean"),
            median_elapsed_seconds=("wall_time_seconds", "median"),
        )
        .reset_index()
    )
    print(summary.to_string(index=False))
    print(f"matched problem/model groups: {len(matched):,}")

    paired = matched.filter(
        lambda row: row["actor_model_id"] == "gemma_4_31b"
        and row["benchmark_id"] == "omnimath2"
    ).to_pandas()
    baseline_rate = paired["baseline_correct"].mean()
    single_rate = paired["single_correct"].mean()
    print(
        "Gemma 4 31B on OmniMath2, paired Single-Agent Iterative minus "
        f"Direct Baseline: {100 * (single_rate - baseline_rate):.2f} percentage points"
    )

    example = comparison[0]
    trajectory_uid = example["trajectory_uid"]
    message_stream = load_dataset(
        REPO_ID, "messages", split="test", streaming=True
    )
    trace = islice(
        (row for row in message_stream if row["trajectory_uid"] == trajectory_uid),
        20,
    )
    print(f"\nfirst events for {trajectory_uid}:")
    for event in trace:
        print(event["sequence_index"], event["role"], event["content"][:160])


if __name__ == "__main__":
    main()