File tree 4 files changed +28
-8
lines changed
modules/text/machine_translation/transformer
4 files changed +28
-8
lines changed Original file line number Diff line number Diff line change @@ -119,3 +119,7 @@ paddlehub >= 2.1.0
119
119
* 1.0.0
120
120
121
121
初始发布
122
+
123
+ * 1.0.1
124
+
125
+ 修复模型初始化的兼容性问题
Original file line number Diff line number Diff line change 12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- from typing import List
16
15
import os
16
+ from packaging .version import Version
17
+ from typing import List
17
18
18
19
import paddle
19
20
import paddle .nn as nn
20
21
from paddlehub .env import MODULE_HOME
21
22
from paddlehub .module .module import moduleinfo , serving
23
+ import paddlenlp
22
24
from paddlenlp .data import Pad , Vocab
23
25
from paddlenlp .transformers import InferTransformerModel , position_encoding_init
24
26
27
29
28
30
@moduleinfo (
29
31
name = "transformer_en-de" ,
30
- version = "1.0.0 " ,
32
+ version = "1.0.1 " ,
31
33
summary = "" ,
32
34
author = "PaddlePaddle" ,
33
35
author_email = "" ,
@@ -42,8 +44,6 @@ class MTTransformer(nn.Layer):
42
44
43
45
# Model config
44
46
model_config = {
45
- # Number of sub-layers to be stacked in the encoder and decoder.
46
- "n_layer" : 6 ,
47
47
# Number of head used in multi-head attention.
48
48
"n_head" : 8 ,
49
49
# The dimension for word embeddings, which is also the last dimension of
@@ -59,6 +59,12 @@ class MTTransformer(nn.Layer):
59
59
'dropout' : 0
60
60
}
61
61
62
+ # Number of sub-layers to be stacked in the encoder and decoder.
63
+ if Version (paddlenlp .__version__ ) <= Version ('2.0.5' ):
64
+ model_config .update ({"n_layer" : 6 })
65
+ else :
66
+ model_config .update ({"num_encoder_layers" : 6 , "num_decoder_layers" : 6 })
67
+
62
68
# Vocab config
63
69
vocab_config = {
64
70
# Used to pad vocab size to be multiple of pad_factor.
Original file line number Diff line number Diff line change @@ -117,3 +117,7 @@ paddlehub >= 2.1.0
117
117
* 1.0.0
118
118
119
119
初始发布
120
+
121
+ * 1.0.1
122
+
123
+ 修复模型初始化的兼容性问题
Original file line number Diff line number Diff line change 12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- from typing import List
16
15
import os
16
+ from packaging .version import Version
17
+ from typing import List
17
18
18
19
import paddle
19
20
import paddle .nn as nn
20
21
from paddlehub .env import MODULE_HOME
21
22
from paddlehub .module .module import moduleinfo , serving
23
+ import paddlenlp
22
24
from paddlenlp .data import Pad , Vocab
23
25
from paddlenlp .transformers import InferTransformerModel , position_encoding_init
24
26
27
29
28
30
@moduleinfo (
29
31
name = "transformer_zh-en" ,
30
- version = "1.0.0 " ,
32
+ version = "1.0.1 " ,
31
33
summary = "" ,
32
34
author = "PaddlePaddle" ,
33
35
author_email = "" ,
@@ -42,8 +44,6 @@ class MTTransformer(nn.Layer):
42
44
43
45
# Model config
44
46
model_config = {
45
- # Number of sub-layers to be stacked in the encoder and decoder.
46
- "n_layer" : 6 ,
47
47
# Number of head used in multi-head attention.
48
48
"n_head" : 8 ,
49
49
# The dimension for word embeddings, which is also the last dimension of
@@ -59,6 +59,12 @@ class MTTransformer(nn.Layer):
59
59
'dropout' : 0
60
60
}
61
61
62
+ # Number of sub-layers to be stacked in the encoder and decoder.
63
+ if Version (paddlenlp .__version__ ) <= Version ('2.0.5' ):
64
+ model_config .update ({"n_layer" : 6 })
65
+ else :
66
+ model_config .update ({"num_encoder_layers" : 6 , "num_decoder_layers" : 6 })
67
+
62
68
# Vocab config
63
69
vocab_config = {
64
70
# Used to pad vocab size to be multiple of pad_factor.
You can’t perform that action at this time.
0 commit comments