|
import os |
|
import matplotlib as mpl |
|
import matplotlib.pyplot as plt |
|
import pandas as pd |
|
from random import shuffle, seed |
|
|
|
maps = {"is competitor/rival of": "Rival", "is friend/ally of": "Ally", "is influenced by": "Inf", "is known for": "Know", "is similar to": "Sim", |
|
"average": "Avg"} |
|
|
|
os.makedirs('experiments/figures/fewshots', exist_ok=True) |
|
plt.rcParams.update({'font.size': 16}) |
|
|
|
styles = ['o', "X", '^', 'P'] |
|
seed(1) |
|
colors = list(mpl.colormaps['tab20b'].colors) |
|
shuffle(colors) |
|
for prompt in ['qa', 'lc']: |
|
df = pd.concat([ |
|
pd.read_csv(f"experiments/results/lm_{prompt}_zeroshot.csv", index_col=0), |
|
pd.read_csv(f"experiments/results/lm_{prompt}_fewshots.csv", index_col=0)]) |
|
|
|
df_full = pd.read_csv(f"experiments/results/lm_{prompt}/lm.csv", index_col=0) |
|
for r in maps: |
|
tmp = df[[r, "shot", "seed"]] |
|
tmp[r] = tmp[r] * 100 |
|
ax = None |
|
for n, m in enumerate(['Flan-T5\textsubscript{XXL}', 'Flan-UL2', 'OPT\textsubscript{13B}', 'GPT-3\textsubscript{davinci}']): |
|
|
|
g = tmp.loc[m] |
|
full_shot = df_full[[r]].loc[[m]] * 100 |
|
full_shot["shot"] = 5 |
|
full_shot["seed"] = 0 |
|
g = pd.concat([g, full_shot]) |
|
if "OPT" in m: |
|
|
|
m = "OPT" |
|
if "Flan-T5" in m: |
|
|
|
m = "Flan-T5" |
|
if "GPT-3" in m: |
|
|
|
m = "GPT-3" |
|
ax = g.plot.line(y=r, |
|
x='shot', |
|
|
|
|
|
|
|
xlabel="", |
|
ylabel="", |
|
ax=ax, |
|
ms=8, |
|
color=colors[n], |
|
style=styles[n], |
|
label=m, |
|
|
|
grid=True) |
|
ax.set_xticks([0, 1, 3, 5]) |
|
ax.legend(loc='lower right') |
|
plt.tight_layout() |
|
plt.savefig(f"experiments/figures/fewshots/{prompt}.{r.replace(' ', '_').replace('/', '-')}.fewshot.landscape.png", bbox_inches="tight", dpi=600) |
|
|
|
|