File size: 2,212 Bytes
842d83a
 
ea45343
 
 
5db4b10
cd80526
 
 
 
09203c6
 
 
 
 
 
 
842d83a
003a43e
c5e86d4
003a43e
 
 
c0cc845
003a43e
 
 
 
 
 
 
93e977f
 
003a43e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ad1f595
003a43e
ac54d87
003a43e
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
license: apache-2.0
datasets:
- multi_nli
- pietrolesci/nli_fever
pipeline_tag: text-classification
tags:
- feature-extraction
- sentence-similarity
- transformers
language:
- en
- nl
- de
- fr
- it
- es
---

# Cross-Encoder for Sentence Similarity
This model was trained using [SentenceTransformers](https://sbert.net) [Cross-Encoder](https://www.sbert.net/examples/applications/cross-encoder/README.html) class.

## Training Data
This model was trained on 6 different nli datasets. The model will predict a score between 0 (not similar) and 1 (very similar) for the semantic similarity of two sentences. 


## Usage (CrossEncoder)
Comparing each sentence of sentences1 array to the corrosponding sentence of sentences2 array like comparing the first sentnece of each array, then comparing the second sentence of each array,...
```python
from sentence_transformers import CrossEncoder


model = CrossEncoder('abbasgolestani/ag-nli-DeTS-sentence-similarity-v1')

# Two lists of sentences
sentences1 = ['I am honored to be given the opportunity to help make our company better',
             'I love my job and what I do here',
             'I am excited about our company’s vision']

sentences2 = ['I am hopeful about the future of our company',
              'My work is aligning with my passion',
              'Definitely our company vision will be the next breakthrough to change the world and I’m so happy and proud to work here']

pairs = zip(sentences1,sentences2)
list_pairs=list(pairs)

scores1 = model.predict(list_pairs, show_progress_bar=False)
print(scores1)

for i in range(len(sentences1)):
    print("{} \t\t {} \t\t Score: {:.4f}".format(sentences1[i], sentences2[i], scores1[i]))

```





## Usage #2

Pre-trained models can be used like this:
```python
from sentence_transformers import CrossEncoder
model = CrossEncoder('abbasgolestani/ag-nli-DeTS-sentence-similarity-v1')
scores = model.predict([('Sentence 1', 'Sentence 2'), ('Sentence 3', 'Sentence 4')])
```

The model will predict scores for the pairs `('Sentence 1', 'Sentence 2')` and `('Sentence 3', 'Sentence 4')`.

You can use this model also without sentence_transformers and by just using Transformers ``AutoModel`` class