diff --git a/gemma/gemma.cc b/gemma/gemma.cc index f7d3daa..bef03c4 100644 --- a/gemma/gemma.cc +++ b/gemma/gemma.cc @@ -1136,8 +1136,8 @@ template void LogTopK(GemmaImpl& gemma, float* logits, float* dist, size_t len, size_t k) { std::vector> sorted(len); - for (int i = 0; i < len; ++i) { - sorted[i] = std::make_pair(dist[i], i); + for (size_t i = 0; i < len; ++i) { + sorted[i] = std::make_pair(dist[i], static_cast(i)); } std::sort(sorted.begin(), sorted.end(), [](const std::pair& a, const std::pair& b) { @@ -1146,9 +1146,10 @@ void LogTopK(GemmaImpl& gemma, float* logits, float* dist, size_t len, } return a.second < b.second; }); - for (int i = 0; i < k; ++i) { - printf(" [#%-2d token %6d = %-12s %.2e %f]\n", i + 1, sorted[i].second, - TOKEN(sorted[i].second), sorted[i].first, logits[sorted[i].second]); + for (size_t i = 0; i < k; ++i) { + printf(" [#%-2d token %6d = %-12s %.2e %f]\n", static_cast(i + 1), + sorted[i].second, TOKEN(sorted[i].second), sorted[i].first, + logits[sorted[i].second]); } } diff --git a/gemma/run.cc b/gemma/run.cc index 633e37c..aa5f9bb 100644 --- a/gemma/run.cc +++ b/gemma/run.cc @@ -98,7 +98,7 @@ void ReplGemma(gcpp::Gemma& model, ModelTraining training, int verbosity, const gcpp::AcceptFunc& accept_token, std::string& eot_line) { PROFILER_ZONE("Gen.misc"); - int abs_pos = 0; // absolute token index over all turns + size_t abs_pos = 0; // absolute token index over all turns int current_pos = 0; // token index within the current turn int prompt_size{}; @@ -181,7 +181,7 @@ void ReplGemma(gcpp::Gemma& model, ModelTraining training, // For instruction-tuned models: add control tokens. prompt_string = "user\n" + prompt_string + "\nmodel\n"; - if (abs_pos > 0) { + if (abs_pos != 0) { // Prepend "" token if this is a multi-turn dialogue // continuation. prompt_string = "\n" + prompt_string;