Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update plot with some fixes #43

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[WIP] Update
  • Loading branch information
ljvmiranda921 committed Oct 8, 2024
commit 6852fd607148692269a05996ea894e587f12b3d8
18 changes: 11 additions & 7 deletions analysis/plot_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,30 +112,34 @@ def plot_eng_drop_line(
df = df[["Model", "Model_Type", "eng_Latn", "Avg_Multilingual"]]
df = df.sort_values(by="Avg_Multilingual", ascending=False).reset_index(drop=True)
data = df.set_index("Model").dropna()
data = data[["eng_Latn", "Avg_Multilingual"]] * 100
model_types = df.dropna().pop("Model_Type")
data[data.select_dtypes(include="number").columns] = data.select_dtypes(include="number") * 100
data["Model_Type"] = data["Model_Type"].replace({"DPO": "Implicit RM", "Sequence Classifier": "Classifier RM"})
if top_n:
logging.info(f"Showing top {top_n}")
data = data.head(top_n)
model_types = model_types[:top_n]

fig, ax = plt.subplots(figsize=figsize)

colors = ["red", "green", "blue"]
for (label, group), colors in zip(data.groupby("Model_Type"), colors):
mrewardbench_scores = group["Avg_Multilingual"]
rewardbench_scores = group["eng_Latn"]
ax.scatter(rewardbench_scores, mrewardbench_scores, marker="o", s=30, label=label)

mrewardbench_scores = data["Avg_Multilingual"]
rewardbench_scores = data["eng_Latn"]
r, _ = pearsonr(mrewardbench_scores, rewardbench_scores)
res = spearmanr(mrewardbench_scores, rewardbench_scores)

colormap = {"Generative RM": "green", "Sequence Classifier": "blue", "DPO": "red"}
colors = [colormap[model_type] for model_type in model_types]

ax.scatter(rewardbench_scores, mrewardbench_scores, marker="o", s=30, color=colors)
# ax.scatter(rewardbench_scores, mrewardbench_scores, marker="o", s=30, color=colors, label=model_types)

min_val = min(rewardbench_scores.min(), mrewardbench_scores.min())
max_val = max(rewardbench_scores.max(), mrewardbench_scores.max())
ax.plot([min_val, max_val], [min_val, max_val], linestyle="--", color="black", alpha=0.25)
ax.set_xlabel("RewardBench (Lambert et al., 2024)")
ax.set_ylabel("M-RewardBench")
ax.set_aspect("equal")
ax.legend()

model_names = [model.split("/")[1] for model in data.index]
texts = [
Expand Down