# Mullti Label Text Classification

**URL:** <https://discuss.huggingface.co/t/mullti-label-text-classification/44233>\
**Category:** 🤗Transformers\
**Created:** [June 22, 2023, 10:03pm UTC](https://discuss.huggingface.co/t/mullti-label-text-classification/44233 "2023-06-22T22:03:01Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![rvienne](https://avatars.discourse-cdn.com/v4/letter/r/50afbb/32.png) [@rvienne](https://discuss.huggingface.co/u/rvienne)\
**Post date:** [June 23, 2023, 7:45am UTC](https://discuss.huggingface.co/t/mullti-label-text-classification/44233/2 "2023-06-23T07:45:06Z")

</div>

Hello @ayush-adeptmind,  
From my understanding of your question you want to introduce a weighted loss into your multilabel classification problem.  
For such a problem, the best way to do I’m aware of while using transformers library is to override the Trainer class (create a new trainer class which inherits from the actual Trainer) and override (by defining it again) the “compute\_loss” method.  
When instanciating BCEWithLogitsLoss, you should be able to insert a weight vector.

See [How can I use class\_weights when training?](https://discuss.huggingface.co/t/how-can-i-use-class-weights-when-training/1067) for more precise information and code snippets.

Have a good day!

---

_[View the full topic](https://discuss.huggingface.co/t/mullti-label-text-classification/44233)._
