Update README.md
Browse files
README.md
CHANGED
@@ -15,15 +15,21 @@ For further information, please refer to https://github.com/yctam/dstc10_track2_
|
|
15 |
```python
|
16 |
def single_test(tokenizer, title_body_pair):
|
17 |
result = tokenizer([title_body_pair], return_tensors="pt")
|
18 |
-
result.to(device)
|
19 |
model.eval()
|
20 |
outputs = model(**result)
|
21 |
predictions = outputs.logits.argmax(dim=-1)
|
22 |
return True if predictions == 0 else False
|
23 |
|
24 |
if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
sentence = "Can I check in anytime?"
|
26 |
body = "Yes, 24 Hours Front Desk Avaliable."
|
27 |
-
|
28 |
-
print(single_test(pair)) # Expect: True
|
29 |
```
|
|
|
15 |
```python
|
16 |
def single_test(tokenizer, title_body_pair):
|
17 |
result = tokenizer([title_body_pair], return_tensors="pt")
|
|
|
18 |
model.eval()
|
19 |
outputs = model(**result)
|
20 |
predictions = outputs.logits.argmax(dim=-1)
|
21 |
return True if predictions == 0 else False
|
22 |
|
23 |
if __name__ == '__main__':
|
24 |
+
from transformers import AutoConfig, AutoTokenizer, AutoModel, AutoModelForSequenceClassification
|
25 |
+
|
26 |
+
model_name = "wilsontam/bert-base-uncased-dstc10-kb-title-body-validate"
|
27 |
+
|
28 |
+
config = AutoConfig.from_pretrained(model_name)
|
29 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=True)
|
30 |
+
model = AutoModelForSequenceClassification.from_pretrained(".")
|
31 |
+
|
32 |
sentence = "Can I check in anytime?"
|
33 |
body = "Yes, 24 Hours Front Desk Avaliable."
|
34 |
+
print(single_test((sentence, body))) # Expect: True
|
|
|
35 |
```
|