Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about generation loss #3

Open
bjtuxck opened this issue Feb 5, 2024 · 1 comment
Open

about generation loss #3

bjtuxck opened this issue Feb 5, 2024 · 1 comment

Comments

@bjtuxck
Copy link

bjtuxck commented Feb 5, 2024

src/modeling code:
if self.training:
# 只对positive计算generation loss
# generated_q_hidden = generated_q_hidden[:,None,:,:].view(bz, self.args.sample_num, -1, p_hidden.size(-1))[:,0,:,:] # [bz, seq_len, 768]
if mlm_labels is not None and mlm_labels['decoder_mlm_labels'] is not None:
mlm_loss += self.mlm_loss(generated_q_hidden, mlm_labels['decoder_mlm_labels']) # query生成loss

如何保证只对【正样本】计算mlm_loss?负样本是如何过滤的?

@Deriq-Qian-Dong
Copy link
Owner

p_hidden的第一个位置都是正样本的hidden state,只用第一个就行了
参考代码中的p_hidden.size(-1))[:,0,:,:]

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

No branches or pull requests

2 participants