# Could someone please explain how to make a multi-label dataset from csv?

**URL:** <https://discuss.huggingface.co/t/could-someone-please-explain-how-to-make-a-multi-label-dataset-from-csv/18534>\
**Category:** Beginners\
**Created:** [May 30, 2022, 4:42pm UTC](https://discuss.huggingface.co/t/could-someone-please-explain-how-to-make-a-multi-label-dataset-from-csv/18534 "2022-05-30T16:42:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yulgm](https://avatars.discourse-cdn.com/v4/letter/y/41988e/32.png) [@yulgm](https://discuss.huggingface.co/u/yulgm)\
**Post date:** [May 30, 2022, 4:42pm UTC](https://discuss.huggingface.co/t/could-someone-please-explain-how-to-make-a-multi-label-dataset-from-csv/18534/1 "2022-05-30T16:42:43Z")

</div>

I have a csv file with two columns in which there are thousands of sentences (column 1, ‘sentence’) and they are marked as ‘type1’ and ‘type2’ (column 2, ‘label’). I need to build a classifier that learns to split incoming sentences into these two categories.

I tried to load the data and pass to:

```auto
from transformers import AutoModelForSequenceClassification
model = AutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased", num_labels=2)

df = pd.read_csv('filename.csv')
ds = Dataset.from_pandas(df)

```

but it never works if I set the model’s `num_labels` to anything other than 1. I get dimension errors. How do I specify in the dataset that there are 2 labels? (and maybe in general, how to specify that the label column is categorical, which N possible classes)

I’m really just trying to build a basic sentence classifier from my own labeled data…

---

<div class="post-metadata">

**Author:** ![nbroad](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nbroad/32/26465_2.png) [@nbroad](https://discuss.huggingface.co/u/nbroad)\
**Post date:** [May 31, 2022, 1:35pm UTC](https://discuss.huggingface.co/t/could-someone-please-explain-how-to-make-a-multi-label-dataset-from-csv/18534/2 "2022-05-31T13:35:53Z")

</div>

Here’s an example: [Transformers-Tutorials/Fine\_tuning\_BERT\_(and\_friends)\_for\_multi\_label\_text\_classification.ipynb at master · NielsRogge/Transformers-Tutorials · GitHub](https://github.com/NielsRogge/Transformers-Tutorials/blob/master/BERT/Fine_tuning_BERT_(and_friends)_for_multi_label_text_classification.ipynb)

---

<div class="post-metadata">

**Author:** ![yulgm](https://avatars.discourse-cdn.com/v4/letter/y/41988e/32.png) [@yulgm](https://discuss.huggingface.co/u/yulgm)\
**Post date:** [May 31, 2022, 8:57pm UTC](https://discuss.huggingface.co/t/could-someone-please-explain-how-to-make-a-multi-label-dataset-from-csv/18534/3 "2022-05-31T20:57:43Z")

</div>

Thank you!
