# Label 2 id not working

**URL:** <https://discuss.huggingface.co/t/label-2-id-not-working/86557>\
**Category:** Beginners\
**Created:** [May 13, 2024, 10:08pm UTC](https://discuss.huggingface.co/t/label-2-id-not-working/86557 "2024-05-13T22:08:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![maazmusa](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@maazmusa](https://discuss.huggingface.co/u/maazmusa)\
**Post date:** [May 13, 2024, 10:08pm UTC](https://discuss.huggingface.co/t/label-2-id-not-working/86557/1 "2024-05-13T22:08:13Z")

</div>

I recently starting to make a text classification pipeline using this tutorial:

> **[Text classification](https://huggingface.co/docs/transformers/en/tasks/sequence_classification)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

I converted my own data to a dataset with 1 col called text and 1 col called label.

I then did what the tutorial said but I got error:

“”"

Unable to create tensor, you should probably activate truncation and/or padding with ‘padding=True’ ‘truncation=True’ to have batched tensors with the same length. Perhaps your features (`label` in this case) have excessive nesting (inputs type `list` where type `int` is expected).

“”"

I thought id2label and label2id parameter in the model would take care of this. But it didn’t so I added a line in my batch tokenizer to convert the labels to int.

now my tokenized dataset has 1 col called text, 1 col called label, 1 col called input\_ids, 1 col called attention\_masks and 1 more column.

My question is what columns does the Trainer use to train and validate the text classification pipeline? should I remove all other cols from my tokenized dataset?

---

<div class="post-metadata">

**Author:** ![thetraintomars](https://avatars.discourse-cdn.com/v4/letter/t/eada6e/32.png) [@thetraintomars](https://discuss.huggingface.co/u/thetraintomars)\
**Post date:** [June 12, 2025, 9:51am UTC](https://discuss.huggingface.co/t/label-2-id-not-working/86557/2 "2025-06-12T09:51:19Z")

</div>

From reading the troubleshooting docs, the trainer ignores any columns that it doesn’t use, like any untokenized string fields.

Could you share your tokenizer code to convert string labels to int? I am also having an issue where the tutorial code is broken and the trainer seems to ignore id2label and label2id.
