Optimization of the format of the data files

#1
by albertvillanova HF staff - opened

Hi @nanom !

First of all, thank you for sharing this dataset.

I contact you to propose you some optimizations in the format of your data files:

  • First, inside each ZIP, you have a file in JSON format. This format is not very convenient in 2 use cases: either if the user has small RAM memory, or if the user loads your dataset in streaming mode. The JSON file must first be loaded completely in memory and only afterwards each example can be yielded:
    data = json.load(f)
    for _, text in data['text'].items():
        yield id_, {
    
    • I would propose you to use JSON Lines instead: https://jsonlines.org/
    • With this format, users need very little RAM memory and loading in streaming mode is much faster
  • Second, this is less important than the previous one: as your ZIP file contains only a single file inside, you could compress them with GZIP instead of ZIP. That way you would not need to specify self.config.name_into_zip: you would only need to specify the uncompressed data_dir = dl_manager.download_and_extract(self.config.data_url) (you could rename it to data_path instead).

What do you think?
CC: @severo

Sign up or log in to comment