xlora icon indicating copy to clipboard operation
xlora copied to clipboard

cross entropy loss during training with xlora

Open crossxxd opened this issue 1 year ago • 4 comments

I saw discussions about training in other issues, and I have run train and inference code successfully. Training code is mainly based on SFTTrainer and I think only next-token prediction loss is used. If I want to add cross entropy loss mentioned in the paper, what should I do?

crossxxd avatar Apr 03 '24 01:04 crossxxd

To use cross-entropy loss, we configure the training loop to use CE loss.

EricLBuehler avatar Apr 04 '24 22:04 EricLBuehler

I have rewritten the trainer from transformers lib and added the cross entropy of the xlora classifier's category output. There is no problem for now. Thanks for your reply!

crossxxd avatar Apr 23 '24 10:04 crossxxd

@crossxxd, we do not train for the X-LoRA classifier's scalings output in the paper, although you could try that. We just train the model as normal, with the CE loss on the output of the model. This works because the gradients propagate up to the X-LoRA classifier's output, and because the output is a result of the X-LoRA classifier we are training the X-LoRA classifier.

EricLBuehler avatar Apr 23 '24 10:04 EricLBuehler

It seems that I misunderstood the definition of loss in the paper. For now, I am using the loss on the output of the model combined with the loss on the scalings output of the xlora classifier for overall training. The total loss can converge and xlora model works fine.

crossxxd avatar Apr 23 '24 10:04 crossxxd