FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: the source part should not participate in loss calculation in SFT stage by xffxff · Pull Request #762 · deepspeedai/DeepSpeedExamples · GitHub

fix: the source part should not participate in loss calculation in SFT stage - #762

Open
xffxff wants to merge 1 commit into
deepspeedai:masterfrom
xffxff:sft_loss
Open

fix: the source part should not participate in loss calculation in SFT stage#762
xffxff wants to merge 1 commit into
deepspeedai:masterfrom
xffxff:sft_loss

Conversation

xffxff commented Oct 10, 2023
edited
Loading

Copy link
Copy Markdown
Contributor

fix #660

In the SFT stage, it's essential that the source part doesn't contribute to the loss calculation, only the completion part should be considered. To address this issue, I've adjusted the labels for the source part to be set as -100. This specific value, -100, corresponds to the default "ignore index" in the torch.nn.CrossEntropyLoss function. Importantly, both OPT and LLAMA models utilize torch.nn.CrossEntropyLoss for their loss calculations, as seen in OPTForCausalLM and LLamaForCausalLM. As a result, there is no need to make any modifications to the way the loss is computed, as it will automatically handle the source part as intended.

The training loss of opt-350m with Dahoas/rm-static as dataset

Copy link
Copy Markdown
  1. The function is now moved to "DeepSpeedExamples/applications/DeepSpeed-Chat/dschat/utils/data/data_utils.py"
  2. This solution seems to assume single-turn conversation, please consider cases for multi-turn conversation.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Step1: Not mask source part

2 participants


Back | FazBrowse Home | New Git URL