MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / output_data

Method output_data

examples/debug/debug.cpp:55–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53 std::vector<llama_token> tokens;
54
55 output_data(llama_context * ctx, const llama_model * model, const common_params & params) {
56 const llama_vocab * vocab = llama_model_get_vocab(model);
57 const bool add_bos = llama_vocab_get_add_bos(vocab);
58
59 tokens = common_tokenize(ctx, params.prompt, add_bos, params.parse_special);
60 prompt = params.prompt;
61
62 if (params.embedding) {
63 const int n_embd = llama_model_n_embd_out(model);
64 const bool pooling = has_pooling(ctx);
65 const int n_embd_count = pooling ? 1 : tokens.size();
66 const int n_floats = n_embd * n_embd_count;
67
68 float * embd_raw = pooling ? llama_get_embeddings_seq(ctx, 0) : llama_get_embeddings(ctx);
69 if (embd_raw == nullptr) {
70 throw std::runtime_error("failed to get embeddings from the model");
71 }
72
73 LOG_DBG("pooling_enabled: %s\n", pooling ? "true" : "false");
74 LOG_DBG("n_embd: %d\n", n_embd);
75 LOG_DBG("n_floats: %d\n", n_floats);
76 LOG_DBG("n_embd_count: %d\n", n_embd_count);
77
78 data_ptr = embd_raw;
79 data_size = n_floats;
80 type_suffix = "-embeddings";
81
82 if (params.embd_normalize >= 0) {
83 embd_norm.resize(n_floats);
84 for (int i = 0; i < n_embd_count; i++) {
85 common_embd_normalize(embd_raw+i*n_embd, embd_norm.data()+i*n_embd, n_embd, params.embd_normalize);
86 }
87 data_ptr = embd_norm.data();
88 }
89 } else {
90 const float * logits = llama_get_logits_ith(ctx, tokens.size() - 1);
91 const int n_logits = llama_vocab_n_tokens(vocab);
92
93 data_ptr = const_cast<float*>(logits);
94 data_size = n_logits;
95 type_suffix = "";
96 }
97 }
98};
99
100static void save_output_data(const output_data & output, const std::string & model_name, const std::string & output_dir) {

Callers

nothing calls this directly

Calls 13

llama_model_get_vocabFunction · 0.85
llama_vocab_get_add_bosFunction · 0.85
common_tokenizeFunction · 0.85
llama_model_n_embd_outFunction · 0.85
has_poolingFunction · 0.85
llama_get_embeddings_seqFunction · 0.85
llama_get_embeddingsFunction · 0.85
common_embd_normalizeFunction · 0.85
llama_get_logits_ithFunction · 0.85
llama_vocab_n_tokensFunction · 0.85
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected