You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In models / fuyu processing_fuyu.py , the method get labels , what is the purpose of special_token_id and how do I get it.
For example my input ids look like this.
" Extract text from this image " , using fuyo processor I pass in the image and text and get input_ids , I am not too sure how to get labels from input_ids using the above method.
The text was updated successfully, but these errors were encountered:
The special_token_id is from Fuyu's design, it's a \x04 that use to separate Questions and Answers.
(if I remember correctly)
Fuyu's template is:
"{question}\n\x04{answer}\x04".
Our template is
"User:{question} Assistant:\x04{answer}\x04".
We also use it to locate the answer's position since we need to mask the {answer} during training.
The code is here~
# src/otter_ai/models/fuyu/processing_fuyu.pydefget_labels(self, input_ids, special_token_id, masking_number=-100):
# Initialize labels tensor filled with masking_numberlabels=torch.full_like(input_ids, masking_number)
# Iterate through each sequence in the batchforiinrange(input_ids.shape[0]):
seq=input_ids[i]
# Find the indices of the special_token_idindices= (seq==special_token_id).nonzero(as_tuple=False).squeeze()
# Pair the indices and unmask the tokens between each pairtpaired_indices=indices.reshape(-1, 2)
forstart, endinpaired_indices:
labels[i, start+1 : end+1] =seq[start+1 : end+1]
returnlabels
In models / fuyu processing_fuyu.py , the method get labels , what is the purpose of special_token_id and how do I get it.
For example my input ids look like this.
" Extract text from this image " , using fuyo processor I pass in the image and text and get input_ids , I am not too sure how to get labels from input_ids using the above method.
The text was updated successfully, but these errors were encountered: