@@ -3710,41 +3710,24 @@ def llama_token_to_piece(
37103710 ...
37113711
37123712
3713- # # // check if token0 is contained as a prefix in token1
3714- # # LLAMA_API bool llama_token_is_prefix(
3715- # # const struct llama_model * model,
3716- # # llama_token token0,
3717- # # llama_token token1);
3718- # @ctypes_function(
3719- # "llama_token_is_prefix",
3720- # [llama_model_p_ctypes, llama_token, llama_token],
3721- # ctypes.c_bool,
3722- # )
3723- # def llama_token_is_prefix(
3724- # model: llama_model_p, token0: Union[llama_token, int], token1: Union[llama_token, int], /
3725- # ) -> bool:
3726- # """Check if token0 is contained as a prefix in token1"""
3727- # ...
3728-
3729-
37303713# /// @details Convert the provided tokens into text (inverse of llama_tokenize()).
37313714# /// @param text The char pointer must be large enough to hold the resulting text.
37323715# /// @return Returns the number of chars/bytes on success, no more than text_len_max.
37333716# /// @return Returns a negative number on failure - the number of chars/bytes that would have been returned.
37343717# /// @param remove_special Allow to remove BOS and EOS tokens if model is configured to do so.
37353718# /// @param unparse_special If true, special tokens are rendered in the output.
37363719# LLAMA_API int32_t llama_detokenize(
3737- # const struct llama_model * model ,
3738- # const llama_token * tokens,
3739- # int32_t n_tokens,
3720+ # const struct llama_vocab * vocab ,
3721+ # const llama_token * tokens,
3722+ # int32_t n_tokens,
37403723# char * text,
3741- # int32_t text_len_max,
3724+ # int32_t text_len_max,
37423725# bool remove_special,
37433726# bool unparse_special);
37443727@ctypes_function (
37453728 "llama_detokenize" ,
37463729 [
3747- llama_model_p_ctypes ,
3730+ llama_vocab_p_ctypes ,
37483731 llama_token_p ,
37493732 ctypes .c_int32 ,
37503733 ctypes .c_char_p ,
@@ -3755,7 +3738,7 @@ def llama_token_to_piece(
37553738 ctypes .c_int32 ,
37563739)
37573740def llama_detokenize (
3758- model : llama_model_p ,
3741+ vocab : llama_vocab_p ,
37593742 tokens : CtypesArray [llama_token ],
37603743 n_tokens : Union [ctypes .c_int , int ],
37613744 text : bytes ,
@@ -3767,13 +3750,14 @@ def llama_detokenize(
37673750 """Convert the provided tokens into text (inverse of llama_tokenize()).
37683751
37693752 Args:
3770- model : The model to use for tokenization.
3753+ vocab : The model vocab to use for tokenization.
37713754 tokens: The tokens to convert.
37723755 n_tokens: The number of tokens.
37733756 text: The buffer to write the text to.
37743757 text_len_max: The length of the buffer.
37753758 remove_special: Allow to remove BOS and EOS tokens if model is configured to do so.
3776- unparse_special: If true, special tokens are rendered in the output."""
3759+ unparse_special: If true, special tokens are rendered in the output.
3760+ """
37773761 ...
37783762
37793763
0 commit comments