Support all negative values in ClassLabel
NONE
_The documentation is not available anymore as the PR was closed or merged._
2022-06-16T10:06:57Z
https://github.com/huggingface/datasets/pull/4511#issuecomment-1157479469
https://api.github.com/repos/huggingface/datasets/issues/4511
IC_kwDODunzps5E_bwt
https://api.github.com/repos/huggingface/datasets/issues/comments/1157479469/reactions
2022-06-16T14:04:09Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1157479469
https://avatars.githubusercontent.com/u/99929124?v=4
https://api.github.com/users/HuggingFaceDocBuilderDev/events{/privacy}
https://api.github.com/users/HuggingFaceDocBuilderDev/followers
https://api.github.com/users/HuggingFaceDocBuilderDev/following{/other_user}
https://api.github.com/users/HuggingFaceDocBuilderDev/gists{/gist_id}
https://github.com/HuggingFaceDocBuilderDev
HuggingFaceDocBuilderDev
U_kgDOBfTMJA
https://api.github.com/users/HuggingFaceDocBuilderDev/orgs
https://api.github.com/users/HuggingFaceDocBuilderDev/received_events
https://api.github.com/users/HuggingFaceDocBuilderDev/repos
https://api.github.com/users/HuggingFaceDocBuilderDev/starred{/owner}{/repo}
https://api.github.com/users/HuggingFaceDocBuilderDev/subscriptions
User
https://api.github.com/users/HuggingFaceDocBuilderDev
public
NONE
Thanks for this fix! I'm not sure what the release timeline is, but FYI #4508 is a breaking issue for transformer token classification using Trainer and PyTorch. PyTorch defaults to -100 as the ignored label for [negative log loss](https://pytorch.org/docs/stable/generated/torch.nn.NLLLoss.html?highlight=nllloss#torch.nn.NLLLoss), so switching labels to -1 leads to index errors using Trainer defaults.

As a workaround, I'm using master branch directly (`pip install git+https://github.com/huggingface/datasets.git@master` for anyone who needs to do the same) until this gets released.
2022-06-23T15:58:58Z
https://github.com/huggingface/datasets/pull/4511#issuecomment-1164594329
https://api.github.com/repos/huggingface/datasets/issues/4511
IC_kwDODunzps5FakyZ
https://api.github.com/repos/huggingface/datasets/issues/comments/1164594329/reactions
2022-06-23T16:04:05Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1164594329
https://avatars.githubusercontent.com/u/1603279?v=4
https://api.github.com/users/davidbenton/events{/privacy}
https://api.github.com/users/davidbenton/followers
https://api.github.com/users/davidbenton/following{/other_user}
https://api.github.com/users/davidbenton/gists{/gist_id}
https://github.com/davidbenton
davidbenton
MDQ6VXNlcjE2MDMyNzk=
https://api.github.com/users/davidbenton/orgs
https://api.github.com/users/davidbenton/received_events
https://api.github.com/users/davidbenton/repos
https://api.github.com/users/davidbenton/starred{/owner}{/repo}
https://api.github.com/users/davidbenton/subscriptions
User
https://api.github.com/users/davidbenton
public
MEMBER
The new release `2.4` fixes the issue, feel free to update `datasets` :) 
```
pip install -U datasets
```
2022-07-28T16:03:27Z
https://github.com/huggingface/datasets/pull/4511#issuecomment-1198347350
https://api.github.com/repos/huggingface/datasets/issues/4511
IC_kwDODunzps5HbVRW
https://api.github.com/repos/huggingface/datasets/issues/comments/1198347350/reactions
2022-07-28T16:03:27Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1198347350
https://avatars.githubusercontent.com/u/42851186?v=4
https://api.github.com/users/lhoestq/events{/privacy}
https://api.github.com/users/lhoestq/followers
https://api.github.com/users/lhoestq/following{/other_user}
https://api.github.com/users/lhoestq/gists{/gist_id}
https://github.com/lhoestq
lhoestq
MDQ6VXNlcjQyODUxMTg2
https://api.github.com/users/lhoestq/orgs
https://api.github.com/users/lhoestq/received_events
https://api.github.com/users/lhoestq/repos
https://api.github.com/users/lhoestq/starred{/owner}{/repo}
https://api.github.com/users/lhoestq/subscriptions
User
https://api.github.com/users/lhoestq
public
NONE
@lhoestq I hope it's OK to ping you here. I've noticed that `encode_example` does only work with -1. I already created #7645 to fix the documentation, but then I stumbled across your original changes to the docs text in this PR.

I am talking about this part in `ClassLabel -> encode_example`:

https://github.com/huggingface/datasets/blob/e71b0b19d79c7531f9b9bea7c09916b5f6157f42/src/datasets/features/features.py#L1126-L1129
2025-07-23T18:38:15Z
https://github.com/huggingface/datasets/pull/4511#issuecomment-3109699309
https://api.github.com/repos/huggingface/datasets/issues/4511
IC_kwDODunzps65Wj7t
https://api.github.com/repos/huggingface/datasets/issues/comments/3109699309/reactions
2025-07-23T18:38:15Z
https://api.github.com/repos/huggingface/datasets/issues/comments/3109699309
https://avatars.githubusercontent.com/u/56924246?v=4
https://api.github.com/users/l-uuz/events{/privacy}
https://api.github.com/users/l-uuz/followers
https://api.github.com/users/l-uuz/following{/other_user}
https://api.github.com/users/l-uuz/gists{/gist_id}
https://github.com/l-uuz
l-uuz
MDQ6VXNlcjU2OTI0MjQ2
https://api.github.com/users/l-uuz/orgs
https://api.github.com/users/l-uuz/received_events
https://api.github.com/users/l-uuz/repos
https://api.github.com/users/l-uuz/starred{/owner}{/repo}
https://api.github.com/users/l-uuz/subscriptions
User
https://api.github.com/users/l-uuz
public
We usually use -1 to represent a missing label, but we should also support any negative values (some users use -100 for example). This is a regression from `datasets` 2.3

Fix https://github.com/huggingface/datasets/issues/4508