EasyEdit icon indicating copy to clipboard operation
EasyEdit copied to clipboard

line 118 in ft_main.py

Open SH9959 opened this issue 1 year ago • 1 comments

Line 118 of ft_main.py:

loss_mask = target_ids ! = tok.unk_token_id

The handling of tok.unk_token_id as None seems to be omitted here. If tok.unk_token_id is None, then on line 201 loss = -(torch.gather(probs, 1, target_ids) * loss_mask).sum(1) / loss_mask.sum(1) will report an error of .sum()

SH9959 avatar May 09 '24 05:05 SH9959

I'm not quite sure if it would be better to modify it like the following.😊

  if tok.unk_token_id is None:
      tok.unk_token_id = tok.pad_token_id
  loss_mask = target_ids != tok.unk_token_id

SH9959 avatar May 09 '24 05:05 SH9959

Thank you very much for your advice; we have updated the code. Wishing you a pleasant life!

XeeKee avatar May 10 '24 13:05 XeeKee