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

update tokenizer process. #2138

Merged
merged 1 commit into from
Aug 8, 2023
Merged

update tokenizer process. #2138

merged 1 commit into from
Aug 8, 2023

Conversation

shibing624
Copy link
Contributor

  1. support llama2, baichuan, bloom, chatglm model data tokenize
  2. make the code more readable

Why are these changes needed?

Related issue number (if applicable)

Checks

  • I've run format.sh to lint the changes in this PR.
  • I've included any doc changes needed.
  • I've made sure the relevant tests are passing (if applicable).

1. support llama2, baichuan, bloom, chatglm model data tokenize
2. make the code more readable
@merrymercy
Copy link
Member

merrymercy commented Aug 2, 2023

Could you double-check that the output of this line (

if False: # Inspect and check the correctness of masking
z = target.clone()
z = torch.where(z == IGNORE_TOKEN_ID, tokenizer.unk_token_id, z)
rank0_print(tokenizer.decode(z))
) is exactly the same before and after your change?
You can see more discussions and test cases at #1894 (comment)

@shibing624
Copy link
Contributor Author

i double chekced, it is right with llama2.

257726417-668e01da-328e-4977-a59c-bbbf757ff45a

@merrymercy merrymercy merged commit bad72ef into lm-sys:main Aug 8, 2023
1 check failed
@merrymercy
Copy link
Member

@shibing624 Thanks! It is merged.

@@ -117,19 +118,17 @@ def preprocess(
total_len = int(target.ne(tokenizer.pad_token_id).sum())

turns = conversation.split(conv.sep2)
cur_len = 1
target[:cur_len] = IGNORE_TOKEN_ID
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shibing624 The first token is for BOS. I found BOS is dropped after your PR. Could you fix this?

@merrymercy
Copy link
Member

I reverted this PR because of the BOS problem (#2138 (comment)). Please fix it and submit a new one.
This part is very error-prone. Please make sure input_ids and targets keep exactly the same for Llama models after your PR.

@shibing624
Copy link
Contributor Author

yes, the tokenizer process with split and find multi round eos_token is very error-prone. so i rewrite the logic of get dialogs from preprocess, then just need tokenize prompt and answer, the code is changed in my repo: https://github.com/shibing624/MedicalGPT/blob/main/supervised_finetuning.py#L653

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants