Skip to content

Commit

Permalink
LLaMa: get tokens in the range of the vocab size (#1621)
Browse files Browse the repository at this point in the history
Co-authored-by: thucpham <minhthuc.pham@systrangroup.com>
  • Loading branch information
minhthuc2502 and thucpham authored Feb 12, 2024
1 parent ce47032 commit 8e82733
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/ctranslate2/converters/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,8 @@ def get_vocabulary(self, model, tokenizer):
extra_ids = model.config.vocab_size - len(tokens)
for i in range(extra_ids):
tokens.append("<extra_id_%d>" % i)
if model.config.vocab_size < len(tokens):
tokens = tokens[: model.config.vocab_size]

return tokens

Expand Down

0 comments on commit 8e82733

Please sign in to comment.