ray.data.from_huggingface#

ray.data.from_huggingface(dataset: datasets.Dataset | datasets.IterableDataset, parallelism: int = -1, concurrency: int | None = None, override_num_blocks: int | None = None) MaterializedDataset | Dataset[source]#

Read a Hugging Face Dataset into a Ray Dataset.

Creates a MaterializedDataset from a Hugging Face Datasets Dataset or a Dataset from a Hugging Face Datasets IterableDataset.

It is recommended to use read_parquet() with the HfFileSystem filesystem to read Hugging Face datasets rather than from_huggingface.

See Loading Hugging Face datasets for more details.

Parameters:
  • dataset – A Hugging Face Datasets Dataset or Hugging Face Datasets IterableDataset. DatasetDict and IterableDatasetDict are not supported.

  • parallelism – This argument is deprecated. Use override_num_blocks argument.

  • concurrency – The maximum number of Ray tasks to run concurrently. Set this to control number of tasks to run concurrently. This doesn’t change the total number of tasks run or the total number of output blocks. By default, concurrency is dynamically decided based on the available resources.

  • override_num_blocks – Override the number of output blocks from all read tasks. By default, the number of output blocks is dynamically decided based on input data size and available resources. You shouldn’t manually set this value in most cases.

Returns:

A Dataset holding rows from the Hugging Face Datasets Dataset.