Update README.md
Browse files
README.md
CHANGED
|
@@ -25,11 +25,18 @@ Here is how to use this model to get the features of a given text in PyTorch:
|
|
| 25 |
from transformers import AutoModelForQuestionAnswering, AutoTokenizer
|
| 26 |
|
| 27 |
model = AutoModelForQuestionAnswering.from_pretrained("rubentito/bert-large-mpdocvqa")
|
|
|
|
| 28 |
|
| 29 |
question = "Replace me by any text you'd like."
|
| 30 |
context = "Put some context for answering"
|
|
|
|
| 31 |
encoded_input = tokenizer(question, context, return_tensors='pt')
|
| 32 |
output = model(**encoded_input)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
```
|
| 34 |
|
| 35 |
## Model results
|
|
|
|
| 25 |
from transformers import AutoModelForQuestionAnswering, AutoTokenizer
|
| 26 |
|
| 27 |
model = AutoModelForQuestionAnswering.from_pretrained("rubentito/bert-large-mpdocvqa")
|
| 28 |
+
tokenizer = AutoTokenizer.from_pretrained("rubentito/bert-large-mpdocvqa")
|
| 29 |
|
| 30 |
question = "Replace me by any text you'd like."
|
| 31 |
context = "Put some context for answering"
|
| 32 |
+
|
| 33 |
encoded_input = tokenizer(question, context, return_tensors='pt')
|
| 34 |
output = model(**encoded_input)
|
| 35 |
+
|
| 36 |
+
start_pos = output.start_logits.argmax(dim=-1).item()
|
| 37 |
+
end_pos = output.end_logits.argmax(dim=-1).item()
|
| 38 |
+
|
| 39 |
+
pred_answer = context[start_pos:end_pos]
|
| 40 |
```
|
| 41 |
|
| 42 |
## Model results
|