Spaces:
Build error
Build error
Update space name
Browse files- README.md +5 -5
- vendiscore.py +1 -1
README.md
CHANGED
@@ -41,7 +41,7 @@ pip install vendi_score[all]
|
|
41 |
```
|
42 |
To calculate the score, pass a list of samples and a similarity function or a string identifying a predefined class of similarity functions (see below).
|
43 |
```
|
44 |
-
>>> vendiscore = evaluate.load("
|
45 |
>>> samples = ["Look, Jane.",
|
46 |
"See Spot.",
|
47 |
"See Spot run.",
|
@@ -86,7 +86,7 @@ Given n samples, the value of the Vendi Score ranges between 1 and n, with highe
|
|
86 |
|
87 |
```
|
88 |
>>> import numpy as np
|
89 |
-
>>> vendiscore = evaluate.load("
|
90 |
>>> samples = [0, 0, 10, 10, 20, 20]
|
91 |
>>> k = lambda a, b: np.exp(-np.abs(a - b))
|
92 |
>>> vendiscore.compute(samples=samples, k=k)
|
@@ -95,7 +95,7 @@ Given n samples, the value of the Vendi Score ranges between 1 and n, with highe
|
|
95 |
|
96 |
If you already have precomputed a similarity matrix:
|
97 |
```
|
98 |
-
>>> vendiscore = evaluate.load("
|
99 |
>>> K = np.array([[1.0, 0.9, 0.0],
|
100 |
[0.9, 1.0, 0.0],
|
101 |
[0.0, 0.0, 1.0]])
|
@@ -108,7 +108,7 @@ If your similarity function is a dot product between `n` normalized
|
|
108 |
to compute the Vendi Score using the covariance matrix, `X @ X.T`.
|
109 |
(If the rows of `X` are not normalized, set `normalize = True`.)
|
110 |
```
|
111 |
-
>>> vendiscore = evaluate.load("
|
112 |
>>> X = np.array([[100, 0], [99, 1], [1, 99], [0, 100]])
|
113 |
>>> vendiscore.compute(samples=X, score_dual=True, normalize=True)
|
114 |
{'VS': 1.99989...}
|
@@ -116,7 +116,7 @@ to compute the Vendi Score using the covariance matrix, `X @ X.T`.
|
|
116 |
|
117 |
Text similarity can be calculated using n-gram overlap or using inner products between embeddings from a neural network.
|
118 |
```
|
119 |
-
>>> vendiscore = evaluate.load("
|
120 |
>>> sents = ["Look, Jane.", "See Spot.", "See Spot run.", "Run, Spot, run.", "Jane sees Spot run."]
|
121 |
>>> ngram_vs = vendiscore.compute(samples=sents, k="ngram_overlap", ns=[1, 2])["VS"]
|
122 |
>>> bert_vs = vendiscore.compute(samples=sents, k="text_embeddings", model_path="bert-base-uncased")["VS"]
|
|
|
41 |
```
|
42 |
To calculate the score, pass a list of samples and a similarity function or a string identifying a predefined class of similarity functions (see below).
|
43 |
```
|
44 |
+
>>> vendiscore = evaluate.load("Vertaix/vendiscore")
|
45 |
>>> samples = ["Look, Jane.",
|
46 |
"See Spot.",
|
47 |
"See Spot run.",
|
|
|
86 |
|
87 |
```
|
88 |
>>> import numpy as np
|
89 |
+
>>> vendiscore = evaluate.load("Vertaix/vendiscore", "int")
|
90 |
>>> samples = [0, 0, 10, 10, 20, 20]
|
91 |
>>> k = lambda a, b: np.exp(-np.abs(a - b))
|
92 |
>>> vendiscore.compute(samples=samples, k=k)
|
|
|
95 |
|
96 |
If you already have precomputed a similarity matrix:
|
97 |
```
|
98 |
+
>>> vendiscore = evaluate.load("Vertaix/vendiscore", "K")
|
99 |
>>> K = np.array([[1.0, 0.9, 0.0],
|
100 |
[0.9, 1.0, 0.0],
|
101 |
[0.0, 0.0, 1.0]])
|
|
|
108 |
to compute the Vendi Score using the covariance matrix, `X @ X.T`.
|
109 |
(If the rows of `X` are not normalized, set `normalize = True`.)
|
110 |
```
|
111 |
+
>>> vendiscore = evaluate.load("Vertaix/vendiscore", "X")
|
112 |
>>> X = np.array([[100, 0], [99, 1], [1, 99], [0, 100]])
|
113 |
>>> vendiscore.compute(samples=X, score_dual=True, normalize=True)
|
114 |
{'VS': 1.99989...}
|
|
|
116 |
|
117 |
Text similarity can be calculated using n-gram overlap or using inner products between embeddings from a neural network.
|
118 |
```
|
119 |
+
>>> vendiscore = evaluate.load("Vertaix/vendiscore", "text")
|
120 |
>>> sents = ["Look, Jane.", "See Spot.", "See Spot run.", "Run, Spot, run.", "Jane sees Spot run."]
|
121 |
>>> ngram_vs = vendiscore.compute(samples=sents, k="ngram_overlap", ns=[1, 2])["VS"]
|
122 |
>>> bert_vs = vendiscore.compute(samples=sents, k="text_embeddings", model_path="bert-base-uncased")["VS"]
|
vendiscore.py
CHANGED
@@ -53,7 +53,7 @@ Args:
|
|
53 |
Returns:
|
54 |
VS: The Vendi Score.
|
55 |
Examples:
|
56 |
-
>>> vendiscore = evaluate.load("
|
57 |
>>> samples = ["Look, Jane.",
|
58 |
"See Spot.",
|
59 |
"See Spot run.",
|
|
|
53 |
Returns:
|
54 |
VS: The Vendi Score.
|
55 |
Examples:
|
56 |
+
>>> vendiscore = evaluate.load("Vertaix/vendiscore", "text")
|
57 |
>>> samples = ["Look, Jane.",
|
58 |
"See Spot.",
|
59 |
"See Spot run.",
|