Skip to content

Commit 5be8354

Browse files
committed
Added tokenizer
1 parent 8fa2ef1 commit 5be8354

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llama_cpp/llama.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,8 +1416,10 @@ class LlamaTokenizer:
14161416
def __init__(self, llama: Llama):
14171417
self.llama = llama
14181418

1419-
def encode(self, text: str) -> List[int]:
1420-
return self.llama.tokenize(text.encode("utf-8", errors="ignore"))
1419+
def encode(self, text: str, add_bos: bool = True) -> List[int]:
1420+
return self.llama.tokenize(
1421+
text.encode("utf-8", errors="ignore"), add_bos=add_bos
1422+
)
14211423

14221424
def decode(self, tokens: List[int]) -> str:
14231425
return self.llama.detokenize(tokens).decode("utf-8", errors="ignore")

0 commit comments

Comments
 (0)