diff options
author | Bach Le <bach@bullno1.com> | 2023-07-15 02:55:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-14 21:55:24 +0300 |
commit | 7513b7b0a1c11faa00ad5a34d22681e5f07d32e4 (patch) | |
tree | a2de08957355d59b1eb2ee61b6e33458d5737c64 /llama.h | |
parent | de8342423d9600cf6e15455c1a27bae441262b45 (diff) |
llama : add functions that work directly on model (#2197)
* Remove vocab reference from context
* Add functions that works directly with model
Diffstat (limited to 'llama.h')
-rw-r--r-- | llama.h | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -270,10 +270,21 @@ extern "C" { int n_max_tokens, bool add_bos); + LLAMA_API int llama_tokenize_with_model( + const struct llama_model * model, + const char * text, + llama_token * tokens, + int n_max_tokens, + bool add_bos); + LLAMA_API int llama_n_vocab(const struct llama_context * ctx); LLAMA_API int llama_n_ctx (const struct llama_context * ctx); LLAMA_API int llama_n_embd (const struct llama_context * ctx); + LLAMA_API int llama_n_vocab_from_model(const struct llama_model * model); + LLAMA_API int llama_n_ctx_from_model (const struct llama_model * model); + LLAMA_API int llama_n_embd_from_model (const struct llama_model * model); + // Get the vocabulary as output parameters. // Returns number of results. LLAMA_API int llama_get_vocab( @@ -282,6 +293,12 @@ extern "C" { float * scores, int capacity); + LLAMA_API int llama_get_vocab_from_model( + const struct llama_model * model, + const char * * strings, + float * scores, + int capacity); + // Token logits obtained from the last call to llama_eval() // The logits for the last token are stored in the last row // Can be mutated in order to change the probabilities of the next token @@ -294,7 +311,13 @@ extern "C" { LLAMA_API float * llama_get_embeddings(struct llama_context * ctx); // Token Id -> String. Uses the vocabulary in the provided context - LLAMA_API const char * llama_token_to_str(const struct llama_context * ctx, llama_token token); + LLAMA_API const char * llama_token_to_str( + const struct llama_context * ctx, + llama_token token); + + LLAMA_API const char * llama_token_to_str_with_model( + const struct llama_model * model, + llama_token token); // Special tokens LLAMA_API llama_token llama_token_bos(); // beginning-of-sentence |