class paddle.text. WMT16 ( data_file=None, mode='train', src_dict_size=- 1, trg_dict_size=- 1, lang='en', download=True ) [source]

Implementation of WMT16 test dataset. ACL2016 Multimodal Machine Translation. Please see this website for more details: http://www.statmt.org/wmt16/multimodal-task.html#task1

If you use the dataset created for your task, please cite the following paper: Multi30K: Multilingual English-German Image Descriptions.

 author    = {{Elliott}, D. and {Frank}, S. and {Sima"an}, K. and {Specia}, L.},
 title     = {Multi30K: Multilingual English-German Image Descriptions},
 booktitle = {Proceedings of the 6th Workshop on Vision and Language},
 year      = {2016},
 pages     = {70--74},
 year      = 2016
  • data_file (str) – path to data tar file, can be set None if download is True. Default None

  • mode (str) – ‘train’, ‘test’ or ‘val’. Default ‘train’

  • src_dict_size (int) – word dictionary size for source language word. Default -1.

  • trg_dict_size (int) – word dictionary size for target language word. Default -1.

  • lang (str) – source language, ‘en’ or ‘de’. Default ‘en’.

  • download (bool) – whether to download dataset automatically if data_file is not set. Default True


Instance of WMT16 dataset. The instance of dataset has 3 fields:
  • src_ids (np.array) - The sequence of token ids of source language.

  • trg_ids (np.array) - The sequence of token ids of target language.

  • trg_ids_next (np.array) - The next sequence of token ids of target language.

Return type



import paddle
from paddle.text.datasets import WMT16

class SimpleNet(paddle.nn.Layer):
    def __init__(self):

    def forward(self, src_ids, trg_ids, trg_ids_next):
        return paddle.sum(src_ids), paddle.sum(trg_ids), paddle.sum(trg_ids_next)


wmt16 = WMT16(mode='train', src_dict_size=50, trg_dict_size=50)

for i in range(10):
    src_ids, trg_ids, trg_ids_next = wmt16[i]
    src_ids = paddle.to_tensor(src_ids)
    trg_ids = paddle.to_tensor(trg_ids)
    trg_ids_next = paddle.to_tensor(trg_ids_next)

    model = SimpleNet()
    src_ids, trg_ids, trg_ids_next = model(src_ids, trg_ids, trg_ids_next)
    print(src_ids.numpy(), trg_ids.numpy(), trg_ids_next.numpy())
get_dict ( lang, reverse=False )


return the word dictionary for the specified language.

  • lang (string) – A string indicating which language is the source language. Available options are: “en” for English and “de” for Germany.

  • reverse (bool) – If reverse is set to False, the returned python dictionary will use word as key and use index as value. If reverse is set to True, the returned python dictionary will use index as key and word as value.


The word dictionary for the specific language.

Return type



from paddle.text.datasets import WMT16
wmt16 = WMT16(mode='train', src_dict_size=50, trg_dict_size=50)
en_dict = wmt16.get_dict('en')