Skip to content

Commit

Permalink
fix: segfault for models without eos / bos tokens. Closes #1463
Browse files Browse the repository at this point in the history
  • Loading branch information
abetlen committed May 16, 2024
1 parent e811a81 commit d99a6ba
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions llama_cpp/llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ def __init__(
eos_token_id = self.token_eos()
bos_token_id = self.token_bos()

eos_token = self._model.token_get_text(eos_token_id)
bos_token = self._model.token_get_text(bos_token_id)
eos_token = self._model.token_get_text(eos_token_id) if eos_token_id != -1 else ""
bos_token = self._model.token_get_text(bos_token_id) if bos_token_id != -1 else ""

# Unfortunately the llama.cpp API does not return metadata arrays, so we can't get template names from tokenizer.chat_templates
template_choices = dict((name[10:], template) for name, template in self.metadata.items() if name.startswith("tokenizer.chat_template."))
Expand Down

0 comments on commit d99a6ba

Please sign in to comment.