Fixing variable names and cosine_similarity is imported in the example code.
#2
by
hafiz031
- opened
README.md
CHANGED
@@ -32,17 +32,20 @@ Here is how to use this model to get the features of a given text using [Sentenc
|
|
32 |
|
33 |
```python
|
34 |
from sentence_transformers import SentenceTransformer
|
|
|
35 |
|
36 |
model_Q = SentenceTransformer('flax-sentence-embeddings/multi-QA_v1-mpnet-asymmetric-Q')
|
37 |
model_A = SentenceTransformer('flax-sentence-embeddings/multi-QA_v1-mpnet-asymmetric-A')
|
38 |
|
39 |
question = "Replace me by any question you'd like."
|
40 |
-
|
41 |
|
42 |
answer = "Replace me by any answer you'd like."
|
43 |
-
|
44 |
|
45 |
-
answer_likeliness = cosine_similarity(question_embedding, answer_embedding)
|
|
|
|
|
46 |
```
|
47 |
|
48 |
# Training procedure
|
|
|
32 |
|
33 |
```python
|
34 |
from sentence_transformers import SentenceTransformer
|
35 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
36 |
|
37 |
model_Q = SentenceTransformer('flax-sentence-embeddings/multi-QA_v1-mpnet-asymmetric-Q')
|
38 |
model_A = SentenceTransformer('flax-sentence-embeddings/multi-QA_v1-mpnet-asymmetric-A')
|
39 |
|
40 |
question = "Replace me by any question you'd like."
|
41 |
+
question_embedding = model_Q.encode(question)
|
42 |
|
43 |
answer = "Replace me by any answer you'd like."
|
44 |
+
answer_embedding = model_A.encode(answer)
|
45 |
|
46 |
+
answer_likeliness = cosine_similarity([question_embedding], [answer_embedding])
|
47 |
+
|
48 |
+
print(answer_likeliness)
|
49 |
```
|
50 |
|
51 |
# Training procedure
|