2023-10-24 13:28:21 +00:00
|
|
|
#!/usr/bin/env python3
|
2023-03-28 18:47:38 +00:00
|
|
|
import glob
|
|
|
|
import pickle
|
|
|
|
import numpy as np
|
|
|
|
from matplotlib import pyplot as plt
|
|
|
|
|
|
|
|
plt.figure()
|
2023-03-28 20:22:48 +00:00
|
|
|
for fpath in glob.glob('./eval_data/*.pkl'):
|
2023-03-28 18:47:38 +00:00
|
|
|
parts = fpath.split('__')
|
2023-04-10 02:14:20 +00:00
|
|
|
model_name = "-".join(fpath.replace(".pkl", "").split("_")[2:])
|
2023-03-28 18:47:38 +00:00
|
|
|
with open(fpath, 'rb') as f:
|
|
|
|
data = pickle.load(f)
|
|
|
|
perplexities = data['perplexities']
|
|
|
|
perplexities = np.nan_to_num(perplexities, 100)
|
|
|
|
perplexities = np.clip(perplexities, 0, 100)
|
2023-04-10 02:14:20 +00:00
|
|
|
if 'alpaca' not in fpath:
|
|
|
|
identifier = model_name = "-".join(fpath.replace(".pkl", "").split("eval__model-")[1:])
|
|
|
|
label = 'GPT4all-'
|
|
|
|
label += identifier
|
|
|
|
|
2023-03-28 20:22:48 +00:00
|
|
|
else:
|
|
|
|
label = 'alpaca-lora'
|
2023-04-10 02:14:20 +00:00
|
|
|
plt.hist(perplexities, label=label, alpha=.5, bins=50)
|
2023-03-28 18:47:38 +00:00
|
|
|
|
|
|
|
plt.xlabel('Perplexity')
|
|
|
|
plt.ylabel('Frequency')
|
|
|
|
plt.legend()
|
|
|
|
plt.savefig('figs/perplexity_hist.png')
|
|
|
|
|