import os import matplotlib as mpl import matplotlib.pyplot as plt import pandas as pd from random import shuffle, seed # LM model_size = { "T5\textsubscript{SMALL}": [60, "T5"], "T5\textsubscript{BASE}": [200, "T5"], "T5\textsubscript{LARGE}": [770, "T5"], "T5\textsubscript{XL}": [3000, "T5"], "T5\textsubscript{XXL}": [11000, "T5"], "Flan-T5\textsubscript{SMALL}": [60, "Flan-T5"], "Flan-T5\textsubscript{BASE}": [200, "Flan-T5"], "Flan-T5\textsubscript{LARGE}": [770, "Flan-T5"], "Flan-T5\textsubscript{XL}": [3000, "Flan-T5"], "Flan-T5\textsubscript{XXL}": [11000, "Flan-T5"], "OPT\textsubscript{125M}": [125, "OPT"], "OPT\textsubscript{350M}": [350, "OPT"], "OPT\textsubscript{1.3B}": [1300, "OPT"], "OPT\textsubscript{2.7B}": [2700, "OPT"], "OPT\textsubscript{6.7B}": [6700, "OPT"], "OPT\textsubscript{13B}": [13000, "OPT"], "OPT\textsubscript{30B}": [30000, "OPT"], "OPT\textsubscript{66B}": [66000, "OPT"], "OPT-IML\textsubscript{1.3B}": [1300, "OPT-IML"], "OPT-IML\textsubscript{30B}": [30000, "OPT-IML"], } lm_list = ['T5', 'Flan-T5', 'OPT', 'OPT-IML'] # Oracle df_oracle = pd.read_csv("results/oracle.csv", index_col=0) # Plot os.makedirs('figures/main', exist_ok=True) plt.rcParams.update({'font.size': 16}) # must set in top def main(target_relation: str = "average", prompt_type: str = "lc"): df = pd.read_csv(f"results/lm_{prompt_type}/lm.csv") df.index = df.pop("model") df = (df * 100).round(1) df = df[[i in model_size for i in df.index]] df["size"] = [model_size[i][0] * 1000000 for i in df.index] df["lm"] = [model_size[i][1] for i in df.index] df_target = df[[target_relation, "size", "lm"]] out = df_target.pivot_table(index='size', columns='lm', aggfunc='mean') out.columns = [i[1] for i in out.columns] out = out.reset_index() out = out[['size'] + lm_list] styles = ['o-', '^--', 'X:', "P:"] seed(1) colors = list(mpl.colormaps['tab20b'].colors) shuffle(colors) ax = None for n, c in enumerate(lm_list): tmp = out[['size', c]].dropna().reset_index() ax = tmp.plot.line(y=c, x='size', xlabel='Model Size', ylabel="Correlation", ax=ax, color=colors[n], style=styles[n], label=c, logx=True, grid=True) # ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)) plt.tight_layout() plt.savefig(f"figures/main/{prompt_type}.{target_relation.replace(' ', '_').replace('/', '-')}.landscape.png", bbox_inches="tight", dpi=600) if __name__ == '__main__': for p in ['lc', 'qa']: main('average', p) main("competitor/rival of", p) main("friend/ally of", p) main("influenced by", p) main("known for", p) main("similar to", p)