# NonMatchingSplitsSizesError

**URL:** <https://discuss.huggingface.co/t/nonmatchingsplitssizeserror/30033>\
**Category:** 🤗Datasets\
**Created:** [January 19, 2023, 8:12pm UTC](https://discuss.huggingface.co/t/nonmatchingsplitssizeserror/30033 "2023-01-19T20:12:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sl02](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@sl02](https://discuss.huggingface.co/u/sl02)\
**Post date:** [January 19, 2023, 8:12pm UTC](https://discuss.huggingface.co/t/nonmatchingsplitssizeserror/30033/1 "2023-01-19T20:12:35Z")

</div>

I created a custom script which splits the raw file into train/test split on the fly. The script works with the default arguments. However, when I change the `test_size` ratio which I pass via `load_dataset()`, it fails with the following error

```auto
Traceback (most recent call last):                                                                                                                                                                                                                            
  File "<stdin>", line 1, in <module>
  File "/Users/home/.local/share/virtualenvs/1717-yQ3Y_lVD/lib/python3.8/site-packages/datasets/load.py", line 1757, in load_dataset
    builder_instance.download_and_prepare(
  File "/Users/home/.local/share/virtualenvs/1717-yQ3Y_lVD/lib/python3.8/site-packages/datasets/builder.py", line 860, in download_and_prepare
    self._download_and_prepare(
  File "/Users/home/.local/share/virtualenvs/1717-yQ3Y_lVD/lib/python3.8/site-packages/datasets/builder.py", line 1611, in _download_and_prepare
    super()._download_and_prepare(
  File "/Users/home/.local/share/virtualenvs/1717-yQ3Y_lVD/lib/python3.8/site-packages/datasets/builder.py", line 971, in _download_and_prepare
    verify_splits(self.info.splits, split_dict)
  File "/Users/home/.local/share/virtualenvs/1717-yQ3Y_lVD/lib/python3.8/site-packages/datasets/utils/info_utils.py", line 74, in verify_splits
    raise NonMatchingSplitsSizesError(str(bad_splits))
datasets.utils.info_utils.NonMatchingSplitsSizesError

```

It fails the integrity check as expected. The [Build and load](https://huggingface.co/docs/datasets/about_dataset_load#maintaining-integrity) doesn’t show how to update the checks. I thought, using the `download_mode=force_redownload` argument in `load_dataset()` would fix it but it throws the same error as shown above. How do I resolve this?

---

<div class="post-metadata">

**Author:** ![polinaeterna](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/polinaeterna/32/19055_2.png) [@polinaeterna](https://discuss.huggingface.co/u/polinaeterna)\
**Post date:** [January 25, 2023, 12:10pm UTC](https://discuss.huggingface.co/t/nonmatchingsplitssizeserror/30033/2 "2023-01-25T12:10:34Z")

</div>

Hi @sl02 ! Is `test_size` a custom builder parameter you define in your loading script?

You can set `ignore_verifications=True` param in `load_dataset` to skip splits sizes verification.

Also note that `Dataset` object has [`.train_test_split()`](https://huggingface.co/docs/datasets/process#split) method, probably it might be useful for your case.

---

<div class="post-metadata">

**Author:** ![sl02](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@sl02](https://discuss.huggingface.co/u/sl02)\
**Post date:** [January 27, 2023, 1:14pm UTC](https://discuss.huggingface.co/t/nonmatchingsplitssizeserror/30033/3 "2023-01-27T13:14:44Z")

</div>

> [@sl02](#):
>
> `s.NonMatchingSplitsSizesError`

Hi @polinaeterna  
Yes. `test_size` is a parameter. Sure with the `ignore_verifications=True` parameter it works. But I would like to know how, for other datasets when it changes at the source, do you update the information; The instructions in the document, to which I provide a link in the above thread, doesn’t explain this clearly.

I am doing a group shuffle split because I have to ensure no overlap in the id column in the respective splits.

---

<div class="post-metadata">

**Author:** ![polinaeterna](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/polinaeterna/32/19055_2.png) [@polinaeterna](https://discuss.huggingface.co/u/polinaeterna)\
**Post date:** [January 27, 2023, 5:56pm UTC](https://discuss.huggingface.co/t/nonmatchingsplitssizeserror/30033/4 "2023-01-27T17:56:14Z")

</div>

@sl02  
When you load your dataset locally for the first time, it creates `dataset_info.json` file under its cache folder, the file contains all these splits info (like `num_examples`, `num_bytes`, etc.). If you regenerate the dataset while the script is unchanged (for example, run `load_dataset` with `download_mode="reuse_cache_if_exists"`), it performs verifications against this file.

We used to have `dataset_info.json` files in datasets repositories on the Hub (so, not just in a local cache folder) to verify splits info on the first download but now it’s **deprecated** , we use `README.md` instead for storing these numbers.  
To (re)compute these numbers automatically and dump them to a `README.md` file, one should run `datasets-cli test your_dataset --save_info`. And as it’s done manually, it depends on datasets’ authors if they update and push this info or not as it’s not required.  
Hope it’s more or less clear, feel free to ask any questions if it’s not 🙂

---

<div class="post-metadata">

**Author:** ![sl02](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@sl02](https://discuss.huggingface.co/u/sl02)\
**Post date:** [January 28, 2023, 2:18pm UTC](https://discuss.huggingface.co/t/nonmatchingsplitssizeserror/30033/5 "2023-01-28T14:18:23Z")

</div>

@polinaeterna  
Thanks for clearing that up!

---

<div class="post-metadata">

**Author:** ![hjerpe](https://avatars.discourse-cdn.com/v4/letter/h/7993a0/32.png) [@hjerpe](https://discuss.huggingface.co/u/hjerpe)\
**Post date:** [September 13, 2023, 7:07pm UTC](https://discuss.huggingface.co/t/nonmatchingsplitssizeserror/30033/6 "2023-09-13T19:07:17Z")

</div>

Note that you could get this error when you try and download an updated dataset without using the cache. E.g.,  
dataset = load\_dataset(url, download\_mode=“force\_redownload”)

If the underlying dataset has been updated there can be a miss-match between the number of read records and what is read from the cache. You can read about the cache here, [Cache management](https://huggingface.co/docs/datasets/cache).

---

<div class="post-metadata">

**Author:** ![albertzeyer](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/albertzeyer/32/46906_2.png) [@albertzeyer](https://discuss.huggingface.co/u/albertzeyer)\
**Post date:** [October 8, 2025, 4:51pm UTC](https://discuss.huggingface.co/t/nonmatchingsplitssizeserror/30033/7 "2025-10-08T16:51:31Z")

</div>

> [@polinaeterna](#):
>
> ignore\_verifications=True

This does not work anymore. I think now you have to use `verification_mode=VerificationMode.NO_CHECKS`.
