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

fix: inconsistent tokenization by llama tokenizer #3006

Merged
merged 2 commits into from
Feb 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion fastchat/train/train_with_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def mask_targets(conversations, targets, tokenizer, conv):
if i != 0:
turn = user_turn_separator + turn

turn_len = len(tokenizer(turn).input_ids)
turn_len = len(tokenizer(turn, add_special_tokens=False).input_ids)

if assistant_turn_separator in turn:
parts = turn.rsplit(assistant_turn_separator)
Expand Down Expand Up @@ -373,6 +373,7 @@ def train():
)
# NOTE: if the token_id exceed the vocab_size will cause failing in training process! we need add special config and resize the embedding size!
tokenizer.pad_token = tokenizer.unk_token
tokenizer.pad_token_id = tokenizer.unk_token_id
print(f"tokens len: {len(tokenizer)}")
model.resize_token_embeddings(len(tokenizer))

Expand Down
Loading