summaryrefslogtreecommitdiff
path: root/llama.h
diff options
context:
space:
mode:
authorjaime-m-p <167997752+jaime-m-p@users.noreply.github.com>2024-06-04 09:17:17 +0200
committerGitHub <noreply@github.com>2024-06-04 09:17:17 +0200
commit3b38d48609280aa5f8ab7ea135a4351b2a5ee240 (patch)
treec3fdcd91e9959ee394ea798d78731e611faaa008 /llama.h
parent6d1616944d9efd342ed2a4fd318722adfc9febcd (diff)
Per token attributes (#7685)
* Add per token attributes enum * Using phi-3 for testing 'rstrip' * Using jina-v2 for testing 'lstrip' * Brute force test for 'lstrip' and 'rstrip' * Implement 'rstrip' and 'lstrip' * Update phi-3 GGUF file (obsolete since 917dc8c) * Replace llama_token_type with llama_token_attribs
Diffstat (limited to 'llama.h')
-rw-r--r--llama.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/llama.h b/llama.h
index 95105c28..a78ccdaf 100644
--- a/llama.h
+++ b/llama.h
@@ -97,7 +97,7 @@ extern "C" {
LLAMA_ROPE_TYPE_GLM = 4,
};
- enum llama_token_type {
+ enum llama_token_type { //TODO: remove, required until per token attributes are available from GGUF file
LLAMA_TOKEN_TYPE_UNDEFINED = 0,
LLAMA_TOKEN_TYPE_NORMAL = 1,
LLAMA_TOKEN_TYPE_UNKNOWN = 2,
@@ -107,6 +107,20 @@ extern "C" {
LLAMA_TOKEN_TYPE_BYTE = 6,
};
+ enum llama_token_attr {
+ LLAMA_TOKEN_ATTR_UNDEFINED = 0,
+ LLAMA_TOKEN_ATTR_UNKNOWN = 1 << 1,
+ LLAMA_TOKEN_ATTR_UNUSED = 1 << 2,
+ LLAMA_TOKEN_ATTR_NORMAL = 1 << 3,
+ LLAMA_TOKEN_ATTR_CONTROL = 1 << 4, // SPECIAL?
+ LLAMA_TOKEN_ATTR_USER_DEFINED = 1 << 5,
+ LLAMA_TOKEN_ATTR_BYTE = 1 << 6,
+ LLAMA_TOKEN_ATTR_NORMALIZED = 1 << 7,
+ LLAMA_TOKEN_ATTR_LSTRIP = 1 << 8,
+ LLAMA_TOKEN_ATTR_RSTRIP = 1 << 9,
+ LLAMA_TOKEN_ATTR_SINGLE_WORD = 1 << 10,
+ };
+
// model file types
enum llama_ftype {
LLAMA_FTYPE_ALL_F32 = 0,
@@ -821,7 +835,7 @@ extern "C" {
LLAMA_API float llama_token_get_score(const struct llama_model * model, llama_token token);
- LLAMA_API enum llama_token_type llama_token_get_type(const struct llama_model * model, llama_token token);
+ LLAMA_API enum llama_token_attr llama_token_get_attr(const struct llama_model * model, llama_token token);
// Check if the token is supposed to end generation (end-of-generation, eg. EOS, EOT, etc.)
LLAMA_API bool llama_token_is_eog(const struct llama_model * model, llama_token token);