From c24778df01aa3817d8c63602331f3e6291b3b32a Mon Sep 17 00:00:00 2001 From: Yann Follet Date: Tue, 10 Dec 2024 01:53:49 +0000 Subject: [PATCH] add verbosity -1 to log token, so can output only tokens with -lv -1 --- common/arg.cpp | 2 +- common/log.h | 1 + examples/main/main.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/common/arg.cpp b/common/arg.cpp index 0db59f701..3be59bf20 100644 --- a/common/arg.cpp +++ b/common/arg.cpp @@ -1940,7 +1940,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex )); add_opt(common_arg( {"-lv", "--verbosity", "--log-verbosity"}, "N", - "Set the verbosity threshold. Messages with a higher verbosity will be ignored.", + "Set the verbosity threshold. Messages with a higher verbosity will be ignored. (-lv -1 for token only, no EOS nor EOG message)", [](common_params & params, int value) { params.verbosity = value; common_log_set_verbosity_thold(value); diff --git a/common/log.h b/common/log.h index 66605cc69..264b99a97 100644 --- a/common/log.h +++ b/common/log.h @@ -76,6 +76,7 @@ void common_log_set_timestamps(struct common_log * log, bool timestamps) } \ } while (0) +#define LOGTOKEN(...) LOG_TMPL(GGML_LOG_LEVEL_NONE, -1, __VA_ARGS__) #define LOG(...) LOG_TMPL(GGML_LOG_LEVEL_NONE, 0, __VA_ARGS__) #define LOGV(verbosity, ...) LOG_TMPL(GGML_LOG_LEVEL_NONE, verbosity, __VA_ARGS__) diff --git a/examples/main/main.cpp b/examples/main/main.cpp index d0c28f317..5431612cc 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -677,7 +677,7 @@ int main(int argc, char ** argv) { const std::string token_str = common_token_to_piece(ctx, id, params.special); // Console/Stream Output - LOG("%s", token_str.c_str()); + LOGTOKEN("%s", token_str.c_str()); // Record Displayed Tokens To Log // Note: Generated tokens are created one by one hence this check