ToluClassics
commited on
Commit
•
b6c44c1
1
Parent(s):
5ab9275
Update README.md
Browse files
README.md
CHANGED
@@ -6,6 +6,8 @@ datasets:
|
|
6 |
model-index:
|
7 |
- name: extractive_reader_nq_squad_v2
|
8 |
results: []
|
|
|
|
|
9 |
---
|
10 |
|
11 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
@@ -50,3 +52,28 @@ The following hyperparameters were used during training:
|
|
50 |
- Pytorch 1.13.1+cu117
|
51 |
- Datasets 2.8.0
|
52 |
- Tokenizers 0.13.2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
model-index:
|
7 |
- name: extractive_reader_nq_squad_v2
|
8 |
results: []
|
9 |
+
language:
|
10 |
+
- en
|
11 |
---
|
12 |
|
13 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
|
|
52 |
- Pytorch 1.13.1+cu117
|
53 |
- Datasets 2.8.0
|
54 |
- Tokenizers 0.13.2
|
55 |
+
|
56 |
+
|
57 |
+
### Code Examples
|
58 |
+
|
59 |
+
```python
|
60 |
+
import torch
|
61 |
+
import numpy as np
|
62 |
+
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
|
63 |
+
|
64 |
+
tokenizer = AutoTokenizer.from_pretrained("ToluClassics/extractive_reader_nq_squad_v2")
|
65 |
+
|
66 |
+
model = AutoModelForQuestionAnswering.from_pretrained("ToluClassics/extractive_reader_nq_squad_v2")
|
67 |
+
|
68 |
+
question = ""
|
69 |
+
context = ""
|
70 |
+
|
71 |
+
inputs = tokenizer.encode(question, context, add_special_tokens=True, return_tensors="pt")
|
72 |
+
|
73 |
+
output = model(inputs)
|
74 |
+
|
75 |
+
answer_start = torch.argmax(output.start_logits)
|
76 |
+
answer_end = torch.argmax(output.end_logits)
|
77 |
+
if answer_end >= answer_start:
|
78 |
+
print(tokenizer.decode(inputs[0][answer_start:answer_end+1]))
|
79 |
+
```
|