question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem about wmt17 zh-en dataset

See original GitHub issue

It seems that in subset casia2015, some samples are like {'c[hn]':'xxx', 'en': 'aa'}. So when using data = load_dataset('wmt17', "zh-en") to load the wmt17 zh-en dataset, which will raise the exception:

Traceback (most recent call last):
  File "train.py", line 78, in <module>
    data = load_dataset(args.dataset, "zh-en")
  File "/usr/local/lib/python3.7/dist-packages/datasets/load.py", line 1684, in load_dataset
    use_auth_token=use_auth_token,
  File "/usr/local/lib/python3.7/dist-packages/datasets/builder.py", line 705, in download_and_prepare
    dl_manager=dl_manager, verify_infos=verify_infos, **download_and_prepare_kwargs
  File "/usr/local/lib/python3.7/dist-packages/datasets/builder.py", line 1221, in _download_and_prepare
    super()._download_and_prepare(dl_manager, verify_infos, check_duplicate_keys=verify_infos)
  File "/usr/local/lib/python3.7/dist-packages/datasets/builder.py", line 793, in _download_and_prepare
    self._prepare_split(split_generator, **prepare_split_kwargs)
  File "/usr/local/lib/python3.7/dist-packages/datasets/builder.py", line 1215, in _prepare_split
    num_examples, num_bytes = writer.finalize()
  File "/usr/local/lib/python3.7/dist-packages/datasets/arrow_writer.py", line 533, in finalize
    self.write_examples_on_file()
  File "/usr/local/lib/python3.7/dist-packages/datasets/arrow_writer.py", line 410, in write_examples_on_file
    self.write_batch(batch_examples=batch_examples)
  File "/usr/local/lib/python3.7/dist-packages/datasets/arrow_writer.py", line 503, in write_batch
    arrays.append(pa.array(typed_sequence))
  File "pyarrow/array.pxi", line 230, in pyarrow.lib.array
  File "pyarrow/array.pxi", line 110, in pyarrow.lib._handle_arrow_array_protocol
  File "/usr/local/lib/python3.7/dist-packages/datasets/arrow_writer.py", line 198, in __arrow_array__
    out = cast_array_to_feature(out, type, allow_number_to_str=not self.trying_type)
  File "/usr/local/lib/python3.7/dist-packages/datasets/table.py", line 1675, in wrapper
    return func(array, *args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/datasets/table.py", line 1846, in cast_array_to_feature
    return array_cast(array, feature(), allow_number_to_str=allow_number_to_str)
  File "/usr/local/lib/python3.7/dist-packages/datasets/table.py", line 1675, in wrapper
    return func(array, *args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/datasets/table.py", line 1756, in array_cast
    raise TypeError(f"Couldn't cast array of type\n{array.type}\nto\n{pa_type}")
TypeError: Couldn't cast array of type
struct<c[hn]: string, en: string, zh: string>
to
struct<en: string, zh: string>

So the solution of this problem is to change the original array manually:

if 'c[hn]' in str(array.type):
        py_array = array.to_pylist()
        data_list = []
        for vo in py_array:
            tmp = {
                'en': vo['en'],
            }
            if 'zh' not in vo:
                tmp['zh'] = vo['c[hn]']
            else:
                tmp['zh'] = vo['zh']
            data_list.append(tmp)
        array = pa.array(data_list, type=pa.struct([
            pa.field('en', pa.string()),
            pa.field('zh', pa.string()),
        ]))

Therefore, maybe a correct version of original casia2015 file need to be updated

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
lhoestqcommented, Aug 23, 2022

I just pushed a fix, we’ll do a new release of datasets soon to include this fix. In the meantime you can use the fixed dataset by passing revision="main" to load_dataset

0reactions
StevenTang1998commented, Aug 13, 2022

I found some ‘zh’ item is none while ‘c[hn]’ is not. So the code may change to:

if 'c[hn]' in str(array.type):
        py_array = array.to_pylist()
        data_list = []
        for vo in py_array:
            tmp = {
                'en': vo['en'],
            }
            if vo.get('zh'):
                tmp['zh'] = vo['zh']
            else:
                tmp['zh'] = vo['c[hn]']
            data_list.append(tmp)
        array = pa.array(data_list, type=pa.struct([
            pa.field('en', pa.string()),
            pa.field('zh', pa.string()),
        ]))
Read more comments on GitHub >

github_iconTop Results From Across the Web

The University of Edinburgh's Neural MT Systems for WMT17
This paper describes the University of. Edinburgh's submissions to the WMT17 shared news translation and biomedical translation tasks. We participated in 12.
Read more >
2017 Second Conference on Machine Translation (WMT17)
BIOMEDICAL TRANSLATION TASK​​ In this second edition of this task, we will evaluate systems for the translation of biomedical documents for the following ......
Read more >
arXiv:1908.09329v1 [cs.CL] 25 Aug 2019
tioned problem is to consider a right-to-left de- ... Table 1: Translation examples on WMT17 Chinese-English dataset in L2R (left-to-right) ...
Read more >
Results of the WMT17 Metrics Shared Task | Request PDF
Even though there are some acknowledged problems with BLEU and other ... Such shared tasks with standardised datasets for multiple tasks and ...
Read more >
Chinese Machine Translation | ChineseNLP
Addresses decomposability problems with Bleu, proposing a cross between Bleu and word error ... The Second Conference on Machine Translation (WMT17) has a ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found