Change llama_tokenize return meaning

This commit is contained in:
Georgi Gerganov 2023-03-22 07:27:26 +02:00
parent a9f900b645
commit c3d13eaa4d
No known key found for this signature in database
GPG key ID: 449E073F9DC10735
3 changed files with 3 additions and 2 deletions

View file

@ -1455,7 +1455,7 @@ int llama_tokenize(
if (n_max_tokens < (int) res.size()) { if (n_max_tokens < (int) res.size()) {
fprintf(stderr, "%s: too many tokens\n", __func__); fprintf(stderr, "%s: too many tokens\n", __func__);
return 1; return -((int) res.size());
} }
for (size_t i = 0; i < res.size(); i++) { for (size_t i = 0; i < res.size(); i++) {

View file

@ -89,7 +89,7 @@ extern "C" {
// Convert the provided text into tokens. // Convert the provided text into tokens.
// The tokens pointer must be large enough to hold the resulting 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 the number of tokens on success, no more than n_max_tokens
// Returns -1 on failure // Returns a negative number on failure - the number of tokens that would have been returned
// TODO: not sure if correct // TODO: not sure if correct
LLAMA_API int llama_tokenize( LLAMA_API int llama_tokenize(
struct llama_context * ctx, struct llama_context * ctx,

View file

@ -155,6 +155,7 @@ void sigint_handler(int signo) {
#endif #endif
int main(int argc, char ** argv) { int main(int argc, char ** argv) {
// has to be called once at the start of the program to init ggml stuff
ggml_time_init(); ggml_time_init();
gpt_params params; gpt_params params;