nreimers
commited on
Commit
·
b2b5013
1
Parent(s):
ced69de
up
Browse files
README.md
CHANGED
@@ -24,7 +24,7 @@ For evaluation results, see [SBERT.net - Pretrained Cross-Encoder](https://www.s
|
|
24 |
Pre-trained models can be used like this:
|
25 |
```python
|
26 |
from sentence_transformers import CrossEncoder
|
27 |
-
model = CrossEncoder('
|
28 |
scores = model.predict([('A man is eating pizza', 'A man eats something'), ('A black race car starts up in front of a crowd of people.', 'A man is driving down a lonely road.')])
|
29 |
|
30 |
#Convert scores to labels
|
@@ -38,8 +38,8 @@ You can use the model also directly with Transformers library (without SentenceT
|
|
38 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
39 |
import torch
|
40 |
|
41 |
-
model = AutoModelForSequenceClassification.from_pretrained('
|
42 |
-
tokenizer = AutoTokenizer.from_pretrained('
|
43 |
|
44 |
features = tokenizer(['A man is eating pizza', 'A black race car starts up in front of a crowd of people.'], ['A man eats something', 'A man is driving down a lonely road.'], padding=True, truncation=True, return_tensors="pt")
|
45 |
|
@@ -53,7 +53,7 @@ with torch.no_grad():
|
|
53 |
|
54 |
## Zero-Shot Classification
|
55 |
This model can also be used for zero-shot-classification:
|
56 |
-
```
|
57 |
from transformers import pipeline
|
58 |
|
59 |
classifier = pipeline("zero-shot-classification", model='cross-encoder/nli-roberta-base')
|
|
|
24 |
Pre-trained models can be used like this:
|
25 |
```python
|
26 |
from sentence_transformers import CrossEncoder
|
27 |
+
model = CrossEncoder('cross-encoder/nli-roberta-base')
|
28 |
scores = model.predict([('A man is eating pizza', 'A man eats something'), ('A black race car starts up in front of a crowd of people.', 'A man is driving down a lonely road.')])
|
29 |
|
30 |
#Convert scores to labels
|
|
|
38 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
39 |
import torch
|
40 |
|
41 |
+
model = AutoModelForSequenceClassification.from_pretrained('cross-encoder/nli-roberta-base')
|
42 |
+
tokenizer = AutoTokenizer.from_pretrained('cross-encoder/nli-roberta-base')
|
43 |
|
44 |
features = tokenizer(['A man is eating pizza', 'A black race car starts up in front of a crowd of people.'], ['A man eats something', 'A man is driving down a lonely road.'], padding=True, truncation=True, return_tensors="pt")
|
45 |
|
|
|
53 |
|
54 |
## Zero-Shot Classification
|
55 |
This model can also be used for zero-shot-classification:
|
56 |
+
```python
|
57 |
from transformers import pipeline
|
58 |
|
59 |
classifier = pipeline("zero-shot-classification", model='cross-encoder/nli-roberta-base')
|