Skip to content

Commit 88999fb

Browse files
results per binary
1 parent d2d5254 commit 88999fb

File tree

5 files changed

+32
-31
lines changed

5 files changed

+32
-31
lines changed

examples/main/main.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,8 +836,20 @@ int main(int argc, char ** argv) {
836836
FILE * logfile = fopen((params.logdir + timestamp + ".yml").c_str(), "w");
837837
fprintf(logfile, "binary: main\n");
838838
dump_non_result_info_yaml(logfile, params, timestamp, input_tokens);
839-
llama_dump_result_info_yaml(
840-
logfile, ctx, output_ss.str().c_str(), output_tokens.data(), output_tokens.size(), NULL, 0);
839+
840+
fprintf(logfile, "\n");
841+
fprintf(logfile, "######################\n");
842+
fprintf(logfile, "# Generation Results #\n");
843+
fprintf(logfile, "######################\n");
844+
fprintf(logfile, "\n");
845+
846+
// fprintf(logfile, "ftype: %u\n", ctx->model.hparams.ftype);
847+
// fprintf(logfile, "ftype_str: %s\n", llama_ftype_name(ctx->model.hparams.ftype));
848+
// fprintf(logfile, "model_type: %s\n", llama_model_type_name(ctx->model.type));
849+
dump_string_yaml_multiline(logfile, "output", output_ss.str().c_str(), false);
850+
dump_vector_int_yaml(logfile, "output_tokens", output_tokens);
851+
852+
llama_dump_timing_info_yaml(logfile, ctx);
841853
fclose(logfile);
842854
} else {
843855
fprintf(stderr, "%s: warning: failed to create logdir %s, cannot write logfile\n",

examples/perplexity/perplexity.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,19 @@ int main(int argc, char ** argv) {
369369
FILE * logfile = fopen((params.logdir + timestamp + ".yml").c_str(), "w");
370370
fprintf(logfile, "binary: perplexity\n");
371371
dump_non_result_info_yaml(logfile, params, timestamp, tokens);
372-
llama_dump_result_info_yaml(logfile, ctx, NULL, NULL, 0, probs.data(), probs.size());
372+
373+
fprintf(logfile, "\n");
374+
fprintf(logfile, "######################\n");
375+
fprintf(logfile, "# Perplexity Results #\n");
376+
fprintf(logfile, "######################\n");
377+
fprintf(logfile, "\n");
378+
379+
// fprintf(logfile, "ftype: %u\n", ctx->model.hparams.ftype);
380+
// fprintf(logfile, "ftype_str: %s\n", llama_ftype_name(ctx->model.hparams.ftype));
381+
// fprintf(logfile, "model_type: %s\n", llama_model_type_name(ctx->model.type));
382+
dump_vector_float_yaml(logfile, "probs", probs);
383+
384+
llama_dump_timing_info_yaml(logfile, ctx);
373385
fclose(logfile);
374386
} else {
375387
fprintf(stderr, "%s: warning: failed to create logdir %s, cannot write logfile\n",

llama-util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,9 @@ static bool create_directory_with_parents(const std::string & path) {
591591
static void dump_vector_float_yaml(FILE * stream, const char * prop_name, const std::vector<float> & data) {
592592
fprintf(stream, "%s: [", prop_name);
593593
for (size_t i = 0; i < data.size() - 1; ++i) {
594-
fprintf(stream, "%f, ", data[i]);
594+
fprintf(stream, "%e, ", data[i]);
595595
}
596-
fprintf(stream, "%f]\n", data.back());
596+
fprintf(stream, "%e]\n", data.back());
597597
}
598598

599599
static void dump_vector_int_yaml(FILE * stream, const char * prop_name, const std::vector<int> & data) {

llama.cpp

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4399,19 +4399,14 @@ const char * llama_print_system_info(void) {
43994399
return s.c_str();
44004400
}
44014401

4402-
void llama_dump_result_info_yaml(
4403-
FILE * stream, const llama_context * ctx, const char * output_str, const int * output_tokens,
4404-
const int n_output_tokens, const float * probs, const int n_probs) {
4402+
void llama_dump_timing_info_yaml(FILE * stream, const llama_context * ctx) {
44054403

44064404
fprintf(stream, "\n");
44074405
fprintf(stream, "###########\n");
4408-
fprintf(stream, "# Results #\n");
4406+
fprintf(stream, "# Timings #\n");
44094407
fprintf(stream, "###########\n");
44104408
fprintf(stream, "\n");
44114409

4412-
fprintf(stream, "ftype: %u\n", ctx->model.hparams.ftype);
4413-
fprintf(stream, "ftype_str: %s\n", llama_ftype_name(ctx->model.hparams.ftype));
4414-
fprintf(stream, "model_type: %s\n", llama_model_type_name(ctx->model.type));
44154410
fprintf(stream, "mst_eval: %.2f # ms / token during generation\n",
44164411
1.0e-3 * ctx->t_eval_us / ctx->n_eval);
44174412
fprintf(stream, "mst_p_eval: %.2f # ms / token during prompt processing\n",
@@ -4422,22 +4417,6 @@ void llama_dump_result_info_yaml(
44224417
fprintf(stream, "n_vocab: %d # output size of the final layer, 32001 for some models\n", ctx->model.hparams.n_vocab);
44234418
fprintf(stream, "n_p_eval: %d # number of tokens processed in batches at the beginning\n", ctx->n_p_eval);
44244419
fprintf(stream, "n_sample: %d # number of sampled tokens\n", ctx->n_sample);
4425-
dump_string_yaml_multiline(stream, "output", output_str, false);
4426-
4427-
if (output_tokens == NULL) {
4428-
fprintf(stream, "output_tokens:\n");
4429-
} else {
4430-
const std::vector<int> output_token_vector(output_tokens, output_tokens + n_output_tokens);
4431-
dump_vector_int_yaml(stream, "output_tokens", output_token_vector);
4432-
}
4433-
4434-
if (probs == NULL) {
4435-
fprintf(stream, "probs:\n");
4436-
} else {
4437-
const std::vector<float> prob_vector(probs, probs + n_probs);
4438-
dump_vector_float_yaml(stream, "probs", prob_vector);
4439-
}
4440-
44414420
fprintf(stream, "t_eval_us: %ld # total microseconds spent generating tokens\n", ctx->t_eval_us);
44424421
fprintf(stream, "t_load_us: %ld # total microseconds spent loading the model\n", ctx->t_load_us);
44434422
fprintf(stream, "t_p_eval_us: %ld # total microseconds spent prompt processing\n", ctx->t_p_eval_us);

llama.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,7 @@ extern "C" {
471471
// Print system information
472472
LLAMA_API const char * llama_print_system_info(void);
473473

474-
LLAMA_API void llama_dump_result_info_yaml(
475-
FILE * stream, const llama_context * ctx, const char * output_str, const int * output_tokens,
476-
int n_output_tokens, const float * probs, int n_probs);
474+
LLAMA_API void llama_dump_timing_info_yaml(FILE * stream, const llama_context * ctx);
477475

478476
#ifdef __cplusplus
479477
}

0 commit comments

Comments
 (0)