Skip to content

Commit

Permalink
Merge branch 'main' into fix_minor_experiment_script
Browse files Browse the repository at this point in the history
  • Loading branch information
chanind committed May 21, 2024
2 parents d4fdef0 + b914302 commit 99199f0
Show file tree
Hide file tree
Showing 37 changed files with 4,891 additions and 652 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ output
# Data
*.sqlite
*.csv
*.gzip
# Dataset files
*.hdf5
*.json
Expand Down
72 changes: 72 additions & 0 deletions repepo/paper/compare_steerability_between_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# %%
"""
Assumes you have run repepo.paper.make_figurse_steering_ood for both models
"""

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from scipy.stats import spearmanr

sns.set_theme()

# Load the steerability data
llama7b_df = pd.read_parquet("llama7b_steerability_summary.parquet.gzip")
llama7b_df = llama7b_df.drop_duplicates()
qwen_df = pd.read_parquet("qwen_steerability_summary.parquet.gzip")
qwen_df = qwen_df.drop_duplicates()

combined = llama7b_df.merge(qwen_df, on="dataset_name", suffixes=("_llama7b", "_qwen"))

# %%
# Correlation in gen gap
sns.regplot(data=combined, x="gap_qwen", y="gap_llama7b")

# %%
# Correlation in steerability
fig, ax = plt.subplots()
sns.regplot(data=combined, x="steerability_id_qwen", y="steerability_id_llama7b")
# Draw the x = y line
x = combined["steerability_id_qwen"]
y = combined["steerability_id_llama7b"]

min = x.min() if x.min() < y.min() else y.min()
max = x.max() if x.max() > y.max() else y.max()
ax.plot([min, max], [min, max], color="black", linestyle="--")
plt.xlabel("Qwen ID steerability")
plt.ylabel("Llama7b ID steerability")

fig.suptitle("Steerability ID for Qwen and Llama7b")
fig.savefig("figures/id_steerability_correlation.png")
plt.show()

# Print the spearman correlation
result = spearmanr(
combined["steerability_id_qwen"], combined["steerability_id_llama7b"]
)
print(f"{result.statistic:.3f}")

# %%
# Correlation in ood steerability
fig, ax = plt.subplots()
sns.regplot(data=combined, x="steerability_ood_qwen", y="steerability_ood_llama7b")
# Draw the x = y line
x = combined["steerability_ood_qwen"]
y = combined["steerability_ood_qwen"]

min = x.min() if x.min() < y.min() else y.min()
max = x.max() if x.max() > y.max() else y.max()
ax.plot([min, max], [min, max], color="black", linestyle="--")
plt.xlabel("Qwen OOD steerability")
plt.ylabel("Llama7b OOD steerability")

fig.suptitle("Steerability OOD for Qwen and Llama7b")
fig.savefig("figures/ood_steerability_correlation.png")
plt.show()

result = spearmanr(
combined["steerability_ood_qwen"], combined["steerability_ood_llama7b"]
)
print(f"{result.statistic:.3f}")
# %%
1,702 changes: 1,062 additions & 640 deletions repepo/paper/fig_logit_diff_vs_multiplier.ipynb

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added repepo/paper/figures/fraction_anti_steerable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added repepo/paper/figures/fraction_positive_slope.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added repepo/paper/figures/llama7b_ood_best_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added repepo/paper/figures/llama7b_ood_worst_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified repepo/paper/figures/per_sample_steerability.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added repepo/paper/figures/qwen_ood_best_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added repepo/paper/figures/qwen_ood_worst_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added repepo/paper/figures/r2_vs_kurtosis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified repepo/paper/figures/slope_vs_response_is_A.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified repepo/paper/figures/slope_vs_response_is_Yes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added repepo/paper/figures/steerability_correlation.png
Loading

0 comments on commit 99199f0

Please sign in to comment.