-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
Truncated assistant message gets a 0 asssitant mask #34494
Comments
Also @yonigottesman, assistant_mask in not converted ot a tensor even if I do tokens = tokenizer.apply_chat_template(
chat,
tokenize=True,
return_assistant_tokens_mask=True,
return_dict=True,
chat_template=better_template,
return_tensors ="pt"
) |
@Butanium you are right there is a bug in my code, I will fix and update. |
thank you! I edited my template to include the |
Thanks for the fix @yonigottesman! Should open another issue regarding the return type of assistant_masks? It does not get converted to pytorch tensor by default tokens = tokenizer.apply_chat_template(
chat,
tokenize=True,
return_assistant_tokens_mask=True,
return_dict=True,
chat_template=better_template,
return_tensors ="pt"
)
In [14]: type(tokens.input_ids)
Out[14]: torch.Tensor
In [15]: type(tokens.assistant_masks)
Out[15]: list |
hi can you explain why you would want a tensor in this case? |
@yonigottesman I'd expect assistant_masks = th.tensor(batch_tokens["assistant_masks"]).bool().to(device) |
Hi @yonigottesman, sorry to bother you with that. I'm wondering: should I open another issue regarding this conversion to tensor issue ? |
System Info
transformers
version: 4.45.2Who can help?
@yonigottesman
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
I modified gemma template to allow
assitant_masks
to work:however, if a model message gets truncated, the mask is all 0:
Expected behavior
I'd expect the mask to have 1 on the partial model response
The text was updated successfully, but these errors were encountered: