Datasets documentation

Beam Datasets

You are viewing v2.0.0 version. A newer version v2.20.0 is available.
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Beam Datasets

Some datasets are too large to be processed on a single machine. Instead, you can process them with Apache Beam, a library for parallel data processing. The processing pipeline is executed on a distributed processing backend such as Apache Flink, Apache Spark, or Google Cloud Dataflow.

We have already created Beam pipelines for some of the larger datasets like wikipedia, and wiki40b. You can load these normally with datasets.Datasets.load_dataset. But if you want to run your own Beam pipeline with Dataflow, here is how:

  1. Specify the dataset and configuration you want to process:
DATASET_NAME=your_dataset_name  # ex: wikipedia
CONFIG_NAME=your_config_name    # ex: 20200501.en
  1. Input your Google Cloud Platform information:
  1. Specify your Python requirements:
echo "datasets" > /tmp/beam_requirements.txt
echo "apache_beam" >> /tmp/beam_requirements.txt
  1. Run the pipeline:
datasets-cli run_beam datasets/$DATASET_NAME \
--name $CONFIG_NAME \
--save_infos \
--cache_dir gs://$BUCKET/cache/datasets \

When you run your pipeline, you can adjust the parameters to change the runner (Flink or Spark), output location (S3 bucket or HDFS), and the number of workers.