# Dataset for multilabel classification

**URL:** <https://discuss.huggingface.co/t/dataset-for-multilabel-classification/136584>\
**Category:** 🤗Transformers\
**Created:** [January 20, 2025, 8:06pm UTC](https://discuss.huggingface.co/t/dataset-for-multilabel-classification/136584 "2025-01-20T20:06:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![celalp](https://avatars.discourse-cdn.com/v4/letter/c/8edcca/32.png) [@celalp](https://discuss.huggingface.co/u/celalp)\
**Post date:** [January 20, 2025, 8:06pm UTC](https://discuss.huggingface.co/t/dataset-for-multilabel-classification/136584/1 "2025-01-20T20:06:39Z")

</div>

Hi I have a dataset for multi-label classification, I have 14 categories and a decent amount of data. However I’m having issues trying to get the training going.

I have tried one hot encoding or passing the list of classes but keep getting errors.

Basically I have a dataset that looks like this:

```auto
{"text":["text1", "text2", "text3"], "labels":[[0,0,0], [1,1,1], [0,1,3]]}

```

I have been searching a lot of places and there are conflicting things and virtually no documentation on this subject. Does anyone have any code snippets for creating datasets or training such models?

Thanks.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [January 20, 2025, 10:42pm UTC](https://discuss.huggingface.co/t/dataset-for-multilabel-classification/136584/2 "2025-01-20T22:42:35Z")

</div>

I hope this is helpful…

> [@Dataset label format for multi-label text classification](https://discuss.huggingface.co/t/dataset-label-format-for-multi-label-text-classification/14998):
>
> Hi, I’ve been able to train a multi-label Bert classifier using a custom Dataset object and the Trainer API from Transformers. The Dataset contains two columns: text and label. After tokenizing, I have all the needed columns for training. For multi-label classification I also set model.config.problem\_type = "multi\_label\_classification", and define each label as a multi-hot vector (a list of 0/1 values, each corresponding to a different class). So for instance, given the task consists in assig…

> **[Multi-Label Classification Model From Scratch: Step-by-Step Tutorial](https://huggingface.co/blog/Valerii-Knowledgator/multi-label-classification)**
>
> A Blog post by Valerii Vasylevskyi on Hugging Face
