Add support for passing args and kwargs to per-sample loss functions #786
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Types of changes
Motivation and Context / Related issue
It prevents
TypeError: DPLossFastGradientAdaptiveClipping.__call__() got an unexpected keyword argument 'vocab_size'
error from triggering when assigningDPLossFastGradientAdaptiveClipping
orDPLossFastGradientClipping
to the.loss_function
property of anyPreTrainedModel
.Every
PreTrainedModel.loss_function()
call expectsvocab_size
amongst it's keyword arguments:Meanwhile,
DPLossFastGradientAdaptiveClipping.__call__
andDPLossFastGradientClipping.__call__
don't have this keyword argumentvocab_size
in their signature.vocab
size is later needed for tensor flattening:How Has This Been Tested (if it applies)
Tested and trained on transformers'
GPT2LMHeadModel
with LoRA and 4B parameter LlamaLlamaForCausalLM
model, purposefully targeting different model architectures.Checklist