Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
To use this model
|
2 |
+
```python
|
3 |
+
import torch
|
4 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
5 |
+
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained("xlm-roberta-base")
|
7 |
+
model = AutoModelForSequenceClassification.from_pretrained("LsTam/MQ-classification")
|
8 |
+
|
9 |
+
softmax = torch.nn.Softmax(dim=1)
|
10 |
+
prediction = lambda p : [(a[0] < a[1]) * 1 for a in p]
|
11 |
+
|
12 |
+
# 0 is for wrong question and 1 for good ones
|
13 |
+
|
14 |
+
text = ['Your question' + ' </s> ' + 'your context']
|
15 |
+
|
16 |
+
a = tokenizer(text, return_tensors="pt")
|
17 |
+
result = model(**a)
|
18 |
+
pred = prediction(softmax(result.logits).tolist())
|
19 |
+
```
|