Commit
路
fe46f77
1
Parent(s):
3099d8a
Update README.md
Browse files
README.md
CHANGED
@@ -63,7 +63,8 @@ This is the [mdeberta-v3-base](https://huggingface.co/microsoft/mdeberta-v3-base
|
|
63 |
|
64 |
### Model Usage
|
65 |
```python
|
66 |
-
|
|
|
67 |
AutoModelForQuestionAnswering,
|
68 |
AutoTokenizer,
|
69 |
pipeline
|
@@ -77,6 +78,8 @@ qa_input = {
|
|
77 |
'context': 'My name is Sarah and I live in London'
|
78 |
}
|
79 |
res = nlp(qa_input)
|
|
|
|
|
80 |
|
81 |
# b) Load model & tokenizer
|
82 |
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
|
@@ -91,6 +94,7 @@ start_scores, end_scores = model(encoding["input_ids"], attention_mask=encoding[
|
|
91 |
all_tokens = tokenizer.convert_ids_to_tokens(input_ids[0].tolist())
|
92 |
answer_tokens = all_tokens[torch.argmax(start_scores) :torch.argmax(end_scores)+1]
|
93 |
answer = tokenizer.decode(tokenizer.convert_tokens_to_ids(answer_tokens))
|
|
|
94 |
```
|
95 |
|
96 |
### Metrics
|
|
|
63 |
|
64 |
### Model Usage
|
65 |
```python
|
66 |
+
import torch
|
67 |
+
from transformers import(
|
68 |
AutoModelForQuestionAnswering,
|
69 |
AutoTokenizer,
|
70 |
pipeline
|
|
|
78 |
'context': 'My name is Sarah and I live in London'
|
79 |
}
|
80 |
res = nlp(qa_input)
|
81 |
+
# {'score': 0.9844420552253723, 'start': 30, 'end': 37, 'answer': ' London'}
|
82 |
+
|
83 |
|
84 |
# b) Load model & tokenizer
|
85 |
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
|
|
|
94 |
all_tokens = tokenizer.convert_ids_to_tokens(input_ids[0].tolist())
|
95 |
answer_tokens = all_tokens[torch.argmax(start_scores) :torch.argmax(end_scores)+1]
|
96 |
answer = tokenizer.decode(tokenizer.convert_tokens_to_ids(answer_tokens))
|
97 |
+
# 'London'
|
98 |
```
|
99 |
|
100 |
### Metrics
|