Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Change llama_tokenize return meaning
  • Loading branch information
ggerganov committed Mar 22, 2023
commit c3d13eaa4d7a34b93b3726f79057d77dd7253776
2 changes: 1 addition & 1 deletion llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ int llama_tokenize(

if (n_max_tokens < (int) res.size()) {
fprintf(stderr, "%s: too many tokens\n", __func__);
return 1;
return -((int) res.size());
}

for (size_t i = 0; i < res.size(); i++) {
Expand Down
2 changes: 1 addition & 1 deletion llama.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ extern "C" {
// 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 -1 on failure
// Returns a negative number on failure - the number of tokens that would have been returned
// TODO: not sure if correct
LLAMA_API int llama_tokenize(
struct llama_context * ctx,
Expand Down
1 change: 1 addition & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ void sigint_handler(int signo) {
#endif

int main(int argc, char ** argv) {
// has to be called once at the start of the program to init ggml stuff
ggml_time_init();

gpt_params params;
Expand Down