Spaces:
Runtime error
Runtime error
Yeonchan Ahn
commited on
Commit
β’
3e9504c
1
Parent(s):
2f32607
remove error
Browse files
cosine_sim_btw_embeddings_of_same_semantics.py
CHANGED
@@ -22,7 +22,7 @@ Examples:
|
|
22 |
|
23 |
Example 1-A simple example
|
24 |
>>> cos_similarity_metrics = evaluate.load("ahnyeonchan/cosine_sim_btw_embeddings_of_same_semantics")
|
25 |
-
>>> results =
|
26 |
>>> print(results)
|
27 |
{'cos_similarity': 1.0}
|
28 |
"""
|
@@ -66,7 +66,7 @@ class CosSim(evaluate.Metric):
|
|
66 |
raise NotImplementedError()
|
67 |
|
68 |
cosims = self.cossim(predictions, references)
|
69 |
-
val = torch.mean(
|
70 |
|
71 |
return {
|
72 |
"cos_similarity": float(val)
|
|
|
22 |
|
23 |
Example 1-A simple example
|
24 |
>>> cos_similarity_metrics = evaluate.load("ahnyeonchan/cosine_sim_btw_embeddings_of_same_semantics")
|
25 |
+
>>> results = cos_similarity_metrics.compute(references=[[1.0, 1.0], [0.0, 1.0]], predictions=[[1.0, 1.0], [0.0, 1.0]])
|
26 |
>>> print(results)
|
27 |
{'cos_similarity': 1.0}
|
28 |
"""
|
|
|
66 |
raise NotImplementedError()
|
67 |
|
68 |
cosims = self.cossim(predictions, references)
|
69 |
+
val = torch.mean(cosims).item()
|
70 |
|
71 |
return {
|
72 |
"cos_similarity": float(val)
|