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
fb6cccb8
"...git@developer.sourcefind.cn:OpenDAS/mmdetection3d.git" did not exist on "5fe12001f124b835591ef80e50cd649f4c716a49"
Unverified
Commit
fb6cccb8
authored
Jun 18, 2020
by
Suraj Patil
Committed by
GitHub
Jun 17, 2020
Browse files
fix qa example (#4929)
parent
38bba9cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
src/transformers/modeling_electra.py
src/transformers/modeling_electra.py
+4
-3
No files found.
src/transformers/modeling_electra.py
View file @
fb6cccb8
...
@@ -815,10 +815,11 @@ class ElectraForQuestionAnswering(ElectraPreTrainedModel):
...
@@ -815,10 +815,11 @@ class ElectraForQuestionAnswering(ElectraPreTrainedModel):
model = ElectraForQuestionAnswering.from_pretrained('google/electra-base-discriminator')
model = ElectraForQuestionAnswering.from_pretrained('google/electra-base-discriminator')
question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"
question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"
input_ids = tokenizer.encode(question, text)
encoding = tokenizer.encode_plus(question, text, return_tensors='pt')
start_scores, end_scores = model(torch.tensor([input_ids]))
input_ids, token_type_ids = encoding['input_ids'], encoding['token_type_ids']
start_scores, end_scores = model(input_ids, token_type_ids=token_type_ids)
all_tokens = tokenizer.convert_ids_to_tokens(input_ids)
all_tokens = tokenizer.convert_ids_to_tokens(input_ids
.squeeze(0)
)
answer = ' '.join(all_tokens[torch.argmax(start_scores) : torch.argmax(end_scores)+1])
answer = ' '.join(all_tokens[torch.argmax(start_scores) : torch.argmax(end_scores)+1])
"""
"""
...
...
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