# Implementing Triplet loss in Vit

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimplementing-triplet-loss-in-vit%2F157754%3E%5C
**Category:** 🤗Transformers\
**Created:** [June 2, 2025, 8:34pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimplementing-triplet-loss-in-vit%2F157754 "2025-06-02T20:34:23Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [June 3, 2025, 12:18am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimplementing-triplet-loss-in-vit%2F157754%2F2 "2025-06-03T00:18:20Z")

</div>

I think overriding the function is the most reliable way.

> [@Specify Loss for Trainer / TrainingArguments](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fspecify-loss-for-trainer-trainingarguments%2F10481)%3A
>
> I’d like to fine-tune for a regression task rather than a classification task. How do I change the default loss in either TrainingArguments or Trainer()?

[https://stackoverflow.com/questions/66302371/how-to-specify-the-loss-function-when-finetuning-a-model-using-the-huggingface-t](https://stackoverflow.com/questions/66302371/how-to-specify-the-loss-function-when-finetuning-a-model-using-the-huggingface-t)

> [@Trainer.evaluate() doesn't return evaluation loss](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrainer-evaluate-doesnt-return-evaluation-loss%2F140841)%3A
>
> I am using Seq2SeqTrainer to lora finetune madlad 3b model using my own dataset. When I run trainer.evaluate(), the evaluation loss is not printing. Code: output\_dir = "madlad\_run\_5" training\_args = Seq2SeqTrainingArguments( output\_dir, per\_device\_train\_batch\_size=32, # per\_device\_eval\_batch\_size=2, num\_train\_epochs=1, # max\_steps=1000, # gradient\_accumulation\_steps=8, bf16=True, torch\_compile=True, # gradient\_checkpointing=True, # torch\_empty\_cache\_st…

---

_[View the full topic](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimplementing-triplet-loss-in-vit%2F157754)._
