init
Browse files
experiments/baseline_relbert.py
CHANGED
|
@@ -21,14 +21,14 @@ for lm in ['base', 'large']:
|
|
| 21 |
scorer = None
|
| 22 |
for d in data:
|
| 23 |
ppl_file = f"experiments/results/relbert/relbert-roberta-{lm}/ppl.{d['relation_type'].replace(' ', '_').replace('/', '__')}.jsonl"
|
| 24 |
-
anchor_embeddings = [(a, b) for a, b in d['
|
| 25 |
option_embeddings = [(x, y) for x, y in d['pairs']]
|
| 26 |
|
| 27 |
if not os.path.exists(ppl_file):
|
| 28 |
|
| 29 |
if scorer is None:
|
| 30 |
scorer = RelBERT(f"relbert/relbert-roberta-{lm}")
|
| 31 |
-
anchor_embeddings = scorer.get_embedding(d['
|
| 32 |
option_embeddings = scorer.get_embedding(d['pairs'], batch_size=64)
|
| 33 |
similarity = [[cosine_similarity(a, b) for b in anchor_embeddings] for a in option_embeddings]
|
| 34 |
output = [{"similarity": s} for s in similarity]
|
|
|
|
| 21 |
scorer = None
|
| 22 |
for d in data:
|
| 23 |
ppl_file = f"experiments/results/relbert/relbert-roberta-{lm}/ppl.{d['relation_type'].replace(' ', '_').replace('/', '__')}.jsonl"
|
| 24 |
+
anchor_embeddings = [(a, b) for a, b in d['prototypical_examples']]
|
| 25 |
option_embeddings = [(x, y) for x, y in d['pairs']]
|
| 26 |
|
| 27 |
if not os.path.exists(ppl_file):
|
| 28 |
|
| 29 |
if scorer is None:
|
| 30 |
scorer = RelBERT(f"relbert/relbert-roberta-{lm}")
|
| 31 |
+
anchor_embeddings = scorer.get_embedding(d['prototypical_examples'])
|
| 32 |
option_embeddings = scorer.get_embedding(d['pairs'], batch_size=64)
|
| 33 |
similarity = [[cosine_similarity(a, b) for b in anchor_embeddings] for a in option_embeddings]
|
| 34 |
output = [{"similarity": s} for s in similarity]
|