Download plot_reward_pass8.py from penfever/qwen3coder-iris-rl-data-sweep-artifacts: direct link, hf CLI and curl.
- Browser
- Download file 2.24 kB
-
https://huggingface.co/datasets/penfever/qwen3coder-iris-rl-data-sweep-artifacts/resolve/main/plot_reward_pass8.py
- Command line
-
hf download hf://datasets/penfever/qwen3coder-iris-rl-data-sweep-artifacts/plot_reward_pass8.py
-
curl -L -o plot_reward_pass8.py https://huggingface.co/datasets/penfever/qwen3coder-iris-rl-data-sweep-artifacts/resolve/main/plot_reward_pass8.py
2.24 kB
| #!/usr/bin/env python3 | |
| """Render the admitted reward and pass@8 history for preserved RL runs.""" | |
| import argparse | |
| from pathlib import Path | |
| import matplotlib.pyplot as plt | |
| import pandas as pd | |
| def main() -> None: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("metrics", type=Path) | |
| parser.add_argument("output_dir", type=Path) | |
| parser.add_argument("--title", required=True) | |
| args = parser.parse_args() | |
| metrics = pd.read_csv(args.metrics) | |
| surface = metrics[["global_step", "reward/avg_raw_reward", "reward/avg_pass_at_8"]].rename( | |
| columns={ | |
| "global_step": "step", | |
| "reward/avg_raw_reward": "reward", | |
| "reward/avg_pass_at_8": "pass_at_8", | |
| } | |
| ) | |
| args.output_dir.mkdir(parents=True, exist_ok=True) | |
| surface.to_csv(args.output_dir / "reward-pass8.csv", index=False) | |
| plt.rcParams.update({"font.size": 11, "axes.titleweight": "semibold"}) | |
| figure, axis = plt.subplots(figsize=(8.2, 4.8), constrained_layout=True) | |
| axis.plot(surface["step"], surface["reward"], color="#1261a0", marker="o", linewidth=2.2, label="Admitted reward") | |
| axis.plot( | |
| surface["step"], | |
| surface["pass_at_8"], | |
| color="#a34a28", | |
| marker="s", | |
| linestyle="--", | |
| linewidth=2.0, | |
| label="Pass@8", | |
| ) | |
| for row in surface.itertuples(index=False): | |
| axis.annotate(f"{row.reward:.3f}", (row.step, row.reward), xytext=(0, -18), textcoords="offset points", ha="center") | |
| axis.set_title(args.title, loc="left") | |
| axis.set_xlabel("Optimizer step") | |
| axis.set_ylabel("Score") | |
| axis.set_xticks(surface["step"].astype(int)) | |
| axis.set_ylim(0, 1.08) | |
| axis.grid(axis="y", color="#d9dee5", linewidth=0.8) | |
| axis.spines[["top", "right"]].set_visible(False) | |
| axis.legend(loc="lower left", frameon=False, ncols=2) | |
| axis.text( | |
| 1.0, | |
| -0.18, | |
| "Pass@8 is 1.0 at all three admitted steps.", | |
| transform=axis.transAxes, | |
| ha="right", | |
| color="#4a5568", | |
| fontsize=9, | |
| ) | |
| figure.savefig(args.output_dir / "reward-pass8.png", dpi=180) | |
| figure.savefig(args.output_dir / "reward-pass8.svg") | |
| plt.close(figure) | |
| if __name__ == "__main__": | |
| main() | |