-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix backwards incompatibility introduced with 2.1.17 (#885)
* Adding a test for backwards compatability. * Backwards compatability. * Space * Changelog.
- Loading branch information
Showing
12 changed files
with
301 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The model was generated with the following command: | ||
``` | ||
-s docs/tutorials/seqcopy/data/dev.source | ||
-t docs/tutorials/seqcopy/data/dev.target | ||
-vs docs/tutorials/seqcopy/data/dev.source | ||
-vt docs/tutorials/seqcopy/data/dev.target | ||
--transformer-model-size 16 | ||
--num-layers 1:1 | ||
--transformer-attention-heads 2 | ||
--transformer-feed-forward-num-hidden 16 | ||
--overwrite-output | ||
--use-cpu | ||
--batch-type sentence | ||
--batch-size 32 | ||
--decode-and-evaluate 400 | ||
--checkpoint-interval 500 | ||
--initial-learning-rate 0.01 | ||
--max-num-checkpoint-not-improved 4 | ||
-o model | ||
``` | ||
|
||
The model_input is just `head dev.source`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
!ModelConfig | ||
config_data: !DataConfig | ||
data_statistics: !DataStatistics | ||
average_len_target_per_bucket: | ||
- null | ||
- 13.44736842105263 | ||
- 20.568421052631578 | ||
- 28.053672316384176 | ||
- null | ||
- null | ||
- null | ||
- null | ||
- null | ||
- null | ||
- null | ||
- null | ||
buckets: | ||
- !!python/tuple | ||
- 8 | ||
- 8 | ||
- !!python/tuple | ||
- 16 | ||
- 16 | ||
- !!python/tuple | ||
- 24 | ||
- 24 | ||
- !!python/tuple | ||
- 32 | ||
- 32 | ||
- !!python/tuple | ||
- 40 | ||
- 40 | ||
- !!python/tuple | ||
- 48 | ||
- 48 | ||
- !!python/tuple | ||
- 56 | ||
- 56 | ||
- !!python/tuple | ||
- 64 | ||
- 64 | ||
- !!python/tuple | ||
- 72 | ||
- 72 | ||
- !!python/tuple | ||
- 80 | ||
- 80 | ||
- !!python/tuple | ||
- 88 | ||
- 88 | ||
- !!python/tuple | ||
- 96 | ||
- 96 | ||
length_ratio_mean: 1.0 | ||
length_ratio_stats_per_bucket: | ||
- &id001 !!python/tuple | ||
- null | ||
- null | ||
- !!python/tuple | ||
- 1.0 | ||
- 0.0 | ||
- !!python/tuple | ||
- 1.0 | ||
- 0.0 | ||
- !!python/tuple | ||
- 1.0 | ||
- 0.0 | ||
- *id001 | ||
- *id001 | ||
- *id001 | ||
- *id001 | ||
- *id001 | ||
- *id001 | ||
- *id001 | ||
- *id001 | ||
length_ratio_std: 0.0 | ||
max_observed_len_source: 31 | ||
max_observed_len_target: 31 | ||
num_discarded: 0 | ||
num_sents: 1000 | ||
num_sents_per_bucket: | ||
- 0 | ||
- 266 | ||
- 380 | ||
- 354 | ||
- 0 | ||
- 0 | ||
- 0 | ||
- 0 | ||
- 0 | ||
- 0 | ||
- 0 | ||
- 0 | ||
num_tokens_source: 21324 | ||
num_tokens_target: 21324 | ||
num_unks_source: 0 | ||
num_unks_target: 0 | ||
size_vocab_source: 15 | ||
size_vocab_target: 15 | ||
max_seq_len_source: 96 | ||
max_seq_len_target: 96 | ||
num_source_factors: 1 | ||
config_decoder: !TransformerConfig | ||
act_type: relu | ||
attention_heads: 2 | ||
depth_key_value: 16 | ||
dropout_act: 0.1 | ||
dropout_attention: 0.1 | ||
dropout_prepost: 0.1 | ||
feed_forward_num_hidden: 16 | ||
lhuc: false | ||
max_seq_len_source: 96 | ||
max_seq_len_target: 96 | ||
model_size: 16 | ||
num_layers: 1 | ||
positional_embedding_type: fixed | ||
postprocess_sequence: dr | ||
preprocess_sequence: n | ||
use_lhuc: false | ||
config_embed_source: !EmbeddingConfig | ||
allow_sparse_grad: true | ||
dropout: 0.0 | ||
factor_configs: null | ||
num_embed: 16 | ||
num_factors: 1 | ||
vocab_size: 15 | ||
config_embed_target: !EmbeddingConfig | ||
allow_sparse_grad: true | ||
dropout: 0.0 | ||
factor_configs: null | ||
num_embed: 16 | ||
num_factors: 1 | ||
vocab_size: 15 | ||
config_encoder: !TransformerConfig | ||
act_type: relu | ||
attention_heads: 2 | ||
depth_key_value: 0 | ||
dropout_act: 0.1 | ||
dropout_attention: 0.1 | ||
dropout_prepost: 0.1 | ||
feed_forward_num_hidden: 16 | ||
lhuc: false | ||
max_seq_len_source: 96 | ||
max_seq_len_target: 96 | ||
model_size: 16 | ||
num_layers: 1 | ||
positional_embedding_type: fixed | ||
postprocess_sequence: dr | ||
preprocess_sequence: n | ||
use_lhuc: false | ||
config_length_task: null | ||
dtype: float32 | ||
intgemm_custom_lib: /Volumes/CaseSensitive/Projects/CoreMT/sockeye-github/sockeye/libintgemm.so | ||
lhuc: false | ||
vocab_source_size: 15 | ||
vocab_target_size: 15 | ||
weight_tying_type: src_trg_softmax |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
6 3 0 9 3 2 0 5 3 8 0 1 0 4 1 6 2 8 9 10 3 7 0 4 9 7 5 2 7 7 | ||
2 1 7 7 5 0 5 7 1 7 10 4 0 9 10 5 0 5 | ||
6 8 4 6 1 8 1 3 2 4 0 1 6 4 6 1 0 6 5 4 7 0 5 | ||
8 1 7 6 9 10 10 3 4 7 8 1 9 6 9 5 2 3 1 1 | ||
0 6 4 2 0 6 8 1 0 8 3 7 4 0 8 0 1 2 0 0 8 9 4 1 7 4 | ||
10 1 8 2 3 4 2 3 7 6 6 | ||
7 7 0 1 5 8 8 8 10 1 7 6 7 4 4 0 9 4 2 7 6 3 8 2 | ||
5 7 3 5 3 7 5 5 9 9 7 5 5 5 8 0 10 8 8 5 3 10 5 6 2 9 8 3 7 7 | ||
6 9 4 4 7 6 9 4 5 9 10 1 8 2 | ||
7 0 1 6 0 6 9 7 2 4 3 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2.1.16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"<pad>": 0, | ||
"<unk>": 1, | ||
"<s>": 2, | ||
"</s>": 3, | ||
"5": 4, | ||
"3": 5, | ||
"9": 6, | ||
"1": 7, | ||
"10": 8, | ||
"6": 9, | ||
"7": 10, | ||
"2": 11, | ||
"4": 12, | ||
"0": 13, | ||
"8": 14 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"<pad>": 0, | ||
"<unk>": 1, | ||
"<s>": 2, | ||
"</s>": 3, | ||
"5": 4, | ||
"3": 5, | ||
"9": 6, | ||
"1": 7, | ||
"10": 8, | ||
"6": 9, | ||
"7": 10, | ||
"2": 11, | ||
"4": 12, | ||
"0": 13, | ||
"8": 14 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You may not | ||
# use this file except in compliance with the License. A copy of the License | ||
# is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is distributed on | ||
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
# express or implied. See the License for the specific language governing | ||
# permissions and limitations under the License. | ||
|
||
import logging | ||
import os | ||
import sys | ||
from tempfile import TemporaryDirectory | ||
|
||
import sockeye.translate | ||
from unittest.mock import patch | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
EXPECTED_OUTPUT = """6 3 0 9 3 2 0 5 3 8 0 1 0 4 1 6 2 8 9 10 3 7 0 4 9 7 5 2 7 7 | ||
2 1 7 7 5 0 5 7 1 7 10 4 0 9 10 5 0 5 | ||
6 8 4 6 1 8 1 3 2 4 0 1 6 4 6 1 0 6 5 4 7 0 5 | ||
8 1 7 6 9 10 10 3 4 7 8 1 9 6 9 5 2 3 1 1 | ||
0 6 4 2 0 6 8 1 0 8 3 7 4 0 8 0 1 2 0 0 8 9 4 1 7 4 | ||
10 1 8 2 3 4 2 3 7 6 6 | ||
7 7 0 1 5 8 8 8 10 1 7 6 7 4 4 0 9 4 2 7 6 3 8 2 | ||
5 7 3 5 3 7 5 5 9 9 7 5 5 5 8 0 10 8 8 5 3 10 5 6 2 9 8 3 7 7 | ||
6 9 4 4 7 6 9 4 5 9 10 1 8 2 | ||
7 0 1 6 0 6 9 7 2 4 3 | ||
""" | ||
|
||
|
||
def test_backwards_compatibility(): | ||
""" | ||
This test checks whether the current code can still produce translations with a model that was trained with the | ||
same major version. | ||
""" | ||
with TemporaryDirectory() as work_dir: | ||
output_file = os.path.join(work_dir, "out") | ||
params = """{sockeye} --use-cpu --models {model} --input {input} --output {output} """.format( | ||
sockeye=sockeye.translate.__file__, | ||
model="test/data/model_2.1.x", | ||
input="test/data/model_2.1.x/model_input", | ||
output=output_file | ||
) | ||
logger.info("Translating with params %s", params) | ||
with patch.object(sys, "argv", params.split()): | ||
sockeye.translate.main() | ||
|
||
with open(output_file) as model_out: | ||
assert model_out.read() == EXPECTED_OUTPUT |