You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
special: If true, special tokens are rendered in the output."""
2737
2755
...
2738
2756
2739
2757
2758
+
# /// @details Convert the provided tokens into text (inverse of llama_tokenize()).
2759
+
# /// @param text The char pointer must be large enough to hold the resulting text.
2760
+
# /// @return Returns the number of chars/bytes on success, no more than text_len_max.
2761
+
# /// @return Returns a negative number on failure - the number of chars/bytes that would have been returned.
2762
+
# /// @param remove_special Allow to remove BOS and EOS tokens if model is configured to do so.
2763
+
# /// @param unparse_special If true, special tokens are rendered in the output.
2764
+
# LLAMA_API int32_t llama_detokenize(
2765
+
# const struct llama_model * model,
2766
+
# const llama_token * tokens,
2767
+
# int32_t n_tokens,
2768
+
# char * text,
2769
+
# int32_t text_len_max,
2770
+
# bool remove_special,
2771
+
# bool unparse_special);
2772
+
@ctypes_function(
2773
+
"llama_detokenize",
2774
+
[
2775
+
llama_model_p_ctypes,
2776
+
ctypes.POINTER(llama_token),
2777
+
ctypes.c_int32,
2778
+
ctypes.c_char_p,
2779
+
ctypes.c_int32,
2780
+
ctypes.c_bool,
2781
+
ctypes.c_bool,
2782
+
],
2783
+
ctypes.c_int32,
2784
+
)
2785
+
defllama_detokenize(
2786
+
model: llama_model_p,
2787
+
tokens: CtypesArray[llama_token],
2788
+
n_tokens: Union[ctypes.c_int, int],
2789
+
text: bytes,
2790
+
text_len_max: Union[ctypes.c_int, int],
2791
+
remove_special: Union[ctypes.c_bool, bool],
2792
+
unparse_special: Union[ctypes.c_bool, bool],
2793
+
/,
2794
+
) ->int:
2795
+
"""Convert the provided tokens into text (inverse of llama_tokenize()).
2796
+
2797
+
Args:
2798
+
model: The model to use for tokenization.
2799
+
tokens: The tokens to convert.
2800
+
n_tokens: The number of tokens.
2801
+
text: The buffer to write the text to.
2802
+
text_len_max: The length of the buffer.
2803
+
remove_special: Allow to remove BOS and EOS tokens if model is configured to do so.
2804
+
unparse_special: If true, special tokens are rendered in the output."""
2805
+
...
2806
+
2807
+
2740
2808
# /// Apply chat template. Inspired by hf apply_chat_template() on python.
2741
2809
# /// Both "model" and "custom_template" are optional, but at least one is required. "custom_template" has higher precedence than "model"
2742
2810
# /// NOTE: This function does not use a jinja parser. It only support a pre-defined list of template. See more: https://github.com/ggerganov/llama.cpp/wiki/Templates-supported-by-llama_chat_apply_template
0 commit comments