From d99a6ba607a4885fb00e63e967964aa41bdbbbcb Mon Sep 17 00:00:00 2001 From: Andrei Betlen Date: Thu, 16 May 2024 00:37:27 -0400 Subject: [PATCH] fix: segfault for models without eos / bos tokens. Closes #1463 --- llama_cpp/llama.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llama_cpp/llama.py b/llama_cpp/llama.py index 7145329..043fb2a 100644 --- a/llama_cpp/llama.py +++ b/llama_cpp/llama.py @@ -413,8 +413,8 @@ class Llama: 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."))