Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
29792864
Unverified
Commit
29792864
authored
Oct 21, 2020
by
Patrick von Platen
Committed by
GitHub
Oct 21, 2020
Browse files
[ProphetNet] Add Question Generation Model + Test (#7942)
* new prophetnet model * correct name * make style
parent
13842e41
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
tests/test_modeling_prophetnet.py
tests/test_modeling_prophetnet.py
+30
-0
No files found.
tests/test_modeling_prophetnet.py
View file @
29792864
...
@@ -1073,3 +1073,33 @@ class ProphetNetModelIntegrationTest(unittest.TestCase):
...
@@ -1073,3 +1073,33 @@ class ProphetNetModelIntegrationTest(unittest.TestCase):
[
EXPECTED_SUMMARIZE_100
],
[
EXPECTED_SUMMARIZE_100
],
generated_titles
,
generated_titles
,
)
)
@
slow
def
test_question_gen_inference
(
self
):
model
=
ProphetNetForConditionalGeneration
.
from_pretrained
(
"microsoft/prophetnet-large-uncased-squad-qg"
)
model
.
to
(
torch_device
)
tokenizer
=
ProphetNetTokenizer
.
from_pretrained
(
"microsoft/prophetnet-large-uncased-squad-qg"
)
INPUTS
=
[
"Bill Gates [SEP] Microsoft was founded by Bill Gates and Paul Allen on April 4, 1975."
,
"1975 [SEP] Microsoft was founded by Bill Gates and Paul Allen on April 4, 1975."
,
"April 4, 1975 [SEP] Microsoft was founded by Bill Gates and Paul Allen on April 4, 1975."
,
]
input_ids
=
tokenizer
(
INPUTS
,
truncation
=
True
,
padding
=
True
,
return_tensors
=
"pt"
).
input_ids
input_ids
=
input_ids
.
to
(
torch_device
)
gen_output
=
model
.
generate
(
input_ids
,
num_beams
=
5
,
early_stopping
=
True
)
generated_questions
=
tokenizer
.
batch_decode
(
gen_output
,
skip_special_tokens
=
True
)
EXPECTED_QUESTIONS
=
[
"along with paul allen, who founded microsoft?"
,
"what year was microsoft founded?"
,
"on what date was microsoft founded?"
,
]
self
.
assertListEqual
(
EXPECTED_QUESTIONS
,
generated_questions
,
)
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