abbasgolestani commited on
Commit
003a43e
·
1 Parent(s): cd8d65d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +56 -0
README.md CHANGED
@@ -1,3 +1,59 @@
1
  ---
2
  license: apache-2.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
  ---
4
+
5
+ # Cross-Encoder for Quora Duplicate Questions Detection
6
+ This model was trained using [SentenceTransformers](https://sbert.net) [Cross-Encoder](https://www.sbert.net/examples/applications/cross-encoder/README.html) class.
7
+
8
+ ## Training Data
9
+ This model was trained on 6 different nli datasets. The model will predict a score between 0 (not similar) and 1 (very similar) how for the semantic similarity of two sentences.
10
+
11
+
12
+ ## Usage (CrossEncoder)
13
+ 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,...
14
+ ```python
15
+ from sentence_transformers import CrossEncoder
16
+ from bento import fwdproxy
17
+
18
+ #device = "cuda:0" if torch.cuda.is_available() else "cpu"
19
+ with fwdproxy():
20
+ model = CrossEncoder('abbasgolestani/ag-nli-DeTS-sentence-similarity-v1')
21
+
22
+ # Two lists of sentences
23
+ sentences1 = ['I am honored to be given the opportunity to help make our company better',
24
+ 'I love my job and what I do here',
25
+ 'I am excited about our company’s vision']
26
+
27
+ sentences2 = ['I am hopeful about the future of our company',
28
+ 'My work is aligning with my passion',
29
+ 'Definitely our company vision will be the next breakthrough to change the world and I’m so happy and proud to work here']
30
+
31
+ pairs = zip(sentences1,sentences2)
32
+ #pairs = zip(premise_NOT_entail,hypothesis_NOT_entail)
33
+ list_pairs=list(pairs)
34
+ #print(list_pairs)
35
+
36
+ scores1 = model.predict(list_pairs, show_progress_bar=False)
37
+ print(scores1)
38
+
39
+ for i in range(len(sentences1)):
40
+ print("{} \t\t {} \t\t Score: {:.4f}".format(sentences1[i], sentences2[i], scores1[i]))
41
+
42
+ ```
43
+
44
+
45
+
46
+
47
+
48
+ ## Usage #2
49
+
50
+ Pre-trained models can be used like this:
51
+ ```
52
+ from sentence_transformers import CrossEncoder
53
+ model = CrossEncoder('model_name')
54
+ scores = model.predict([('Sentence 1', 'Sentence 2'), ('Sentence 3', 'Sentence 4')])
55
+ ```
56
+
57
+ The model will predict scores for the pairs `('Sentence 1', 'Sentence 2')` and `('Sentence 3', 'Sentence 4')`.
58
+
59
+ You can use this model also without sentence_transformers and by just using Transformers ``AutoModel`` class