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
cbf43911
Unverified
Commit
cbf43911
authored
Feb 24, 2022
by
Patrick von Platen
Committed by
GitHub
Feb 24, 2022
Browse files
[TFXLNet] Correct tf xlnet generate (#15822)
* [TFXLNet] Correct tf xlnet * adapt test comment
parent
2f0f9038
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
725 deletions
+15
-725
tests/xlnet/test_modeling_tf_xlnet.py
tests/xlnet/test_modeling_tf_xlnet.py
+9
-364
tests/xlnet/test_modeling_xlnet.py
tests/xlnet/test_modeling_xlnet.py
+6
-361
No files found.
tests/xlnet/test_modeling_tf_xlnet.py
View file @
cbf43911
...
...
@@ -461,174 +461,17 @@ class TFXLNetModelLanguageGenerationTest(unittest.TestCase):
@
slow
def
test_lm_generate_xlnet_base_cased
(
self
):
model
=
TFXLNetLMHeadModel
.
from_pretrained
(
"xlnet-base-cased"
)
# fmt: off
input_ids
=
tf
.
convert_to_tensor
(
[
[
67
,
2840
,
19
,
18
,
1484
,
20
,
965
,
29077
,
8719
,
1273
,
21
,
45
,
273
,
17
,
10
,
15048
,
28
,
27511
,
21
,
4185
,
11
,
41
,
2444
,
9
,
32
,
1025
,
20
,
8719
,
26
,
23
,
673
,
966
,
19
,
29077
,
20643
,
27511
,
20822
,
20643
,
19
,
17
,
6616
,
17511
,
18
,
8978
,
20
,
18
,
777
,
9
,
19233
,
1527
,
17669
,
19
,
24
,
673
,
17
,
28756
,
150
,
12943
,
4354
,
153
,
27
,
442
,
37
,
45
,
668
,
21
,
24
,
256
,
20
,
416
,
22
,
2771
,
4901
,
9
,
12943
,
4354
,
153
,
51
,
24
,
3004
,
21
,
28142
,
23
,
65
,
20
,
18
,
416
,
34
,
24
,
2958
,
22947
,
9
,
1177
,
45
,
668
,
3097
,
13768
,
23
,
103
,
28
,
441
,
148
,
48
,
20522
,
19
,
12943
,
4354
,
153
,
12860
,
34
,
18
,
326
,
27
,
17492
,
684
,
21
,
6709
,
9
,
8585
,
123
,
266
,
19
,
12943
,
4354
,
153
,
6872
,
24
,
3004
,
20
,
18
,
9225
,
2198
,
19
,
12717
,
103
,
22
,
401
,
24
,
6348
,
9
,
12943
,
4354
,
153
,
1068
,
2768
,
2286
,
19
,
33
,
104
,
19
,
176
,
24
,
9313
,
19
,
20086
,
28
,
45
,
10292
,
9
,
4
,
3
,
67
,
2840
,
19
,
18
,
1484
,
20
,
965
,
29077
,
8719
,
1273
,
21
,
45
,
273
,
17
,
10
,
15048
,
28
,
27511
,
21
,
4185
,
11
,
41
,
2444
,
9
,
32
,
1025
,
20
,
8719
,
26
,
23
,
673
,
966
,
19
,
29077
,
20643
,
27511
,
20822
,
20643
,
19
,
17
,
6616
,
17511
,
18
,
8978
,
20
,
18
,
777
,
9
,
19233
,
1527
,
17669
,
19
,
24
,
673
,
17
,
28756
,
150
,
12943
,
4354
,
153
,
27
,
442
,
37
,
45
,
668
,
21
,
24
,
256
,
20
,
416
,
22
,
2771
,
4901
,
9
,
12943
,
4354
,
153
,
51
,
24
,
3004
,
21
,
28142
,
23
,
65
,
20
,
18
,
416
,
34
,
24
,
2958
,
22947
,
9
,
1177
,
45
,
668
,
3097
,
13768
,
23
,
103
,
28
,
441
,
148
,
48
,
20522
,
19
,
12943
,
4354
,
153
,
12860
,
34
,
18
,
326
,
27
,
17492
,
684
,
21
,
6709
,
9
,
8585
,
123
,
266
,
19
,
12943
,
4354
,
153
,
6872
,
24
,
3004
,
20
,
18
,
9225
,
2198
,
19
,
12717
,
103
,
22
,
401
,
24
,
6348
,
9
,
12943
,
4354
,
153
,
1068
,
2768
,
2286
,
19
,
33
,
104
,
19
,
176
,
24
,
9313
,
19
,
20086
,
28
,
45
,
10292
,
9
,
4
,
3
,
]
],
dtype
=
tf
.
int32
,
)
# fmt: on
# In 1991, the remains of Russian Tsar Nicholas II and his family
# (except for Alexei and Maria) are discovered.
# The voice of Nicholas's young son, Tsarevich Alexei Nikolaevich, narrates the
...
...
@@ -640,208 +483,11 @@ class TFXLNetModelLanguageGenerationTest(unittest.TestCase):
# the Virgin Mary, prompting him to become a priest. Rasputin quickly becomes famous,
# with people, even a bishop, begging for his blessing. """
# fmt: off
expected_output_ids
=
[
67
,
2840
,
19
,
18
,
1484
,
20
,
965
,
29077
,
8719
,
1273
,
21
,
45
,
273
,
17
,
10
,
15048
,
28
,
27511
,
21
,
4185
,
11
,
41
,
2444
,
9
,
32
,
1025
,
20
,
8719
,
26
,
23
,
673
,
966
,
19
,
29077
,
20643
,
27511
,
20822
,
20643
,
19
,
17
,
6616
,
17511
,
18
,
8978
,
20
,
18
,
777
,
9
,
19233
,
1527
,
17669
,
19
,
24
,
673
,
17
,
28756
,
150
,
12943
,
4354
,
153
,
27
,
442
,
37
,
45
,
668
,
21
,
24
,
256
,
20
,
416
,
22
,
2771
,
4901
,
9
,
12943
,
4354
,
153
,
51
,
24
,
3004
,
21
,
28142
,
23
,
65
,
20
,
18
,
416
,
34
,
24
,
2958
,
22947
,
9
,
1177
,
45
,
668
,
3097
,
13768
,
23
,
103
,
28
,
441
,
148
,
48
,
20522
,
19
,
12943
,
4354
,
153
,
12860
,
34
,
18
,
326
,
27
,
17492
,
684
,
21
,
6709
,
9
,
8585
,
123
,
266
,
19
,
12943
,
4354
,
153
,
6872
,
24
,
3004
,
20
,
18
,
9225
,
2198
,
19
,
12717
,
103
,
22
,
401
,
24
,
6348
,
9
,
12943
,
4354
,
153
,
1068
,
2768
,
2286
,
19
,
33
,
104
,
19
,
176
,
24
,
9313
,
19
,
20086
,
28
,
45
,
10292
,
9
,
4
,
3
,
19
,
12943
,
4354
,
153
,
27
,
442
,
22
,
2771
,
4901
,
9
,
69
,
27
,
50
,
551
,
22
,
2771
,
4901
,
19
,
21
,
45
,
668
,
21
,
18
,
416
,
41
,
1499
,
22
,
755
,
18
,
14285
,
9
,
12943
,
4354
,
153
,
27
,
1499
,
22
,
642
,
22
,
67
,
2840
,
19
,
18
,
1484
,
20
,
965
,
29077
,
8719
,
1273
,
21
,
45
,
273
,
17
,
10
,
15048
,
28
,
27511
,
21
,
4185
,
11
,
41
,
2444
,
9
,
32
,
1025
,
20
,
8719
,
26
,
23
,
673
,
966
,
19
,
29077
,
20643
,
27511
,
20822
,
20643
,
19
,
17
,
6616
,
17511
,
18
,
8978
,
20
,
18
,
777
,
9
,
19233
,
1527
,
17669
,
19
,
24
,
673
,
17
,
28756
,
150
,
12943
,
4354
,
153
,
27
,
442
,
37
,
45
,
668
,
21
,
24
,
256
,
20
,
416
,
22
,
2771
,
4901
,
9
,
12943
,
4354
,
153
,
51
,
24
,
3004
,
21
,
28142
,
23
,
65
,
20
,
18
,
416
,
34
,
24
,
2958
,
22947
,
9
,
1177
,
45
,
668
,
3097
,
13768
,
23
,
103
,
28
,
441
,
148
,
48
,
20522
,
19
,
12943
,
4354
,
153
,
12860
,
34
,
18
,
326
,
27
,
17492
,
684
,
21
,
6709
,
9
,
8585
,
123
,
266
,
19
,
12943
,
4354
,
153
,
6872
,
24
,
3004
,
20
,
18
,
9225
,
2198
,
19
,
12717
,
103
,
22
,
401
,
24
,
6348
,
9
,
12943
,
4354
,
153
,
1068
,
2768
,
2286
,
19
,
33
,
104
,
19
,
176
,
24
,
9313
,
19
,
20086
,
28
,
45
,
10292
,
9
,
4
,
3
,
19
,
12943
,
4354
,
153
,
27
,
442
,
22
,
2771
,
4901
,
9
,
69
,
27
,
442
,
22
,
2771
,
24
,
11335
,
20
,
18
,
9225
,
2198
,
9
,
69
,
27
,
442
,
22
,
2771
,
24
,
11335
,
20
,
18
,
9225
,
2198
,
9
,
69
,
27
,
442
,
22
,
2771
,
]
# fmt: on
# In 1991, the remains of Russian Tsar Nicholas II and his family (except for Alexei and Maria)
# are discovered. The voice of Nicholas's young son, Tsarevich Alexei Nikolaevich,
# narrates the remainder of the story. 1883 Western Siberia, a young Grigori Rasputin
...
...
@@ -850,9 +496,8 @@ class TFXLNetModelLanguageGenerationTest(unittest.TestCase):
# him for making such an accusation, Rasputin watches as the man is chased outside and beaten.
# Twenty years later, Rasputin sees a vision of the Virgin Mary, prompting him to become a priest.
# Rasputin quickly becomes famous, with people, even a bishop, begging for his blessing.
# <sep><cls>, Rasputin is asked to perform magic.
# He is not able to perform magic, and his father and
# the men are forced to leave the monastery. Rasputin is forced to return to
# <sep><cls>, Rasputin is asked to perform magic. He is asked to perform a ritual of the Virgin Mary.
# He is asked to perform a ritual of the Virgin Mary. He is asked to perform
output_ids
=
model
.
generate
(
input_ids
,
max_length
=
200
,
do_sample
=
False
)
...
...
tests/xlnet/test_modeling_xlnet.py
View file @
cbf43911
...
...
@@ -673,175 +673,17 @@ class XLNetModelLanguageGenerationTest(unittest.TestCase):
def
test_lm_generate_xlnet_base_cased
(
self
):
model
=
XLNetLMHeadModel
.
from_pretrained
(
"xlnet-base-cased"
)
model
.
to
(
torch_device
)
# fmt: off
input_ids
=
torch
.
tensor
(
[
[
67
,
2840
,
19
,
18
,
1484
,
20
,
965
,
29077
,
8719
,
1273
,
21
,
45
,
273
,
17
,
10
,
15048
,
28
,
27511
,
21
,
4185
,
11
,
41
,
2444
,
9
,
32
,
1025
,
20
,
8719
,
26
,
23
,
673
,
966
,
19
,
29077
,
20643
,
27511
,
20822
,
20643
,
19
,
17
,
6616
,
17511
,
18
,
8978
,
20
,
18
,
777
,
9
,
19233
,
1527
,
17669
,
19
,
24
,
673
,
17
,
28756
,
150
,
12943
,
4354
,
153
,
27
,
442
,
37
,
45
,
668
,
21
,
24
,
256
,
20
,
416
,
22
,
2771
,
4901
,
9
,
12943
,
4354
,
153
,
51
,
24
,
3004
,
21
,
28142
,
23
,
65
,
20
,
18
,
416
,
34
,
24
,
2958
,
22947
,
9
,
1177
,
45
,
668
,
3097
,
13768
,
23
,
103
,
28
,
441
,
148
,
48
,
20522
,
19
,
12943
,
4354
,
153
,
12860
,
34
,
18
,
326
,
27
,
17492
,
684
,
21
,
6709
,
9
,
8585
,
123
,
266
,
19
,
12943
,
4354
,
153
,
6872
,
24
,
3004
,
20
,
18
,
9225
,
2198
,
19
,
12717
,
103
,
22
,
401
,
24
,
6348
,
9
,
12943
,
4354
,
153
,
1068
,
2768
,
2286
,
19
,
33
,
104
,
19
,
176
,
24
,
9313
,
19
,
20086
,
28
,
45
,
10292
,
9
,
4
,
3
,
67
,
2840
,
19
,
18
,
1484
,
20
,
965
,
29077
,
8719
,
1273
,
21
,
45
,
273
,
17
,
10
,
15048
,
28
,
27511
,
21
,
4185
,
11
,
41
,
2444
,
9
,
32
,
1025
,
20
,
8719
,
26
,
23
,
673
,
966
,
19
,
29077
,
20643
,
27511
,
20822
,
20643
,
19
,
17
,
6616
,
17511
,
18
,
8978
,
20
,
18
,
777
,
9
,
19233
,
1527
,
17669
,
19
,
24
,
673
,
17
,
28756
,
150
,
12943
,
4354
,
153
,
27
,
442
,
37
,
45
,
668
,
21
,
24
,
256
,
20
,
416
,
22
,
2771
,
4901
,
9
,
12943
,
4354
,
153
,
51
,
24
,
3004
,
21
,
28142
,
23
,
65
,
20
,
18
,
416
,
34
,
24
,
2958
,
22947
,
9
,
1177
,
45
,
668
,
3097
,
13768
,
23
,
103
,
28
,
441
,
148
,
48
,
20522
,
19
,
12943
,
4354
,
153
,
12860
,
34
,
18
,
326
,
27
,
17492
,
684
,
21
,
6709
,
9
,
8585
,
123
,
266
,
19
,
12943
,
4354
,
153
,
6872
,
24
,
3004
,
20
,
18
,
9225
,
2198
,
19
,
12717
,
103
,
22
,
401
,
24
,
6348
,
9
,
12943
,
4354
,
153
,
1068
,
2768
,
2286
,
19
,
33
,
104
,
19
,
176
,
24
,
9313
,
19
,
20086
,
28
,
45
,
10292
,
9
,
4
,
3
,
]
],
dtype
=
torch
.
long
,
device
=
torch_device
,
)
# fmt: on
# In 1991, the remains of Russian Tsar Nicholas II and his family
# (except for Alexei and Maria) are discovered.
# The voice of Nicholas's young son, Tsarevich Alexei Nikolaevich, narrates the
...
...
@@ -853,208 +695,11 @@ class XLNetModelLanguageGenerationTest(unittest.TestCase):
# the Virgin Mary, prompting him to become a priest. Rasputin quickly becomes famous,
# with people, even a bishop, begging for his blessing. """
# fmt: off
expected_output_ids
=
[
67
,
2840
,
19
,
18
,
1484
,
20
,
965
,
29077
,
8719
,
1273
,
21
,
45
,
273
,
17
,
10
,
15048
,
28
,
27511
,
21
,
4185
,
11
,
41
,
2444
,
9
,
32
,
1025
,
20
,
8719
,
26
,
23
,
673
,
966
,
19
,
29077
,
20643
,
27511
,
20822
,
20643
,
19
,
17
,
6616
,
17511
,
18
,
8978
,
20
,
18
,
777
,
9
,
19233
,
1527
,
17669
,
19
,
24
,
673
,
17
,
28756
,
150
,
12943
,
4354
,
153
,
27
,
442
,
37
,
45
,
668
,
21
,
24
,
256
,
20
,
416
,
22
,
2771
,
4901
,
9
,
12943
,
4354
,
153
,
51
,
24
,
3004
,
21
,
28142
,
23
,
65
,
20
,
18
,
416
,
34
,
24
,
2958
,
22947
,
9
,
1177
,
45
,
668
,
3097
,
13768
,
23
,
103
,
28
,
441
,
148
,
48
,
20522
,
19
,
12943
,
4354
,
153
,
12860
,
34
,
18
,
326
,
27
,
17492
,
684
,
21
,
6709
,
9
,
8585
,
123
,
266
,
19
,
12943
,
4354
,
153
,
6872
,
24
,
3004
,
20
,
18
,
9225
,
2198
,
19
,
12717
,
103
,
22
,
401
,
24
,
6348
,
9
,
12943
,
4354
,
153
,
1068
,
2768
,
2286
,
19
,
33
,
104
,
19
,
176
,
24
,
9313
,
19
,
20086
,
28
,
45
,
10292
,
9
,
4
,
3
,
19
,
12943
,
4354
,
153
,
27
,
442
,
22
,
2771
,
4901
,
9
,
69
,
27
,
442
,
22
,
2771
,
24
,
11335
,
20
,
18
,
9225
,
2198
,
9
,
69
,
27
,
442
,
22
,
2771
,
24
,
11335
,
20
,
18
,
9225
,
2198
,
9
,
69
,
27
,
442
,
22
,
2771
,
67
,
2840
,
19
,
18
,
1484
,
20
,
965
,
29077
,
8719
,
1273
,
21
,
45
,
273
,
17
,
10
,
15048
,
28
,
27511
,
21
,
4185
,
11
,
41
,
2444
,
9
,
32
,
1025
,
20
,
8719
,
26
,
23
,
673
,
966
,
19
,
29077
,
20643
,
27511
,
20822
,
20643
,
19
,
17
,
6616
,
17511
,
18
,
8978
,
20
,
18
,
777
,
9
,
19233
,
1527
,
17669
,
19
,
24
,
673
,
17
,
28756
,
150
,
12943
,
4354
,
153
,
27
,
442
,
37
,
45
,
668
,
21
,
24
,
256
,
20
,
416
,
22
,
2771
,
4901
,
9
,
12943
,
4354
,
153
,
51
,
24
,
3004
,
21
,
28142
,
23
,
65
,
20
,
18
,
416
,
34
,
24
,
2958
,
22947
,
9
,
1177
,
45
,
668
,
3097
,
13768
,
23
,
103
,
28
,
441
,
148
,
48
,
20522
,
19
,
12943
,
4354
,
153
,
12860
,
34
,
18
,
326
,
27
,
17492
,
684
,
21
,
6709
,
9
,
8585
,
123
,
266
,
19
,
12943
,
4354
,
153
,
6872
,
24
,
3004
,
20
,
18
,
9225
,
2198
,
19
,
12717
,
103
,
22
,
401
,
24
,
6348
,
9
,
12943
,
4354
,
153
,
1068
,
2768
,
2286
,
19
,
33
,
104
,
19
,
176
,
24
,
9313
,
19
,
20086
,
28
,
45
,
10292
,
9
,
4
,
3
,
19
,
12943
,
4354
,
153
,
27
,
442
,
22
,
2771
,
4901
,
9
,
69
,
27
,
442
,
22
,
2771
,
24
,
11335
,
20
,
18
,
9225
,
2198
,
9
,
69
,
27
,
442
,
22
,
2771
,
24
,
11335
,
20
,
18
,
9225
,
2198
,
9
,
69
,
27
,
442
,
22
,
2771
,
]
# fmt: on
# In 1991, the remains of Russian Tsar Nicholas II and his family (except for Alexei and Maria)
# are discovered. The voice of Nicholas's young son, Tsarevich Alexei Nikolaevich,
# narrates the remainder of the story. 1883 Western Siberia, a young Grigori Rasputin
...
...
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