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
This commit is contained in:
parent
6d1616944d
commit
3b38d48609
4 changed files with 155 additions and 62 deletions
18
llama.h
18
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue