diff --git a/PaddleNLP/neural_machine_translation/transformer/infer.py b/PaddleNLP/neural_machine_translation/transformer/infer.py index 08543f010163f6149c3b227ff86d0a7c95a5064c..aaf813a5e1345a47e4e9073d2ff1219274fc97fe 100644 --- a/PaddleNLP/neural_machine_translation/transformer/infer.py +++ b/PaddleNLP/neural_machine_translation/transformer/infer.py @@ -281,11 +281,11 @@ def fast_infer(args): feed=feed_dict_list[0] if feed_dict_list is not None else None, return_numpy=False, - use_program_cache=True) + use_program_cache=False) seq_ids_list, seq_scores_list = [seq_ids], [ seq_scores - ] if isinstance( - seq_ids, paddle.fluid.LoDTensor) else (seq_ids, seq_scores) + ] if isinstance(seq_ids, + paddle.fluid.LoDTensor) else (seq_ids, seq_scores) for seq_ids, seq_scores in zip(seq_ids_list, seq_scores_list): # How to parse the results: # Suppose the lod of seq_ids is: diff --git a/PaddleNLP/neural_machine_translation/transformer/reader.py b/PaddleNLP/neural_machine_translation/transformer/reader.py index 10f44ade6768edf9536cad27bcbcd0b08d16e668..aa4dea3e380aad409d2ca30cce6658288d2c7eef 100644 --- a/PaddleNLP/neural_machine_translation/transformer/reader.py +++ b/PaddleNLP/neural_machine_translation/transformer/reader.py @@ -266,7 +266,7 @@ class DataReader(object): with open(fpath, "rb") as f: for line in f: if six.PY3: - line = line.decode() + line = line.decode("utf8", errors="ignore") fields = line.strip("\n").split(self._field_delimiter) if (not self._only_src and len(fields) == 2) or ( self._only_src and len(fields) == 1): diff --git a/PaddleNLP/unarchived/neural_machine_translation/transformer/infer.py b/PaddleNLP/unarchived/neural_machine_translation/transformer/infer.py index 96b8e0a14fcc225e11e63a7604c8bf8e6db8e45e..cf89607d7b103cbe65f28868a6ce6f92691f618a 100644 --- a/PaddleNLP/unarchived/neural_machine_translation/transformer/infer.py +++ b/PaddleNLP/unarchived/neural_machine_translation/transformer/infer.py @@ -280,7 +280,7 @@ def fast_infer(args): feed=feed_dict_list[0] if feed_dict_list is not None else None, return_numpy=False, - use_program_cache=True) + use_program_cache=False) seq_ids_list, seq_scores_list = [ seq_ids ], [seq_scores] if isinstance( diff --git a/PaddleNLP/unarchived/neural_machine_translation/transformer/model.py b/PaddleNLP/unarchived/neural_machine_translation/transformer/model.py index cfd85dc505216a0d226a8cb29012ae3e36cc26cc..5b19be6a526852ac348d710800a741d6cfd971c1 100644 --- a/PaddleNLP/unarchived/neural_machine_translation/transformer/model.py +++ b/PaddleNLP/unarchived/neural_machine_translation/transformer/model.py @@ -875,7 +875,7 @@ def fast_decode(src_vocab_size, accu_scores = layers.elementwise_add( x=layers.log(topk_scores), y=pre_scores, axis=0) # beam_search op uses lod to differentiate branches. - topk_indices = layers.lod_reset(accu_scores, pre_ids) + accu_scores = layers.lod_reset(accu_scores, pre_ids) # topK reduction across beams, also contain special handle of # end beams and end sentences(batch reduction) selected_ids, selected_scores, gather_idx = layers.beam_search( diff --git a/PaddleNLP/unarchived/neural_machine_translation/transformer/reader.py b/PaddleNLP/unarchived/neural_machine_translation/transformer/reader.py index 10f44ade6768edf9536cad27bcbcd0b08d16e668..aa4dea3e380aad409d2ca30cce6658288d2c7eef 100644 --- a/PaddleNLP/unarchived/neural_machine_translation/transformer/reader.py +++ b/PaddleNLP/unarchived/neural_machine_translation/transformer/reader.py @@ -266,7 +266,7 @@ class DataReader(object): with open(fpath, "rb") as f: for line in f: if six.PY3: - line = line.decode() + line = line.decode("utf8", errors="ignore") fields = line.strip("\n").split(self._field_delimiter) if (not self._only_src and len(fields) == 2) or ( self._only_src and len(fields) == 1):