From 9308bcbfb0b33456c892d1a5631621453d2b189c Mon Sep 17 00:00:00 2001 From: Aleksandras Kostarevas Date: Thu, 11 Apr 2024 00:43:56 -0500 Subject: [PATCH] Reduce logging --- ...to_inputmethod_latin_xlm_LanguageModel.cpp | 35 +++++++++++-------- native/jni/src/defines.h | 3 +- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/native/jni/org_futo_inputmethod_latin_xlm_LanguageModel.cpp b/native/jni/org_futo_inputmethod_latin_xlm_LanguageModel.cpp index eafe19b42..2706f0267 100644 --- a/native/jni/org_futo_inputmethod_latin_xlm_LanguageModel.cpp +++ b/native/jni/org_futo_inputmethod_latin_xlm_LanguageModel.cpp @@ -13,11 +13,16 @@ #include "jni_utils.h" #define EPS 0.0001 + +#if false #define TIME_START(name) const int64_t start_##name = ggml_time_us(); #define TIME_END(name) const int64_t end_##name = ggml_time_us(); \ const int64_t time_taken_##name = (end_##name - start_##name) / 1000L; \ AKLOGI("%s: Time taken by %s: %d ms\n", __func__, #name, (int)time_taken_##name); - +#else +#define TIME_START(name) +#define TIME_END(name) +#endif #define RETURNVAL_AUTOCORRECT "autocorrect" #define RETURNVAL_UNCERTAIN "uncertain" @@ -349,7 +354,7 @@ struct LanguageModelState { return {}; } } else { - AKLOGI("No need to recompute prompt, proceeding to mixes"); + //AKLOGI("No need to recompute prompt, proceeding to mixes"); } transformer_context_apply(model->transformerContext, prompt_ff); @@ -362,7 +367,7 @@ struct LanguageModelState { std::vector embeds; bool useEncoder = !llamaAdapter->encoder_weight.empty(); - AKLOGI("DecodePromptAndMixes: useEncoder=%d", useEncoder); + //AKLOGI("DecodePromptAndMixes: useEncoder=%d", useEncoder); for(auto &mix : mixes) { @@ -474,13 +479,13 @@ struct LanguageModelState { ASSERT(head == prompt_ff.first.size() - 1); } - AKLOGI("-- Decode"); - AKLOGI("First we processed the prompt (%d):", prompt_ff.first.size()); - for(auto t : prompt) { - AKLOGI(" - [%s]", model->getToken(t)); - } - AKLOGI("Then %d embeds (cached %d)", embeds.size(), n_past); - AKLOGI("The final size is %d and head is %d", size, head); + //AKLOGI("-- Decode"); + //AKLOGI("First we processed the prompt (%d):", prompt_ff.first.size()); + //for(auto t : prompt) { + // AKLOGI(" - [%s]", model->getToken(t)); + //} + //AKLOGI("Then %d embeds (cached %d)", embeds.size(), n_past); + //AKLOGI("The final size is %d and head is %d", size, head); TIME_START(FinishRm) @@ -509,7 +514,7 @@ struct LanguageModelState { auto priorTxt = model->decode(prior); auto nextTxt = model->decode({next}); auto bannedTxt = model->decode(banned_sequence.sequence); - AKLOGI("Tokens [%s] + [%s] matches banned wildcard [%s]", priorTxt.c_str(), nextTxt.c_str(), bannedTxt.c_str()); + //AKLOGI("Tokens [%s] + [%s] matches banned wildcard [%s]", priorTxt.c_str(), nextTxt.c_str(), bannedTxt.c_str()); return true; } }else if((banned_sequence.sequence.size() == prior.size() + 1) && (banned_sequence.hash == new_hash)) { @@ -526,7 +531,7 @@ struct LanguageModelState { auto priorTxt = model->decode(prior); auto nextTxt = model->decode({next}); auto bannedTxt = model->decode(banned_sequence.sequence); - AKLOGI("Tokens [%s] + [%s] matches banned [%s]", priorTxt.c_str(), nextTxt.c_str(), bannedTxt.c_str()); + //AKLOGI("Tokens [%s] + [%s] matches banned [%s]", priorTxt.c_str(), nextTxt.c_str(), bannedTxt.c_str()); return true; } } @@ -547,7 +552,7 @@ struct LanguageModelState { bool allow_correction_token = decodeResult.logits_head == 0; float *logits = llama_get_logits_ith(ctx, decodeResult.logits_head); - AKLOGI("Value of [the ] before transform: %f", logits[561]); + //AKLOGI("Value of [the ] before transform: %f", logits[561]); bool is_bugged = logits[561] == 0.0f; @@ -565,7 +570,7 @@ struct LanguageModelState { return { }; } - AKLOGI("Value of [the ] after transform: %f", logits[561]); + //AKLOGI("Value of [the ] after transform: %f", logits[561]); std::vector> index_value; index_value.clear(); @@ -993,7 +998,7 @@ namespace latinime { }else if(c >= 'A' && c <= 'Z') { results.mixes[j].token = (state->specialTokens.LETTERS_TO_IDS[c - 'A']); } else { - AKLOGI("ignoring character in partial word [%c]", c); + //AKLOGI("ignoring character in partial word [%c]", c); results.mixes[j].weight = 0.0f; } } diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h index d3e9a0ba3..a63c644dd 100644 --- a/native/jni/src/defines.h +++ b/native/jni/src/defines.h @@ -175,7 +175,8 @@ static inline void showStackTrace() { #endif // defined(FLAG_DO_PROFILE) || defined(FLAG_DBG) #ifdef FLAG_DBG -#define DEBUG_DICT true +//#define DEBUG_DICT true +#define DEBUG_DICT false #define DEBUG_DICT_FULL false #define DEBUG_EDIT_DISTANCE false #define DEBUG_NODE DEBUG_DICT_FULL