import os import matplotlib as mpl import matplotlib.pyplot as plt import pandas as pd from random import shuffle, seed maps = {"competitor/rival of": "Rival", "friend/ally of": "Ally", "influenced by": "Inf", "known for": "Know", "similar to": "Sim", "average": "Avg"} # Few-shots + Zero-shot os.makedirs('figures/fewshots', exist_ok=True) plt.rcParams.update({'font.size': 16}) # must set in top # styles = ['o-', 'o--', 'o:', 's-', 's--', 's:', '^-', '^--', '^:', "X-", "X--", "X:"] 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"results/lm_{prompt}_zeroshot.csv", index_col=0), pd.read_csv(f"results/lm_{prompt}_fewshots.csv", index_col=0)]) df_full = pd.read_csv(f"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 (13B)" m = "OPT" if "Flan-T5" in m: # m = "Flan-T5 (XXL)" m = "Flan-T5" if "GPT-3" in m: # m = "GPT-3 (davinci)" m = "GPT-3" ax = g.plot.line(y=r, x='shot', # xlabel='Number of Prototypical Examples', # xlabel='Num. of Proto. Examples', # ylabel="Correlation", xlabel="", ylabel="", ax=ax, ms=8, color=colors[n], style=styles[n], label=m, # figsize=(4, 5), grid=True) ax.set_xticks([0, 1, 3, 5]) ax.legend(loc='lower right') plt.tight_layout() plt.savefig(f"figures/fewshots/{prompt}.{r.replace(' ', '_').replace('/', '-')}.fewshot.landscape.png", bbox_inches="tight", dpi=600)