anonymous commited on
Commit
4ea7bda
·
verified ·
1 Parent(s): bf90fdc

Upload tables/scripts/make_numbers.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. tables/scripts/make_numbers.py +30 -15
tables/scripts/make_numbers.py CHANGED
@@ -1,9 +1,9 @@
1
  """Emit the numbers the body quotes, as LaTeX macros, from the run outputs.
2
 
3
- Two files, both \input by paper.tex:
4
 
5
- sections/numbers.tex scalar macros (\PCTONE, \DIRECTIONPARA, ...)
6
- sections/table_null_body.tex the rows of Table 1
7
 
8
  Anything here is a number the reviewer can trace: it is read from the CSVs the
9
  runs wrote, never typed. Re-run after any rerun and diff the two files.
@@ -171,6 +171,12 @@ def main():
171
  per_step.append((lay, math.floor(min(sh)), math.ceil(max(sh))))
172
  L.append("\\newcommand{\\SHAREBYSTEP}{" + ", ".join(
173
  f"${lo}\\text{{--}}{hi}\\%$ at layer {lay}" for lay, lo, hi in per_step) + "}")
 
 
 
 
 
 
174
  print("null share across all seven steps: " + ", ".join(
175
  f"L{lay} {lo}-{hi}%" for lay, lo, hi in per_step))
176
 
@@ -179,7 +185,7 @@ def main():
179
  L.append(f"\\newcommand{{\\NMSEMAX}}{{{f['nmse']:.4f}}}")
180
  L.append(f"\\newcommand{{\\FRACRECMIN}}{{{f['frac_rec']:.3f}}}")
181
  L.append(f"\\newcommand{{\\DEADMAX}}{{{f['dead']:.1f}}}")
182
- L.append(f"\\newcommand{{\\SEPRATIO}}{{{min(ratios):.0f}$ to ${max(ratios):.0f}}}")
183
  # NSEEDS describes every row of Table 1, so it has to be the range across
184
  # layers, not layer 18's counts. L6 and L12 carry 3 null chains, L18 has 4;
185
  # printing "4/4" would overstate replication for two of the three rows.
@@ -188,25 +194,34 @@ def main():
188
  fmt = lambda x: f"${min(x)}$" if len(x) == 1 else f"${min(x)}$ to ${max(x)}$"
189
  L.append(f"\\newcommand{{\\NSEEDS}}{{{fmt(reals)} real and {fmt(nulls)} null "
190
  "chains per layer}")
 
 
 
 
 
 
 
 
 
 
 
191
  q = resid[(18, "1")]
192
  L.append(f"\\newcommand{{\\RESIDL}}{{${q.mean():.4f}$ "
193
  f"$[{q.min():.4f},{q.max():.4f}]$}}")
194
- L.append(f"\\newcommand{{\\RESIDRATIO}}{{{ratios[LAYERS.index(18)*2]:.0f}}}")
195
 
196
  d = direction(18)
197
  if d and 7 in d:
198
  end, one = d[7], d.get(1, d[7])
199
  L.append("\\newcommand{\\DIRECTIONPARA}{%\n"
200
- f"At layer 18, over {end['n_real']} real and {end['n_null']} null chains, "
201
- "the seven-step endpoints come apart completely "
202
- "(Figure~\\ref{fig:main}d). Two real chains agree with each other at a mean "
203
- f"per-latent decoder cosine of {rng(end['rr'])} and two null chains at "
204
- f"{rng(end['nn'])}, but a real chain agrees with a null chain at only "
205
- f"{rng(end['rn'])}. All ${len(end['rr'])+len(end['nn'])}$ within-arm pairs sit "
206
- f"above all ${len(end['rn'])}$ cross-arm pairs, and they still do after a "
207
- "single step. So fine-tuning leaves a reproducible signature in the "
208
- "\\emph{direction} of the move, which the magnitude gives no way to isolate "
209
- "because retraining supplies most of it.}")
210
  print(f"direction: step7 rr={end['rr'].mean():.4f} nn={end['nn'].mean():.4f} "
211
  f"rn={end['rn'].mean():.4f} separated={end['separated']}")
212
  else:
 
1
  """Emit the numbers the body quotes, as LaTeX macros, from the run outputs.
2
 
3
+ One file, \input by paper.tex:
4
 
5
+ sections/numbers.tex scalar macros (\PCTONE, \DIRECTIONPARA, ...) and
6
+ \TABBODY, the rows of Table 2
7
 
8
  Anything here is a number the reviewer can trace: it is read from the CSVs the
9
  runs wrote, never typed. Re-run after any rerun and diff the two files.
 
171
  per_step.append((lay, math.floor(min(sh)), math.ceil(max(sh))))
172
  L.append("\\newcommand{\\SHAREBYSTEP}{" + ", ".join(
173
  f"${lo}\\text{{--}}{hi}\\%$ at layer {lay}" for lay, lo, hi in per_step) + "}")
174
+ # The body quotes the envelope over every step and layer; the per-layer
175
+ # breakdown above is kept for the appendix.
176
+ if per_step:
177
+ blo = min(lo for _, lo, _ in per_step)
178
+ bhi = max(hi for _, _, hi in per_step)
179
+ L.append(f"\\newcommand{{\\SHAREBAND}}{{${blo}\\text{{--}}{bhi}\\%$}}")
180
  print("null share across all seven steps: " + ", ".join(
181
  f"L{lay} {lo}-{hi}%" for lay, lo, hi in per_step))
182
 
 
185
  L.append(f"\\newcommand{{\\NMSEMAX}}{{{f['nmse']:.4f}}}")
186
  L.append(f"\\newcommand{{\\FRACRECMIN}}{{{f['frac_rec']:.3f}}}")
187
  L.append(f"\\newcommand{{\\DEADMAX}}{{{f['dead']:.1f}}}")
188
+ L.append(f"\\newcommand{{\\SEPRATIO}}{{{math.floor(min(ratios))}$ to ${math.ceil(max(ratios))}}}")
189
  # NSEEDS describes every row of Table 1, so it has to be the range across
190
  # layers, not layer 18's counts. L6 and L12 carry 3 null chains, L18 has 4;
191
  # printing "4/4" would overstate replication for two of the three rows.
 
194
  fmt = lambda x: f"${min(x)}$" if len(x) == 1 else f"${min(x)}$ to ${max(x)}$"
195
  L.append(f"\\newcommand{{\\NSEEDS}}{{{fmt(reals)} real and {fmt(nulls)} null "
196
  "chains per layer}")
197
+ rerun_dead = {}
198
+ for lay in LAYERS:
199
+ csvp = DRIFT / f"real_arm_L{lay}" / "real_arm_replicate.csv"
200
+ if csvp.exists():
201
+ v = pd.read_csv(csvp)["dead_frac"] * 100
202
+ rerun_dead[lay] = (math.floor(v.min()), math.ceil(v.max()))
203
+ if 18 in rerun_dead and 12 in rerun_dead:
204
+ L.append("\\newcommand{\\RERUNDEAD}{$%d$ to $%d\\%%$ at layer 18 and $%d$ to $%d\\%%$ "
205
+ "at layer 12}" % (*rerun_dead[18], *rerun_dead[12]))
206
+ print(f"rerun dead fractions: L18 {rerun_dead[18]}, L12 {rerun_dead[12]}")
207
+
208
  q = resid[(18, "1")]
209
  L.append(f"\\newcommand{{\\RESIDL}}{{${q.mean():.4f}$ "
210
  f"$[{q.min():.4f},{q.max():.4f}]$}}")
211
+ L.append(f"\\newcommand{{\\RESIDRATIO}}{{{math.floor(ratios[LAYERS.index(18)*2])}}}")
212
 
213
  d = direction(18)
214
  if d and 7 in d:
215
  end, one = d[7], d.get(1, d[7])
216
  L.append("\\newcommand{\\DIRECTIONPARA}{%\n"
217
+ f"At layer 18, over {end['n_real']} real and {end['n_null']} null chains, two "
218
+ f"real endpoints agree at a mean matched-latent cosine of "
219
+ f"${end['rr'].mean():.3f}$, two null endpoints at ${end['nn'].mean():.3f}$, and "
220
+ f"a real endpoint with a null endpoint at only ${end['rn'].mean():.3f}$. Every "
221
+ "within-arm pair therefore exceeds every real--null pair, both after the first "
222
+ "step and after the seventh (Figure~\\ref{fig:main}b). Changes in the model "
223
+ "activations affect the direction of SAE movement, even though retraining "
224
+ "accounts for most of its magnitude.}")
 
 
225
  print(f"direction: step7 rr={end['rr'].mean():.4f} nn={end['nn'].mean():.4f} "
226
  f"rn={end['rn'].mean():.4f} separated={end['separated']}")
227
  else: