Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
1889e96c
"doc/git@developer.sourcefind.cn:wangsen/paddle_dbnet.git" did not exist on "c249ba9feac719ed34c20f6a0edcf90686d1cac3"
Unverified
Commit
1889e96c
authored
Sep 02, 2020
by
Patrick von Platen
Committed by
GitHub
Sep 02, 2020
Browse files
fix QA example for PT (#6890)
parent
d822ab63
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
src/transformers/file_utils.py
src/transformers/file_utils.py
+4
-3
No files found.
src/transformers/file_utils.py
View file @
1889e96c
...
@@ -303,14 +303,15 @@ PT_QUESTION_ANSWERING_SAMPLE = r"""
...
@@ -303,14 +303,15 @@ PT_QUESTION_ANSWERING_SAMPLE = r"""
>>> tokenizer = {tokenizer_class}.from_pretrained('{checkpoint}')
>>> tokenizer = {tokenizer_class}.from_pretrained('{checkpoint}')
>>> model = {model_class}.from_pretrained('{checkpoint}', return_dict=True)
>>> model = {model_class}.from_pretrained('{checkpoint}', return_dict=True)
>>> inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
>>> question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"
>>> inputs = tokenizer(question, text, return_tensors='pt')
>>> start_positions = torch.tensor([1])
>>> start_positions = torch.tensor([1])
>>> end_positions = torch.tensor([3])
>>> end_positions = torch.tensor([3])
>>> outputs = model(**inputs, start_positions=start_positions, end_positions=end_positions)
>>> outputs = model(**inputs, start_positions=start_positions, end_positions=end_positions)
>>> loss = outputs.loss
>>> loss = outputs.loss
>>> start_scores = outputs.start_
score
s
>>> start_scores = outputs.start_
logit
s
>>> end_scores = outputs.end_
score
s
>>> end_scores = outputs.end_
logit
s
"""
"""
PT_SEQUENCE_CLASSIFICATION_SAMPLE
=
r
"""
PT_SEQUENCE_CLASSIFICATION_SAMPLE
=
r
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment