abbasgolestani commited on
Commit
be4d1d7
1 Parent(s): 1fde231

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +23 -5
README.md CHANGED
@@ -25,12 +25,30 @@ pip install -U sentence-transformers
25
  Then you can use the model like this:
26
 
27
  ```python
28
- from sentence_transformers import SentenceTransformer
29
- sentences = ["This is an example sentence", "Each sentence is converted"]
30
 
31
- model = SentenceTransformer('abbasgolestani/ag-nli-bert-mpnet-base-uncased-sentence-similarity-v1')
32
- embeddings = model.encode(sentences)
33
- print(embeddings)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  ```
35
 
36
 
 
25
  Then you can use the model like this:
26
 
27
  ```python
28
+ from sentence_transformers import SentenceTransformer, util
 
29
 
30
+
31
+ model = SentenceTransformer('abbasgolestani/ag-nli-bert-mpnet-base-uncased-sentence-similarity-v1') nli-mpnet-base-v2
32
+
33
+ # Two lists of sentences
34
+ sentences1 = ['I am honored to be given the opportunity to help make our company better',
35
+ 'I love my job and what I do here',
36
+ 'I am excited about our company’s vision']
37
+
38
+ sentences2 = ['I am hopeful about the future of our company',
39
+ 'My work is aligning with my passion',
40
+ 'Definitely our company vision will be the next breakthrough to change the world and I’m so happy and proud to work here']
41
+
42
+ #Compute embedding for both lists
43
+ embeddings1 = model.encode(sentences1, convert_to_tensor=True)
44
+ embeddings2 = model.encode(sentences2, convert_to_tensor=True)
45
+
46
+ #Compute cosine-similarities
47
+ cosine_scores = util.cos_sim(embeddings1, embeddings2)
48
+
49
+ #Output the pairs with their score
50
+ for i in range(len(sentences1)):
51
+ print("{} \t\t {} \t\t Score: {:.4f}".format(sentences1[i], sentences2[i], cosine_scores[i][i]))
52
  ```
53
 
54