@@ -208,7 +208,7 @@ def tokenize(self, text: bytes, add_bos: bool, special: bool):
208208 def token_to_piece (self , token : int , special : bool = False ) -> bytes :
209209 assert self .model is not None
210210 buf = ctypes .create_string_buffer (32 )
211- llama_cpp .llama_token_to_piece (self .model , token , buf , 32 , special )
211+ llama_cpp .llama_token_to_piece (self .model , token , buf , 32 , 0 , special )
212212 return bytes (buf )
213213
214214 def detokenize (self , tokens : List [int ], special : bool = False ) -> bytes :
@@ -218,7 +218,7 @@ def detokenize(self, tokens: List[int], special: bool = False) -> bytes:
218218 buffer = (ctypes .c_char * size )()
219219 for token in tokens :
220220 n = llama_cpp .llama_token_to_piece (
221- self .model , llama_cpp .llama_token (token ), buffer , size , special
221+ self .model , llama_cpp .llama_token (token ), buffer , size , 0 , special
222222 )
223223 assert n <= size
224224 output += bytes (buffer [:n ])
@@ -635,10 +635,10 @@ def _tokenize(model: _LlamaModel, text: str, add_bos: bool, special: bool) -> li
635635def _token_to_piece (model : _LlamaModel , token : int , special : bool = False ) -> str :
636636 assert model .model is not None
637637 result = (ctypes .c_char * 8 )(0 )
638- n_tokens = llama_cpp .llama_token_to_piece (model .model , token , result , len (result ), special )
638+ n_tokens = llama_cpp .llama_token_to_piece (model .model , token , result , 0 , len (result ), special )
639639 if n_tokens < 0 :
640640 result = (ctypes .c_char * - n_tokens )(0 )
641- check = llama_cpp .llama_token_to_piece (model .model , token , result , len (result ), special )
641+ check = llama_cpp .llama_token_to_piece (model .model , token , result , 0 , len (result ), special )
642642 if check != - n_tokens :
643643 raise RuntimeError (f"Failed to get piece: token={ token } " )
644644 else :
0 commit comments