8000 We could use std::unordered_map over std::map by Fabio3rs · Pull Request #305 · ggml-org/llama.cpp · GitHub
[go: up one dir, main page]

Skip to content

We could use std::unordered_map over std::map #305

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 7 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
10000 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
Next Next commit
renamed token to tok
  • Loading branch information
Fabio3rs committed Mar 21, 2023
commit a19aa63ba29cc1c2b8370ad1d3993939afda13e8
8 changes: 4 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ bool llama_model_load(const std::string & fname, llama_model & model, gpt_vocab
vocab.token_to_id[word] = i;

auto &tok_score = vocab.id_to_token[i];
tok_score.token = word;
tok_score.tok = word;
tok_score.score = score;

//if (i < 30000) {
Expand Down Expand Up @@ -896,7 +896,7 @@ int main(int argc, char ** argv) {
fprintf(stderr, "%s: prompt: '%s'\n", __func__, params.prompt.c_str());
fprintf(stderr, "%s: number of tokens in prompt = %zu\n", __func__, embd_inp.size());
for (int i = 0; i < (int) embd_inp.size(); i++) {
fprintf(stderr, "%6d -> '%s'\n", embd_inp[i], vocab.id_to_token.at(embd_inp[i]).token.c_str());
fprintf(stderr, "%6d -> '%s'\n", embd_inp[i], vocab.id_to_token.at(embd_inp[i]).tok.c_str());
}
fprintf(stderr, "\n");
if (params.interactive) {
Expand All @@ -918,7 +918,7 @@ int main(int argc, char ** argv) {
fprintf(stderr, "%s: reverse prompt: '%s'\n", __func__, params.antiprompt.at(apindex).c_str());
fprintf(stderr, "%s: number of tokens in reverse prompt = %zu\n", __func__, antiprompt_inp.size());
for (int i = 0; i < (int) antiprompt_inp.size(); i++) {
fprintf(stderr, "%6d -> '%s'\n", antiprompt_inp[i], vocab.id_to_token.at(antiprompt_inp[i]).token.c_str());
fprintf(stderr, "%6d -> '%s'\n", antiprompt_inp[i], vocab.id_to_token.at(antiprompt_inp[i]).tok.c_str());
}
fprintf(stderr, "\n");
}
Expand Down Expand Up @@ -1024,7 +1024,7 @@ int main(int argc, char ** argv) {
// display text
if (!input_noecho) {
for (auto id : embd) {
printf("%s", vocab.id_to_token[id].token.c_str());
printf("%s", vocab.id_to_token[id].tok.c_str());
}
fflush(stdout);
}
Expand Down
2 changes: 1 addition & 1 deletion quantize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ bool llama_model_quantize(const std::string & fname_inp, const std::string & fna
vocab.token_to_id[word] = i;

auto &tok_score = vocab.id_to_token[i];
tok_score.token = word;
tok_score.tok = word;
tok_score.score = score;
}
}
Expand Down
2 changes: 1 addition & 1 deletion utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ bool gpt_vocab_init(const std::string & fname, gpt_vocab & vocab) {

vocab.id_to_token.resize(vocab.token_to_id.size());
for (const auto & kv : vocab.token_to_id) {
vocab.id_to_token[kv.second].token = kv.first;
vocab.id_to_token[kv.second].tok = kv.first;
}

printf("%s: vocab size = %d\n", __func__, (int) vocab.token_to_id.size());
Expand Down
2 changes: 1 addition & 1 deletion utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct gpt_vocab {
using token = std::string;

struct token_score {
token token;
token tok;
float score;
};

Expand Down
0