Chapter 3 questions

RiZiou
Sun, 07 Dec 2025 17:37:05 +0000

Hi there!

I have a question regarding A full training loop - Hugging Face LLM Course

The “outputs.loss” returns “grad_fn=NllLossBackward0”, from which I understand that the BertForSequenceClassification uses a negative log likelihood loss. However, the modeling_bert .py seems to use a CrossEntropyLoss ( transformers/src/transformers/modeling_bert.py at 9aeacb58bab321bc21c24bbdf7a24efdccb1d426 · huggingface/transformers · GitHub ).

What is the loss function really used in this model?

Thank you very much!

Riad