From 67c70cc8ebfc7648e453add5c3b85dd71b6d985f Mon Sep 17 00:00:00 2001 From: Andrei Betlen Date: Sat, 1 Apr 2023 17:29:30 -0400 Subject: [PATCH] Add static methods for beginning and end of sequence tokens. --- docs/index.md | 2 ++ llama_cpp/llama.py | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/docs/index.md b/docs/index.md index 388d8c5..0377a47 100644 --- a/docs/index.md +++ b/docs/index.md @@ -69,6 +69,8 @@ python3 setup.py develop - create_embedding - create_completion - __call__ + - token_bos + - token_eos show_root_heading: true ::: llama_cpp.llama_cpp diff --git a/llama_cpp/llama.py b/llama_cpp/llama.py index a55b422..019605a 100644 --- a/llama_cpp/llama.py +++ b/llama_cpp/llama.py @@ -446,3 +446,13 @@ class Llama: if self.ctx is not None: llama_cpp.llama_free(self.ctx) self.ctx = None + + @staticmethod + def token_eos() -> llama_cpp.llama_token: + """Return the end-of-sequence token.""" + return llama_cpp.llama_token_eos() + + @staticmethod + def token_bos() -> llama_cpp.llama_token: + """Return the beginning-of-sequence token.""" + return llama_cpp.llama_token_bos()