# T5 multilabel classification using tf

**URL:** <https://discuss.huggingface.co/t/t5-multilabel-classification-using-tf/34858>\
**Category:** 🤗Transformers\
**Created:** [March 28, 2023, 4:00am UTC](https://discuss.huggingface.co/t/t5-multilabel-classification-using-tf/34858 "2023-03-28T04:00:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sreraku](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@sreraku](https://discuss.huggingface.co/u/sreraku)\
**Post date:** [March 28, 2023, 4:00am UTC](https://discuss.huggingface.co/t/t5-multilabel-classification-using-tf/34858/1 "2023-03-28T04:00:34Z")

</div>

I am trying to do multilabel classification on a corpus of data which has labels too. When  
The data looks like this after adding the tag in the front for each row:

print(texts)  
0 multilabel classification: how time changes th…  
1 multilabel classification: hawaii has been in …  
2 multilabel classification: not all alaskans ar…  
3 multilabel classification: you should read rap…  
4 multilabel classification: giving stupid kids …

I am trying to tokenize above and since there are multiple rows, I am guessing i have to go in a loop. What I am trying understand is, how do I get the input\_ids, attention\_mask? should I go in a loop to get for each row or for the entire text?  
am I doing it right above by adding the tag multilabel classification: for each row? am totally confused whether my assumption is wrong or whether this is the way to do it.

my code is:

src\_tokenized = TOKENIZER.encode\_plus(  
texts[0],  
max\_length=SRC\_MAX\_LENGTH,  
pad\_to\_max\_length=True,  
truncation=True,  
return\_attention\_mask=True,  
return\_token\_type\_ids=False,  
return\_tensors=‘tf’  
)  
src\_input\_ids = src\_tokenized[‘input\_ids’]  
src\_attention\_mask = src\_tokenized[‘attention\_mask’]

t5\_summary\_ids = t5\_model.generate(src\_input\_ids)

am feeling am doing wrong by running it row by row. but am not sure. I googled for it and all i see multilabel classification example is using pytorch not tf.

Appreciate all the help. TIA
