Skip to content

Commit

Permalink
Fix Llama 3 TikToken conversion (#33538)
Browse files Browse the repository at this point in the history
* Fix Llama 3 TikToken conversion

* No need to add tokens again
  • Loading branch information
pcuenca authored Sep 19, 2024
1 parent 4d8908d commit 0c718f1
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/transformers/models/llama/convert_llama_weights_to_hf.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def permute(w, n_heads, dim1=dim, dim2=dim):

class Llama3Converter(TikTokenConverter):
def __init__(self, vocab_file, special_tokens=None, instruct=False, model_max_length=None, **kwargs):
super().__init__(vocab_file, **kwargs)
super().__init__(vocab_file, additional_special_tokens=special_tokens, **kwargs)
tokenizer = self.converted()
chat_template = (
"{% set loop_messages = messages %}"
Expand All @@ -345,7 +345,6 @@ def __init__(self, vocab_file, special_tokens=None, instruct=False, model_max_le
"{% endfor %}"
"{{ '<|start_header_id|>assistant<|end_header_id|>\n\n' }}"
)
tokenizer.add_special_tokens(special_tokens)

self.tokenizer = PreTrainedTokenizerFast(
tokenizer_object=tokenizer,
Expand Down

0 comments on commit 0c718f1

Please sign in to comment.