@@ -2380,6 +2380,18 @@ def llama_token_get_type(
23802380 ...
23812381
23822382
2383+ # // Check if the token is supposed to end generation (end-of-generation, eg. EOS, EOT, etc.)
2384+ # LLAMA_API bool llama_token_is_eog(const struct llama_model * model, llama_token token);
2385+ @ctypes_function (
2386+ "llama_token_is_eog" , [llama_model_p_ctypes , llama_token ], ctypes .c_bool
2387+ )
2388+ def llama_token_is_eog (
2389+ model : llama_model_p , token : Union [llama_token , int ], /
2390+ ) -> bool :
2391+ """Check if the token is supposed to end generation (end-of-generation, eg. EOS, EOT, etc.)"""
2392+ ...
2393+
2394+
23832395# // Special tokens
23842396
23852397
@@ -2434,7 +2446,7 @@ def llama_add_eos_token(model: llama_model_p, /) -> int:
24342446 ...
24352447
24362448
2437- # // codellama infill tokens
2449+ # // Codellama infill tokens
24382450# LLAMA_API llama_token llama_token_prefix(const struct llama_model * model); // Beginning of infill prefix
24392451@ctypes_function ("llama_token_prefix" , [llama_model_p_ctypes ], llama_token )
24402452def llama_token_prefix (model : llama_model_p ) -> int :
@@ -2524,18 +2536,21 @@ def llama_tokenize(
25242536# // Uses the vocabulary in the provided context.
25252537# // Does not write null terminator to the buffer.
25262538# // User code is responsible to remove the leading whitespace of the first non-BOS token when decoding multiple tokens.
2539+ # // @param special If true, special tokens are rendered in the output.
25272540# LLAMA_API int32_t llama_token_to_piece(
25282541# const struct llama_model * model,
25292542# llama_token token,
25302543# char * buf,
2531- # int32_t length);
2544+ # int32_t length,
2545+ # bool special);
25322546@ctypes_function (
25332547 "llama_token_to_piece" ,
25342548 [
25352549 llama_model_p_ctypes ,
25362550 llama_token ,
25372551 ctypes .c_char_p ,
25382552 ctypes .c_int32 ,
2553+ ctypes .c_bool ,
25392554 ],
25402555 ctypes .c_int32 ,
25412556)
@@ -2544,13 +2559,20 @@ def llama_token_to_piece(
25442559 token : Union [llama_token , int ],
25452560 buf : Union [ctypes .c_char_p , bytes , CtypesArray [ctypes .c_char ]],
25462561 length : Union [ctypes .c_int , int ],
2562+ special : Union [ctypes .c_bool , bool ],
25472563 / ,
25482564) -> int :
25492565 """Token Id -> Piece.
25502566 Uses the vocabulary in the provided context.
25512567 Does not write null terminator to the buffer.
25522568 User code is responsible to remove the leading whitespace of the first non-BOS token when decoding multiple tokens.
2553- """
2569+
2570+ Args:
2571+ model: The model to use for tokenization.
2572+ token: The token to convert.
2573+ buf: The buffer to write the token to.
2574+ length: The length of the buffer.
2575+ special: If true, special tokens are rendered in the output."""
25542576 ...
25552577
25562578
0 commit comments