-
Notifications
You must be signed in to change notification settings - Fork 11.6k
add save_load_state example #1150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -0,0 +1,133 @@ | |||
#include <vector> | |||
#include <iostream> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <iostream> | |
#include <cstdio> |
Is better
auto n_prompt_tokens = llama_tokenize(ctx, params.prompt.c_str(), tokens.data(), tokens.size(), true); | ||
|
||
if (n_prompt_tokens < 1) { | ||
cout << "Failed to tokenize prompt" << endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cout << "Failed to tokenize prompt" << endl; | |
fprintf(stderr, "%s : failed to tokenize prompt\n", __func__); |
etc.
I changed cout to printf / fprintf in this last commit. |
Sorry, one more thing - all filenames use dashes
|
Sure, I changed it :) |
This is the save_load_state example script from #730 (comment)
It will load model params read from command line.
Then evaluate and print the initial prompt and save the state.
n_predict tokens are generate and printed.
Model is freed and load in new context.
Load the state and generate and print n_predict.
The n_predict generated tokens should be the same.