Skip to content

Unitxt 1.18.0 - Faster Loading

Latest
Compare
Choose a tag to compare
@elronbandel elronbandel released this 04 Feb 14:20
· 5 commits to main since this release
2ef9091

The main improvements in this version focus on caching strategies, dataset loading, and speed optimizations.

Hugging Face Datasets Caching Policy

We have completely revised our caching policy and how we handle Hugging Face datasets in order to improve performance.

  1. Hugging Face datasets are now cached by default.

This means that LoadHF loader will cache the downloaded datasets in the HF cache directory (typically ~/.cache/huggingface/datasets).

  • To disable this caching mechanism, use:
unitxt.settings.disable_hf_datasets_cache = True
  1. All Hugging Face datasets are first downloaded and then processed.

    • This means the entire dataset is downloaded, which is faster for most datasets. However, if you want to process a huge dataset, and the HF dataset supports streaming, you can load it in streaming mode
    LoadHF(name="my-dataset", streaming=True)
  2. To enable streaming mode by default for all Hugging Face datasets, use:

    unitxt.settings.stream_hf_datasets_by_default = True

While the new defaults (full download & caching) may make the initial dataset load slower, subsequent loads will be significantly faster.

Unitxt Datasets Caching Policy

By default, when loading datasets with unitxt.load_dataset, the dataset is prepared from scratch each time you call the function.
This ensures that any changes made to the card definition are reflected in the output.

  • This process may take a few seconds, and for large datasets, repeated loading can accumulate overhead.

  • If you are using fixed datasets from the catalog, you can enable caching for Unitxt datasets and thus cache the unitxt datasets.
    The datasets are cached in the huggingface cache (typically ~/.cache/huggingface/datasets).

    from unitxt import load_dataset
    
    ds = load_dataset(card="my_card", use_cache=True)

Faster Unitxt Dataset Preparation

To improve dataset loading speed, we have optimized how Unitxt datasets are prepared.

Background:

Unitxt datasets are converted to Hugging Face datasets because they store data on disk while keeping only the necessary parts in memory (via PyArrow). This enables efficient handling of large datasets without excessive memory usage.

Previously, unitxt.load_dataset used built-in Hugging Face methods for dataset preparation, which included unnecessary type handling and verification, slowing down the process.

Key improvements:

  • We now create the Hugging Face dataset directly, reducing preparation time by almost 50%.
  • With this optimization, Unitxt datasets are now faster than ever!

What's Changed

New Contributors

Full Changelog: 1.17.0...1.18.0