From b97df76c543855e23779e56c200ed3ab4b2b125e Mon Sep 17 00:00:00 2001 From: strikingLoo Date: Sat, 18 Mar 2023 14:10:16 -0700 Subject: [PATCH] working but ugly --- main.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index ca0fca8b3..2adeb5045 100644 --- a/main.cpp +++ b/main.cpp @@ -721,6 +721,25 @@ bool llama_eval( inpL); } + // run the computation + ggml_build_forward_expand(&gf, inpL); + ggml_graph_compute (ctx0, &gf); + + // capture input sentence embedding + { + std::vector embedding_representation; + embedding_representation.resize(n_embd); + memcpy(embedding_representation.data(), (float *) ggml_get_data(inpL) + (n_embd * (N - 2)), sizeof(float) * n_embd); + fprintf(stdout, "\n[\n"); + for (int j = 0; j < embedding_representation.size()-1 ; j++){ + fprintf(stdout, "%f, ", embedding_representation[j]); + } + fprintf(stdout, "%f", embedding_representation[embedding_representation.size()-1]); + fprintf(stdout, "\n]\n"); + + } + + // lm_head { inpL = ggml_mul_mat(ctx0, model.output, inpL); @@ -729,9 +748,7 @@ bool llama_eval( // logits -> probs //inpL = ggml_soft_max(ctx0, inpL); - // run the computation - ggml_build_forward_expand(&gf, inpL); - ggml_graph_compute (ctx0, &gf); + //if (n_past%100 == 0) { // ggml_graph_print (&gf);