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