Download docs/development-artifacts/depth-step-v1/plot-patch-delta-source.py from zsqzz/llm-memory-editability: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/datasets/zsqzz/llm-memory-editability/resolve/main/docs/development-artifacts/depth-step-v1/plot-patch-delta-source.py
- Command line
-
hf download hf://datasets/zsqzz/llm-memory-editability/docs/development-artifacts/depth-step-v1/plot-patch-delta-source.py
-
curl -L -o plot-patch-delta-source.py https://huggingface.co/datasets/zsqzz/llm-memory-editability/resolve/main/docs/development-artifacts/depth-step-v1/plot-patch-delta-source.py
1.53 kB
| """Post-run baseline-adjusted view of the frozen intervention measurements.""" | |
| import json | |
| from pathlib import Path | |
| import matplotlib | |
| matplotlib.use("Agg") | |
| from matplotlib import pyplot as plt | |
| folder = Path(__file__).resolve().parent | |
| audit = json.loads((folder / "independent-audit.json").read_text()) | |
| fig, ax = plt.subplots(figsize=(6.5, 3.6)) | |
| for model, color in (("standard2", "#2467a2"), ("loop2", "#d56a22")): | |
| for component, marker in (("mlp_delta", "o"), ("postresidual", "s")): | |
| cells = [ | |
| row | |
| for row in audit["patch_baseline_adjusted_descriptive_scores"] | |
| if row["state"].startswith(model) and row["component"] == component | |
| ] | |
| cells.sort(key=lambda row: int(row["state"].rsplit("s", 1)[1])) | |
| ax.plot( | |
| [int(row["state"].rsplit("s", 1)[1]) for row in cells], | |
| [100 * row["accuracy_delta"] for row in cells], | |
| marker=marker, | |
| color=color, | |
| linestyle="-" if component == "mlp_delta" else "--", | |
| label=f"{model} {component}", | |
| ) | |
| ax.axhline(0, color="black", linewidth=0.8) | |
| ax.set_xticks([8000, 32000, 64000], ["8k", "32k", "64k"]) | |
| ax.set_xlabel("Parent checkpoint training updates") | |
| ax.set_ylabel("Alternative-route accuracy change (pp)") | |
| ax.set_title("First-block r1 patch minus native alternative-route accuracy") | |
| ax.grid(alpha=0.2) | |
| ax.legend(fontsize=8) | |
| fig.tight_layout() | |
| for suffix in ("png", "pdf"): | |
| fig.savefig(folder / f"patch-delta.{suffix}", dpi=180) | |
| plt.close(fig) | |