2024-09-09 23:36:09 +02:00
|
|
|
#include "arg.h"
|
2023-03-25 19:26:40 +01:00
|
|
|
#include "common.h"
|
2024-09-15 19:46:12 +02:00
|
|
|
#include "log.h"
|
2023-03-25 19:26:40 +01:00
|
|
|
#include "llama.h"
|
|
|
|
|
2023-04-16 12:13:00 +02:00
|
|
|
#include <ctime>
|
|
|
|
|
2023-06-16 20:23:53 +02:00
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#pragma warning(disable: 4244 4267) // possible loss of data
|
|
|
|
#endif
|
|
|
|
|
2024-06-24 07:30:24 +02:00
|
|
|
static std::vector<std::string> split_lines(const std::string & s, const std::string & separator = "\n") {
|
2024-02-13 13:06:58 +01:00
|
|
|
std::vector<std::string> lines;
|
2024-06-24 07:30:24 +02:00
|
|
|
size_t start = 0;
|
|
|
|
size_t end = s.find(separator);
|
|
|
|
|
|
|
|
while (end != std::string::npos) {
|
|
|
|
lines.push_back(s.substr(start, end - start));
|
|
|
|
start = end + separator.length();
|
|
|
|
end = s.find(separator, start);
|
2024-02-13 13:06:58 +01:00
|
|
|
}
|
2024-06-24 07:30:24 +02:00
|
|
|
|
|
|
|
lines.push_back(s.substr(start)); // Add the last part
|
|
|
|
|
2024-02-13 13:06:58 +01:00
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
|
2024-06-21 07:38:22 +02:00
|
|
|
static void batch_add_seq(llama_batch & batch, const std::vector<int32_t> & tokens, llama_seq_id seq_id) {
|
|
|
|
size_t n_tokens = tokens.size();
|
|
|
|
for (size_t i = 0; i < n_tokens; i++) {
|
2024-10-10 22:57:42 +02:00
|
|
|
common_batch_add(batch, tokens[i], i, { seq_id }, true);
|
2024-02-13 13:06:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-24 07:30:24 +02:00
|
|
|
static void batch_decode(llama_context * ctx, llama_batch & batch, float * output, int n_seq, int n_embd, int embd_norm) {
|
2024-08-10 11:43:26 +02:00
|
|
|
const enum llama_pooling_type pooling_type = llama_pooling_type(ctx);
|
|
|
|
const struct llama_model * model = llama_get_model(ctx);
|
|
|
|
|
2024-02-13 13:06:58 +01:00
|
|
|
// clear previous kv_cache values (irrelevant for embeddings)
|
|
|
|
llama_kv_cache_clear(ctx);
|
|
|
|
|
|
|
|
// run model
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG_INF("%s: n_tokens = %d, n_seq = %d\n", __func__, batch.n_tokens, n_seq);
|
2024-08-10 11:43:26 +02:00
|
|
|
if (llama_model_has_encoder(model) && !llama_model_has_decoder(model)) {
|
|
|
|
// encoder-only model
|
|
|
|
if (llama_encode(ctx, batch) < 0) {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG_ERR("%s : failed to encode\n", __func__);
|
2024-08-10 11:43:26 +02:00
|
|
|
}
|
|
|
|
} else if (!llama_model_has_encoder(model) && llama_model_has_decoder(model)) {
|
|
|
|
// decoder-only model
|
|
|
|
if (llama_decode(ctx, batch) < 0) {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG_ERR("%s : failed to decode\n", __func__);
|
2024-08-10 11:43:26 +02:00
|
|
|
}
|
2024-02-13 13:06:58 +01:00
|
|
|
}
|
|
|
|
|
2024-03-04 21:31:20 +01:00
|
|
|
for (int i = 0; i < batch.n_tokens; i++) {
|
|
|
|
if (!batch.logits[i]) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2024-08-10 11:43:26 +02:00
|
|
|
const float * embd = nullptr;
|
|
|
|
int embd_pos = 0;
|
|
|
|
|
|
|
|
if (pooling_type == LLAMA_POOLING_TYPE_NONE) {
|
|
|
|
// try to get token embeddings
|
|
|
|
embd = llama_get_embeddings_ith(ctx, i);
|
|
|
|
embd_pos = i;
|
|
|
|
GGML_ASSERT(embd != NULL && "failed to get token embeddings");
|
|
|
|
} else {
|
|
|
|
// try to get sequence embeddings - supported only when pooling_type is not NONE
|
|
|
|
embd = llama_get_embeddings_seq(ctx, batch.seq_id[i][0]);
|
|
|
|
embd_pos = batch.seq_id[i][0];
|
|
|
|
GGML_ASSERT(embd != NULL && "failed to get sequence embeddings");
|
|
|
|
}
|
2024-03-04 21:31:20 +01:00
|
|
|
|
2024-08-10 11:43:26 +02:00
|
|
|
float * out = output + embd_pos * n_embd;
|
2024-10-10 22:57:42 +02:00
|
|
|
common_embd_normalize(embd, out, n_embd, embd_norm);
|
2024-02-13 13:06:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-25 19:26:40 +01:00
|
|
|
int main(int argc, char ** argv) {
|
2024-10-10 22:57:42 +02:00
|
|
|
common_params params;
|
2023-03-25 19:26:40 +01:00
|
|
|
|
2024-10-10 22:57:42 +02:00
|
|
|
if (!common_params_parse(argc, argv, params, LLAMA_EXAMPLE_EMBEDDING)) {
|
2023-03-25 19:26:40 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2024-10-10 22:57:42 +02:00
|
|
|
common_init();
|
2024-09-15 19:46:12 +02:00
|
|
|
|
2023-03-25 19:26:40 +01:00
|
|
|
params.embedding = true;
|
2024-03-26 10:11:46 +01:00
|
|
|
// For non-causal models, batch size must be equal to ubatch size
|
|
|
|
params.n_ubatch = params.n_batch;
|
2023-03-25 19:26:40 +01:00
|
|
|
|
2024-02-16 10:31:07 +01:00
|
|
|
llama_backend_init();
|
|
|
|
llama_numa_init(params.numa);
|
2023-05-20 10:06:11 +02:00
|
|
|
|
2023-03-25 19:26:40 +01:00
|
|
|
// load the model
|
2024-10-10 22:57:42 +02:00
|
|
|
common_init_result llama_init = common_init_from_params(params);
|
2024-08-05 18:14:10 +02:00
|
|
|
|
|
|
|
llama_model * model = llama_init.model;
|
|
|
|
llama_context * ctx = llama_init.context;
|
2023-06-24 10:47:58 +02:00
|
|
|
if (model == NULL) {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG_ERR("%s: unable to load model\n", __func__);
|
2023-05-02 22:39:51 +02:00
|
|
|
return 1;
|
2023-03-25 19:26:40 +01:00
|
|
|
}
|
|
|
|
|
2023-09-28 21:42:38 +02:00
|
|
|
const int n_ctx_train = llama_n_ctx_train(model);
|
|
|
|
const int n_ctx = llama_n_ctx(ctx);
|
|
|
|
|
2024-06-21 07:38:22 +02:00
|
|
|
const enum llama_pooling_type pooling_type = llama_pooling_type(ctx);
|
2024-08-10 11:43:26 +02:00
|
|
|
|
|
|
|
if (llama_model_has_encoder(model) && llama_model_has_decoder(model)) {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG_ERR("%s: computing embeddings in encoder-decoder models is not supported\n", __func__);
|
2024-06-21 07:38:22 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2023-09-28 21:42:38 +02:00
|
|
|
if (n_ctx > n_ctx_train) {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG_WRN("%s: warning: model was trained on only %d context tokens (%d specified)\n",
|
2023-09-28 21:42:38 +02:00
|
|
|
__func__, n_ctx_train, n_ctx);
|
2023-09-08 17:43:35 +02:00
|
|
|
}
|
|
|
|
|
2023-03-25 19:26:40 +01:00
|
|
|
// print system information
|
|
|
|
{
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG_INF("\n");
|
2024-10-10 22:57:42 +02:00
|
|
|
LOG_INF("%s\n", common_params_get_system_info(params).c_str());
|
2023-03-25 19:26:40 +01:00
|
|
|
}
|
|
|
|
|
2024-02-13 13:06:58 +01:00
|
|
|
// split the prompt into lines
|
2024-06-24 07:30:24 +02:00
|
|
|
std::vector<std::string> prompts = split_lines(params.prompt, params.embd_sep);
|
2023-03-25 19:26:40 +01:00
|
|
|
|
2024-02-13 13:06:58 +01:00
|
|
|
// max batch size
|
|
|
|
const uint64_t n_batch = params.n_batch;
|
2024-03-13 18:54:21 +01:00
|
|
|
GGML_ASSERT(params.n_batch >= params.n_ctx);
|
2023-03-25 19:26:40 +01:00
|
|
|
|
2024-02-13 13:06:58 +01:00
|
|
|
// tokenize the prompts and trim
|
|
|
|
std::vector<std::vector<int32_t>> inputs;
|
|
|
|
for (const auto & prompt : prompts) {
|
2024-10-10 22:57:42 +02:00
|
|
|
auto inp = common_tokenize(ctx, prompt, true, true);
|
2024-02-13 13:06:58 +01:00
|
|
|
if (inp.size() > n_batch) {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG_ERR("%s: number of tokens in input line (%lld) exceeds batch size (%lld), increase batch size and re-run\n",
|
2024-03-26 10:11:46 +01:00
|
|
|
__func__, (long long int) inp.size(), (long long int) n_batch);
|
|
|
|
return 1;
|
2023-03-25 19:26:40 +01:00
|
|
|
}
|
2024-02-13 13:06:58 +01:00
|
|
|
inputs.push_back(inp);
|
2023-03-25 19:26:40 +01:00
|
|
|
}
|
|
|
|
|
2024-05-11 09:46:09 +02:00
|
|
|
// check if the last token is SEP
|
|
|
|
// it should be automatically added by the tokenizer when 'tokenizer.ggml.add_eos_token' is set to 'true'
|
2024-03-14 14:14:14 +01:00
|
|
|
for (auto & inp : inputs) {
|
2024-04-09 19:44:08 +02:00
|
|
|
if (inp.empty() || inp.back() != llama_token_sep(model)) {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG_WRN("%s: last token in the prompt is not SEP\n", __func__);
|
|
|
|
LOG_WRN("%s: 'tokenizer.ggml.add_eos_token' should be set to 'true' in the GGUF header\n", __func__);
|
2024-03-14 14:14:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-13 13:06:58 +01:00
|
|
|
// tokenization stats
|
|
|
|
if (params.verbose_prompt) {
|
|
|
|
for (int i = 0; i < (int) inputs.size(); i++) {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG_INF("%s: prompt %d: '%s'\n", __func__, i, prompts[i].c_str());
|
|
|
|
LOG_INF("%s: number of tokens in prompt = %zu\n", __func__, inputs[i].size());
|
2024-02-13 13:06:58 +01:00
|
|
|
for (int j = 0; j < (int) inputs[i].size(); j++) {
|
2024-10-10 22:57:42 +02:00
|
|
|
LOG("%6d -> '%s'\n", inputs[i][j], common_token_to_piece(ctx, inputs[i][j]).c_str());
|
2024-02-13 13:06:58 +01:00
|
|
|
}
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("\n\n");
|
2023-03-25 19:26:40 +01:00
|
|
|
}
|
2023-08-22 16:03:12 +02:00
|
|
|
}
|
2023-03-25 19:26:40 +01:00
|
|
|
|
2024-02-13 13:06:58 +01:00
|
|
|
// initialize batch
|
|
|
|
const int n_prompts = prompts.size();
|
2024-03-04 21:31:20 +01:00
|
|
|
struct llama_batch batch = llama_batch_init(n_batch, 0, 1);
|
2024-02-13 13:06:58 +01:00
|
|
|
|
2024-08-10 11:43:26 +02:00
|
|
|
// count number of embeddings
|
|
|
|
int n_embd_count = 0;
|
|
|
|
if (pooling_type == LLAMA_POOLING_TYPE_NONE) {
|
|
|
|
for (int k = 0; k < n_prompts; k++) {
|
|
|
|
n_embd_count += inputs[k].size();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
n_embd_count = n_prompts;
|
|
|
|
}
|
|
|
|
|
2024-02-13 13:06:58 +01:00
|
|
|
// allocate output
|
2023-09-28 21:42:38 +02:00
|
|
|
const int n_embd = llama_n_embd(model);
|
2024-08-10 11:43:26 +02:00
|
|
|
std::vector<float> embeddings(n_embd_count * n_embd, 0);
|
2024-02-13 13:06:58 +01:00
|
|
|
float * emb = embeddings.data();
|
|
|
|
|
|
|
|
// break into batches
|
2024-08-10 11:43:26 +02:00
|
|
|
int e = 0; // number of embeddings already stored
|
2024-02-13 13:06:58 +01:00
|
|
|
int s = 0; // number of prompts in current batch
|
|
|
|
for (int k = 0; k < n_prompts; k++) {
|
|
|
|
// clamp to n_batch tokens
|
|
|
|
auto & inp = inputs[k];
|
2024-03-04 21:31:20 +01:00
|
|
|
|
2024-02-13 13:06:58 +01:00
|
|
|
const uint64_t n_toks = inp.size();
|
|
|
|
|
|
|
|
// encode if at capacity
|
|
|
|
if (batch.n_tokens + n_toks > n_batch) {
|
2024-08-10 11:43:26 +02:00
|
|
|
float * out = emb + e * n_embd;
|
2024-06-24 07:30:24 +02:00
|
|
|
batch_decode(ctx, batch, out, s, n_embd, params.embd_normalize);
|
2024-08-10 11:43:26 +02:00
|
|
|
e += pooling_type == LLAMA_POOLING_TYPE_NONE ? batch.n_tokens : s;
|
2024-02-13 13:06:58 +01:00
|
|
|
s = 0;
|
2024-10-10 22:57:42 +02:00
|
|
|
common_batch_clear(batch);
|
2024-02-13 13:06:58 +01:00
|
|
|
}
|
2024-02-11 17:21:38 +01:00
|
|
|
|
2024-02-13 13:06:58 +01:00
|
|
|
// add to batch
|
|
|
|
batch_add_seq(batch, inp, s);
|
|
|
|
s += 1;
|
2024-02-11 17:21:38 +01:00
|
|
|
}
|
2023-03-25 19:26:40 +01:00
|
|
|
|
2024-02-13 13:06:58 +01:00
|
|
|
// final batch
|
2024-08-10 11:43:26 +02:00
|
|
|
float * out = emb + e * n_embd;
|
2024-06-24 07:30:24 +02:00
|
|
|
batch_decode(ctx, batch, out, s, n_embd, params.embd_normalize);
|
2024-03-14 09:12:29 +01:00
|
|
|
|
2024-06-24 07:30:24 +02:00
|
|
|
if (params.embd_out.empty()) {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("\n");
|
2024-08-10 11:43:26 +02:00
|
|
|
|
|
|
|
if (pooling_type == LLAMA_POOLING_TYPE_NONE) {
|
|
|
|
for (int j = 0; j < n_embd_count; j++) {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("embedding %d: ", j);
|
2024-08-10 11:43:26 +02:00
|
|
|
for (int i = 0; i < std::min(3, n_embd); i++) {
|
|
|
|
if (params.embd_normalize == 0) {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("%6.0f ", emb[j * n_embd + i]);
|
2024-08-10 11:43:26 +02:00
|
|
|
} else {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("%9.6f ", emb[j * n_embd + i]);
|
2024-08-10 11:43:26 +02:00
|
|
|
}
|
|
|
|
}
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG(" ... ");
|
2024-08-10 11:43:26 +02:00
|
|
|
for (int i = n_embd - 3; i < n_embd; i++) {
|
|
|
|
if (params.embd_normalize == 0) {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("%6.0f ", emb[j * n_embd + i]);
|
2024-08-10 11:43:26 +02:00
|
|
|
} else {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("%9.6f ", emb[j * n_embd + i]);
|
2024-08-10 11:43:26 +02:00
|
|
|
}
|
2024-06-24 07:30:24 +02:00
|
|
|
}
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("\n");
|
2024-06-24 07:30:24 +02:00
|
|
|
}
|
2024-09-28 16:42:03 +02:00
|
|
|
} else if (pooling_type == LLAMA_POOLING_TYPE_RANK) {
|
|
|
|
for (int j = 0; j < n_embd_count; j++) {
|
|
|
|
// NOTE: if you change this log - update the tests in ci/run.sh
|
|
|
|
LOG("rerank score %d: %8.3f\n", j, emb[j * n_embd]);
|
|
|
|
}
|
2024-08-10 11:43:26 +02:00
|
|
|
} else {
|
|
|
|
// print the first part of the embeddings or for a single prompt, the full embedding
|
|
|
|
for (int j = 0; j < n_prompts; j++) {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("embedding %d: ", j);
|
2024-08-10 11:43:26 +02:00
|
|
|
for (int i = 0; i < (n_prompts > 1 ? std::min(16, n_embd) : n_embd); i++) {
|
|
|
|
if (params.embd_normalize == 0) {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("%6.0f ", emb[j * n_embd + i]);
|
2024-08-10 11:43:26 +02:00
|
|
|
} else {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("%9.6f ", emb[j * n_embd + i]);
|
2024-08-10 11:43:26 +02:00
|
|
|
}
|
|
|
|
}
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("\n");
|
2024-03-27 12:15:44 +01:00
|
|
|
}
|
2024-08-10 11:43:26 +02:00
|
|
|
|
|
|
|
// print cosine similarity matrix
|
|
|
|
if (n_prompts > 1) {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("\n");
|
|
|
|
LOG("cosine similarity matrix:\n\n");
|
2024-08-10 11:43:26 +02:00
|
|
|
for (int i = 0; i < n_prompts; i++) {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("%6.6s ", prompts[i].c_str());
|
2024-06-24 07:30:24 +02:00
|
|
|
}
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("\n");
|
2024-08-10 11:43:26 +02:00
|
|
|
for (int i = 0; i < n_prompts; i++) {
|
|
|
|
for (int j = 0; j < n_prompts; j++) {
|
2024-10-10 22:57:42 +02:00
|
|
|
float sim = common_embd_similarity_cos(emb + i * n_embd, emb + j * n_embd, n_embd);
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("%6.2f ", sim);
|
2024-08-10 11:43:26 +02:00
|
|
|
}
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("%1.10s", prompts[i].c_str());
|
|
|
|
LOG("\n");
|
2024-08-10 11:43:26 +02:00
|
|
|
}
|
2024-06-24 07:30:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (params.embd_out == "json" || params.embd_out == "json+" || params.embd_out == "array") {
|
|
|
|
const bool notArray = params.embd_out != "array";
|
|
|
|
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG(notArray ? "{\n \"object\": \"list\",\n \"data\": [\n" : "[");
|
2024-06-24 07:30:24 +02:00
|
|
|
for (int j = 0;;) { // at least one iteration (one prompt)
|
2024-09-15 19:46:12 +02:00
|
|
|
if (notArray) LOG(" {\n \"object\": \"embedding\",\n \"index\": %d,\n \"embedding\": ",j);
|
|
|
|
LOG("[");
|
2024-06-24 07:30:24 +02:00
|
|
|
for (int i = 0;;) { // at least one iteration (n_embd > 0)
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG(params.embd_normalize == 0 ? "%1.0f" : "%1.7f", emb[j * n_embd + i]);
|
2024-06-24 07:30:24 +02:00
|
|
|
i++;
|
2024-09-15 19:46:12 +02:00
|
|
|
if (i < n_embd) LOG(","); else break;
|
2024-06-24 07:30:24 +02:00
|
|
|
}
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG(notArray ? "]\n }" : "]");
|
2024-06-24 07:30:24 +02:00
|
|
|
j++;
|
2024-09-15 19:46:12 +02:00
|
|
|
if (j < n_embd_count) LOG(notArray ? ",\n" : ","); else break;
|
2024-03-27 12:15:44 +01:00
|
|
|
}
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG(notArray ? "\n ]" : "]\n");
|
2024-06-24 07:30:24 +02:00
|
|
|
|
|
|
|
if (params.embd_out == "json+" && n_prompts > 1) {
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG(",\n \"cosineSimilarity\": [\n");
|
2024-08-10 11:43:26 +02:00
|
|
|
for (int i = 0;;) { // at least two iteration (n_embd_count > 1)
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG(" [");
|
2024-08-10 11:43:26 +02:00
|
|
|
for (int j = 0;;) { // at least two iteration (n_embd_count > 1)
|
2024-10-10 22:57:42 +02:00
|
|
|
float sim = common_embd_similarity_cos(emb + i * n_embd, emb + j * n_embd, n_embd);
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("%6.2f", sim);
|
2024-06-24 07:30:24 +02:00
|
|
|
j++;
|
2024-09-15 19:46:12 +02:00
|
|
|
if (j < n_embd_count) LOG(", "); else break;
|
2024-06-24 07:30:24 +02:00
|
|
|
}
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG(" ]");
|
2024-06-24 07:30:24 +02:00
|
|
|
i++;
|
2024-09-15 19:46:12 +02:00
|
|
|
if (i < n_embd_count) LOG(",\n"); else break;
|
2024-06-24 07:30:24 +02:00
|
|
|
}
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("\n ]");
|
2024-06-24 07:30:24 +02:00
|
|
|
}
|
|
|
|
|
2024-09-15 19:46:12 +02:00
|
|
|
if (notArray) LOG("\n}\n");
|
2023-03-25 19:26:40 +01:00
|
|
|
}
|
|
|
|
|
2024-09-15 19:46:12 +02:00
|
|
|
LOG("\n");
|
2024-09-13 08:53:38 +02:00
|
|
|
llama_perf_context_print(ctx);
|
2024-09-07 14:16:19 +02:00
|
|
|
|
2024-02-13 13:06:58 +01:00
|
|
|
// clean up
|
2024-05-15 14:01:12 +02:00
|
|
|
llama_batch_free(batch);
|
2023-03-25 19:26:40 +01:00
|
|
|
llama_free(ctx);
|
2023-06-24 10:47:58 +02:00
|
|
|
llama_free_model(model);
|
2023-07-10 17:49:56 +02:00
|
|
|
llama_backend_free();
|
|
|
|
|
2023-03-25 19:26:40 +01:00
|
|
|
return 0;
|
|
|
|
}
|