File tree Expand file tree Collapse file tree
examples/machine_translation/transformer Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323import paddle .distributed as dist
2424from paddlenlp .data import Pad , Vocab
2525from paddlenlp .datasets import load_dataset
26- from paddlenlp .datasets import WMT14ende
2726from paddlenlp .data .sampler import SamplerHelper
2827
2928
@@ -125,12 +124,13 @@ def convert_samples(sample):
125124
126125
127126def adapt_vocab_size (args ):
128- root = None if args .root == "None" else args .root
129- (src_vocab , trg_vocab ) = WMT14ende .get_vocab (root = root )
127+ dataset = load_dataset ('wmt14ende' , splits = ('test' ))
128+ src_vocab = Vocab .load_vocabulary (** dataset .vocab_info ["bpe" ])
129+ trg_vocab = src_vocab
130+
130131 padding_vocab = (
131132 lambda x : (x + args .pad_factor - 1 ) // args .pad_factor * args .pad_factor
132133 )
133-
134134 args .src_vocab_size = padding_vocab (len (src_vocab ))
135135 args .trg_vocab_size = padding_vocab (len (trg_vocab ))
136136
You can’t perform that action at this time.
0 commit comments