# How to modify loss function in a seq2seq trainer?

**URL:** <https://discuss.huggingface.co/t/how-to-modify-loss-function-in-a-seq2seq-trainer/104680>\
**Category:** 🤗Transformers\
**Created:** [August 30, 2024, 3:15pm UTC](https://discuss.huggingface.co/t/how-to-modify-loss-function-in-a-seq2seq-trainer/104680 "2024-08-30T15:15:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](https://discuss.huggingface.co/u/nielsr)\
**Post date:** [August 31, 2024, 8:36am UTC](https://discuss.huggingface.co/t/how-to-modify-loss-function-in-a-seq2seq-trainer/104680/2 "2024-08-31T08:36:57Z")

</div>

Hi,

You can overwrite the Seq2SeqTrainer’s compute\_loss method as shown [here](https://discuss.huggingface.co/t/specify-loss-for-trainer-trainingarguments/10481/2).

---

_[View the full topic](https://discuss.huggingface.co/t/how-to-modify-loss-function-in-a-seq2seq-trainer/104680)._
