init
Browse files
experiments/baseline_fasttext.py
CHANGED
|
@@ -39,10 +39,10 @@ def get_vector(_model, _word_a, _word_b):
|
|
| 39 |
# load dataset
|
| 40 |
data = load_dataset("cardiffnlp/relentless", split="test")
|
| 41 |
full_result = []
|
| 42 |
-
os.makedirs("
|
| 43 |
scorer = None
|
| 44 |
for d in data:
|
| 45 |
-
ppl_file = f"
|
| 46 |
|
| 47 |
anchor_embeddings = [(a, b) for a, b in d['prototypical_examples']]
|
| 48 |
option_embeddings = [(x, y) for x, y in d['pairs']]
|
|
@@ -81,13 +81,11 @@ for d in data:
|
|
| 81 |
cor_min = tmp.corr("spearman").values[0, 2]
|
| 82 |
cor_mean = tmp.corr("spearman").values[0, 3]
|
| 83 |
full_result.append({"model": "fastText\textsubscript{pair}", "relation_type": d['relation_type'], "correlation": cor_max})
|
| 84 |
-
# full_result.append({"model": "fasttext (min)", "relation_type": d['relation_type'], "correlation": cor_min})
|
| 85 |
-
# full_result.append({"model": "fastText", "relation_type": d['relation_type'], "correlation": cor_mean})
|
| 86 |
|
| 87 |
df = pd.DataFrame(full_result)
|
| 88 |
df = df.pivot(columns="relation_type", index="model", values="correlation")
|
| 89 |
df['average'] = df.mean(1)
|
| 90 |
-
df.to_csv("
|
| 91 |
df = (100 * df).round()
|
| 92 |
print(df.to_markdown())
|
| 93 |
print(df.to_latex())
|
|
|
|
| 39 |
# load dataset
|
| 40 |
data = load_dataset("cardiffnlp/relentless", split="test")
|
| 41 |
full_result = []
|
| 42 |
+
os.makedirs("results/word_embedding/fasttext", exist_ok=True)
|
| 43 |
scorer = None
|
| 44 |
for d in data:
|
| 45 |
+
ppl_file = f"results/word_embedding/fasttext/ppl.{d['relation_type'].replace(' ', '_').replace('/', '__')}.jsonl"
|
| 46 |
|
| 47 |
anchor_embeddings = [(a, b) for a, b in d['prototypical_examples']]
|
| 48 |
option_embeddings = [(x, y) for x, y in d['pairs']]
|
|
|
|
| 81 |
cor_min = tmp.corr("spearman").values[0, 2]
|
| 82 |
cor_mean = tmp.corr("spearman").values[0, 3]
|
| 83 |
full_result.append({"model": "fastText\textsubscript{pair}", "relation_type": d['relation_type'], "correlation": cor_max})
|
|
|
|
|
|
|
| 84 |
|
| 85 |
df = pd.DataFrame(full_result)
|
| 86 |
df = df.pivot(columns="relation_type", index="model", values="correlation")
|
| 87 |
df['average'] = df.mean(1)
|
| 88 |
+
df.to_csv("results/word_embedding/fasttext.csv")
|
| 89 |
df = (100 * df).round()
|
| 90 |
print(df.to_markdown())
|
| 91 |
print(df.to_latex())
|
experiments/baseline_fasttext_zeroshot.py
CHANGED
|
@@ -33,10 +33,10 @@ def cosine_similarity(a, b):
|
|
| 33 |
# load dataset
|
| 34 |
data = load_dataset("cardiffnlp/relentless", split="test")
|
| 35 |
full_result = []
|
| 36 |
-
os.makedirs("
|
| 37 |
scorer = None
|
| 38 |
for d in data:
|
| 39 |
-
ppl_file = f"
|
| 40 |
|
| 41 |
anchor_embeddings = [(a, b) for a, b in d['prototypical_examples']]
|
| 42 |
option_embeddings = [(x, y) for x, y in d['pairs']]
|
|
@@ -65,7 +65,7 @@ for d in data:
|
|
| 65 |
df = pd.DataFrame(full_result)
|
| 66 |
df = df.pivot(columns="relation_type", index="model", values="correlation")
|
| 67 |
df['average'] = df.mean(1)
|
| 68 |
-
df.to_csv("
|
| 69 |
df = (100 * df).round()
|
| 70 |
print(df.to_markdown())
|
| 71 |
print(df.to_latex())
|
|
|
|
| 33 |
# load dataset
|
| 34 |
data = load_dataset("cardiffnlp/relentless", split="test")
|
| 35 |
full_result = []
|
| 36 |
+
os.makedirs("results/word_embedding/fasttext_zeroshot", exist_ok=True)
|
| 37 |
scorer = None
|
| 38 |
for d in data:
|
| 39 |
+
ppl_file = f"results/word_embedding/fasttext_zeroshot/ppl.{d['relation_type'].replace(' ', '_').replace('/', '__')}.jsonl"
|
| 40 |
|
| 41 |
anchor_embeddings = [(a, b) for a, b in d['prototypical_examples']]
|
| 42 |
option_embeddings = [(x, y) for x, y in d['pairs']]
|
|
|
|
| 65 |
df = pd.DataFrame(full_result)
|
| 66 |
df = df.pivot(columns="relation_type", index="model", values="correlation")
|
| 67 |
df['average'] = df.mean(1)
|
| 68 |
+
df.to_csv("results/word_embedding/fasttext_zeroshot.csv")
|
| 69 |
df = (100 * df).round()
|
| 70 |
print(df.to_markdown())
|
| 71 |
print(df.to_latex())
|