Datasets:

Languages:
English
Size:
< 1K
ArXiv:
Libraries:
Datasets
License:
File size: 1,417 Bytes
1bb8d13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
import json
from glob import glob
import pandas as pd
from datasets import load_dataset

os.makedirs("analysis/flan_ul2_additional_analysis", exist_ok=True)
data = load_dataset("cardiffnlp/relentless_full", split="test")
data = {i['relation_type']: i for i in data}

pred_zero = {}
for i in glob("results/lm_qa_zeroshot/flan-ul2/*.jsonl"):
    r = os.path.basename(i).replace("__", "/").replace("_", " ").replace("ppl.", "").replace("is ", "").replace(".jsonl", "")
    with open(i) as f:
        pred_zero[r] = [json.loads(l)['perplexity'] for l in f.read().split("\n")]

pred_few = {}
for i in glob("results/lm_qa_1shots_1seed/flan-ul2/*.jsonl"):
    r = os.path.basename(i).replace("__", "/").replace("_", " ").replace("ppl.", "").replace("is ", "").replace(".jsonl", "")
    with open(i) as f:
        pred_few[r] = [json.loads(l)['perplexity'] for l in f.read().split("\n")]


def get_rank(score):
    s2r = {s: n for n, s in enumerate(sorted(score))}
    return [s2r[s] for s in score]

for k, v in data.items():
    df = pd.DataFrame({
        "pairs": v['pairs'],
        "score_fewshot": pred_few[k],
        "score_zeroshot": pred_zero[k],
        "score_true": v["scores_mean"],
        "rank_fewshot": get_rank(pred_few[k]),
        "rank_zeroshot": get_rank(pred_zero[k]),
        "rank_true": v["ranks"],
    })
    df.to_csv(f"analysis/flan_ul2_additional_analysis/{k[:4]}.csv", index=False)