8000 fix perplexity after c-api refactor by Green-Sky · Pull Request #390 · ggml-org/llama.cpp · GitHub
[go: up one dir, main page]

Skip to content

fix perplexity after c-api refactor #390

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

Merged
merged 2 commits into from
Mar 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
8000 Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
preallocate a buffer of fitting size for tokenization (utils.cpp)
  • Loading branch information
Green-Sky committed Mar 22, 2023
commit 7b1b575fe8de8ece4122f7bd7a8242e63841ec70
4 changes: 3 additions & 1 deletion utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ std::string gpt_random_prompt(std::mt19937 & rng) {

// TODO: not great allocating this every time
std::vector<llama_token> llama_tokenize(struct llama_context * ctx, const std::string & text, bool add_bos) {
std::vector<llama_token> res(8096);
// initialize to prompt numer of chars, since n_tokens <= n_prompt_chars
std::vector<llama_token> res(text.size() + (int)add_bos);
int n = llama_tokenize(ctx, text.c_str(), res.data(), res.size(), add_bos);
assert(n >= 0);
res.resize(n);

return res;
Expand Down
0