-
Notifications
You must be signed in to change notification settings - Fork 845
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
[Bug]? how does the tokenizer encode the special tokens? #1263
Comments
after some other experiments, I found some weird thing: tokenizer('我是谁')
output:
'input_ids': [1, 29871, 30672, 30392, 235, 179, 132] 1 is bos_token_id, 29871 is the token id of '' tokenizer('我是谁</s>')
output:
'input_ids': [1, 29871, 30672, 30392, 235, 179, 132, 829, 29879, 29958]
tokenizer('who are you</s>')
output:
'input_ids': [1, 1058, 526, 366, 829, 29879, 29958] # there is no 29871. when add a space tokenizer('我是谁 </s>')
output:
'input_ids': [1, 29871, 30672, 30392, 235, 179, 132, 2] # the `</s>` is encoded correctly when decode
the space When manually add token id 29871:
this time, there is a space Does these experiments above means encode, decode methods are not completely Reciprocal reversible operation? |
Thanks for linking to the transformers PR! This issue slipped through the cracks 👍🏻 |
Hi, all, I used the tokenzier to process data for llama model(already converted to hf formated) and set:
when tokenizing a piece of text with an eos_token:
The
eos_token: </s>
is encoded to829, 29879, 29958
which means</s>
is regarded as</
,s
and>
.in this time,
</s>
is encoded correctly (token id is 2).As description above, does this mean we should add a space between text and
eos_token
? however, I find many popular projects likeAlpaca
concatenate text witheos_token
without a space.I previously thought tokenizer encode text in a greedy style, the
eos_token
would be encoded correctly with or without a space. However, the experiments above seemed to not support my opinion.could anyone help me, if there is something misunderstood by me? thx.
The text was updated successfully, but these errors were encountered: