summaryrefslogtreecommitdiff
path: root/llama.h
diff options
context:
space:
mode:
authorstaviq <staviq@gmail.com>2023-10-17 17:11:01 +0200
committerGitHub <noreply@github.com>2023-10-17 18:11:01 +0300
commit1a159553f921a9209fed8c714494e57b3649f232 (patch)
treeb880614b6be6541d1890db725a7292fccef93855 /llama.h
parent281ef73c258cc1eebec8a64264240432d5878c4b (diff)
tokenizer : special token handling (#3538)
* Rewrite special token handling from #1931 * shorten param name, add st verification by type * use offsets instead of copy by substr * formatting, remove copying iterator on delete * llama : normalize code-style * swift fix * print pfx/sfx if verb, main: split pfx input sfx * dont add space when using special tokens * minor : comment + spacing --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
Diffstat (limited to 'llama.h')
-rw-r--r--llama.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/llama.h b/llama.h
index a78015ad..b13f2312 100644
--- a/llama.h
+++ b/llama.h
@@ -511,17 +511,20 @@ extern "C" {
// Tokenization
//
- // Convert the provided text into tokens.
- // The tokens pointer must be large enough to hold the resulting tokens.
- // Returns the number of tokens on success, no more than n_max_tokens
- // Returns a negative number on failure - the number of tokens that would have been returned
+ /// @details Convert the provided text into tokens.
+ /// @param tokens The tokens pointer must be large enough to hold the resulting tokens.
+ /// @return Returns the number of tokens on success, no more than n_max_tokens
+ /// @return Returns a negative number on failure - the number of tokens that would have been returned
+ /// @param special Allow tokenizing special and/or control tokens which otherwise are not exposed and treated as plaintext.
+ /// Does not insert a leading space.
LLAMA_API int llama_tokenize(
const struct llama_model * model,
const char * text,
int text_len,
llama_token * tokens,
int n_max_tokens,
- bool add_bos);
+ bool add_bos,
+ bool special);
// Token Id -> Piece.
// Uses the vocabulary in the provided context.