ChihHsuan-Yang's picture
Upload folder using huggingface_hub
1ffffb3 verified
Raw History Blame Contribute Delete
2.14 kB
#!/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()