Skip to content

Commit 6df37bc

Browse files
authored
llama : update API names to use correct prefix (#11174)
* llama : update API names to use correct prefix ggml-ci * cont ggml-ci * cont ggml-ci * minor [no ci]
1 parent 6efee8c commit 6df37bc

File tree

48 files changed

+468
-325
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+468
-325
lines changed

common/common.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -857,22 +857,22 @@ struct common_init_result common_init_from_params(common_params & params) {
857857
return iparams;
858858
}
859859

860-
const llama_vocab * vocab = llama_get_vocab(model);
860+
const llama_vocab * vocab = llama_model_get_vocab(model);
861861

862862
if (params.reranking) {
863863
bool ok = true;
864864

865-
if (llama_token_bos(vocab) == LLAMA_TOKEN_NULL) {
865+
if (llama_vocab_bos(vocab) == LLAMA_TOKEN_NULL) {
866866
LOG_WRN("%s: warning: vocab does not have a BOS token, reranking will not work\n", __func__);
867867
ok = false;
868868
}
869869

870-
if (llama_token_eos(vocab) == LLAMA_TOKEN_NULL) {
870+
if (llama_vocab_eos(vocab) == LLAMA_TOKEN_NULL) {
871871
LOG_WRN("%s: warning: vocab does not have an EOS token, reranking will not work\n", __func__);
872872
ok = false;
873873
}
874874

875-
if (llama_token_sep(vocab) == LLAMA_TOKEN_NULL) {
875+
if (llama_vocab_sep(vocab) == LLAMA_TOKEN_NULL) {
876876
LOG_WRN("%s: warning: vocab does not have a SEP token, reranking will not work\n", __func__);
877877
ok = false;
878878
}
@@ -886,7 +886,7 @@ struct common_init_result common_init_from_params(common_params & params) {
886886

887887
auto cparams = common_context_params_to_llama(params);
888888

889-
llama_context * lctx = llama_new_context_with_model(model, cparams);
889+
llama_context * lctx = llama_init_from_model(model, cparams);
890890
if (lctx == NULL) {
891891
LOG_ERR("%s: failed to create context with model '%s'\n", __func__, params.model.c_str());
892892
llama_model_free(model);
@@ -900,7 +900,7 @@ struct common_init_result common_init_from_params(common_params & params) {
900900

901901
if (!params.control_vectors.empty()) {
902902
if (params.control_vector_layer_start <= 0) params.control_vector_layer_start = 1;
903-
if (params.control_vector_layer_end <= 0) params.control_vector_layer_end = llama_n_layer(model);
903+
if (params.control_vector_layer_end <= 0) params.control_vector_layer_end = llama_model_n_layer(model);
904904

905905
const auto cvec = common_control_vector_load(params.control_vectors);
906906
if (cvec.n_embd == -1) {
@@ -944,14 +944,14 @@ struct common_init_result common_init_from_params(common_params & params) {
944944
common_set_adapter_lora(lctx, params.lora_adapters);
945945
}
946946

947-
if (params.sampling.ignore_eos && llama_token_eos(vocab) == LLAMA_TOKEN_NULL) {
947+
if (params.sampling.ignore_eos && llama_vocab_eos(vocab) == LLAMA_TOKEN_NULL) {
948948
LOG_WRN("%s: warning: vocab does not have an EOS token, ignoring --ignore-eos\n", __func__);
949949
params.sampling.ignore_eos = false;
950950
}
951951

952952
if (params.sampling.ignore_eos) {
953-
for (llama_token i = 0; i < llama_n_vocab(vocab); i++) {
954-
if (llama_token_is_eog(vocab, i)) {
953+
for (llama_token i = 0; i < llama_vocab_n_vocab(vocab); i++) {
954+
if (llama_vocab_is_eog(vocab, i)) {
955955
LOG_INF("%s: added %s logit bias = %f\n", __func__, common_token_to_piece(lctx, i).c_str(), -INFINITY);
956956
params.sampling.logit_bias.push_back({i, -INFINITY});
957957
}
@@ -972,8 +972,8 @@ struct common_init_result common_init_from_params(common_params & params) {
972972
LOG_WRN("%s: warming up the model with an empty run - please wait ... (--no-warmup to disable)\n", __func__);
973973

974974
std::vector<llama_token> tmp;
975-
llama_token bos = llama_token_bos(vocab);
976-
llama_token eos = llama_token_eos(vocab);
975+
llama_token bos = llama_vocab_bos(vocab);
976+
llama_token eos = llama_vocab_eos(vocab);
977977

978978
// some models (e.g. T5) don't have a BOS token
979979
if (bos != LLAMA_TOKEN_NULL) {
@@ -1564,7 +1564,7 @@ std::vector<llama_token> common_tokenize(
15641564
bool add_special,
15651565
bool parse_special) {
15661566
const llama_model * model = llama_get_model(ctx);
1567-
const llama_vocab * vocab = llama_get_vocab(model);
1567+
const llama_vocab * vocab = llama_model_get_vocab(model);
15681568
return common_tokenize(vocab, text, add_special, parse_special);
15691569
}
15701570

@@ -1589,7 +1589,7 @@ std::vector<llama_token> common_tokenize(
15891589

15901590
std::string common_token_to_piece(const struct llama_context * ctx, llama_token token, bool special) {
15911591
const llama_model * model = llama_get_model(ctx);
1592-
const llama_vocab * vocab = llama_get_vocab(model);
1592+
const llama_vocab * vocab = llama_model_get_vocab(model);
15931593
return common_token_to_piece(vocab, token, special);
15941594
}
15951595

@@ -1611,7 +1611,7 @@ std::string common_token_to_piece(const struct llama_vocab * vocab, llama_token
16111611

16121612
std::string common_detokenize(const struct llama_context * ctx, const std::vector<llama_token> & tokens, bool special) {
16131613
const llama_model * model = llama_get_model(ctx);
1614-
const llama_vocab * vocab = llama_get_vocab(model);
1614+
const llama_vocab * vocab = llama_model_get_vocab(model);
16151615
return common_detokenize(vocab, tokens, special);
16161616
}
16171617

common/sampling.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ struct common_sampler {
114114
const auto * logits = llama_get_logits_ith(ctx, idx);
115115

116116
const llama_model * model = llama_get_model(ctx);
117-
const llama_vocab * vocab = llama_get_vocab(model);
117+
const llama_vocab * vocab = llama_model_get_vocab(model);
118118

119-
const int n_vocab = llama_n_vocab(vocab);
119+
const int n_vocab = llama_vocab_n_vocab(vocab);
120120

121121
cur.resize(n_vocab);
122122

@@ -145,7 +145,7 @@ std::string common_params_sampling::print() const {
145145
}
146146

147147
struct common_sampler * common_sampler_init(const struct llama_model * model, const struct common_params_sampling & params) {
148-
const llama_vocab * vocab = llama_get_vocab(model);
148+
const llama_vocab * vocab = llama_model_get_vocab(model);
149149

150150
llama_sampler_chain_params lparams = llama_sampler_chain_default_params();
151151

@@ -162,7 +162,7 @@ struct common_sampler * common_sampler_init(const struct llama_model * model, co
162162

163163
llama_sampler_chain_add(result->chain,
164164
llama_sampler_init_logit_bias(
165-
llama_n_vocab(vocab),
165+
llama_vocab_n_vocab(vocab),
166166
params.logit_bias.size(),
167167
params.logit_bias.data()));
168168

@@ -177,7 +177,7 @@ struct common_sampler * common_sampler_init(const struct llama_model * model, co
177177
c_breakers.push_back(str.c_str());
178178
}
179179

180-
llama_sampler_chain_add(result->chain, llama_sampler_init_dry (vocab, llama_n_ctx_train(model), params.dry_multiplier, params.dry_base, params.dry_allowed_length, params.dry_penalty_last_n, c_breakers.data(), c_breakers.size()));
180+
llama_sampler_chain_add(result->chain, llama_sampler_init_dry (vocab, llama_model_n_ctx_train(model), params.dry_multiplier, params.dry_base, params.dry_allowed_length, params.dry_penalty_last_n, c_breakers.data(), c_breakers.size()));
181181
}
182182
break;
183183
case COMMON_SAMPLER_TYPE_TOP_K:
@@ -211,7 +211,7 @@ struct common_sampler * common_sampler_init(const struct llama_model * model, co
211211
llama_sampler_chain_add(result->chain, llama_sampler_init_dist(params.seed));
212212
} else if (params.mirostat == 1) {
213213
llama_sampler_chain_add(result->chain, llama_sampler_init_temp(params.temp));
214-
llama_sampler_chain_add(result->chain, llama_sampler_init_mirostat(llama_n_vocab(vocab), params.seed, params.mirostat_tau, params.mirostat_eta, 100));
214+
llama_sampler_chain_add(result->chain, llama_sampler_init_mirostat(llama_vocab_n_vocab(vocab), params.seed, params.mirostat_tau, params.mirostat_eta, 100));
215215
} else if (params.mirostat == 2) {
216216
llama_sampler_chain_add(result->chain, llama_sampler_init_temp(params.temp));
217217
llama_sampler_chain_add(result->chain, llama_sampler_init_mirostat_v2(params.seed, params.mirostat_tau, params.mirostat_eta));

common/speculative.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ bool common_speculative_are_compatible(
7979
const struct llama_model * model_tgt = llama_get_model(ctx_tgt);
8080
const struct llama_model * model_dft = llama_get_model(ctx_dft);
8181

82-
const struct llama_vocab * vocab_tgt = llama_get_vocab(model_tgt);
83-
const struct llama_vocab * vocab_dft = llama_get_vocab(model_dft);
82+
const struct llama_vocab * vocab_tgt = llama_model_get_vocab(model_tgt);
83+
const struct llama_vocab * vocab_dft = llama_model_get_vocab(model_dft);
8484

8585
const bool vocab_type_tgt = llama_vocab_type(vocab_tgt);
8686
LOG_DBG("%s: vocab_type tgt: %d\n", __func__, vocab_type_tgt);
@@ -94,32 +94,32 @@ bool common_speculative_are_compatible(
9494
return false;
9595
}
9696

97-
if (llama_add_bos_token(vocab_tgt) != llama_add_bos_token(vocab_dft) ||
98-
llama_add_eos_token(vocab_tgt) != llama_add_eos_token(vocab_dft) ||
99-
llama_token_bos(vocab_tgt) != llama_token_bos(vocab_dft) ||
100-
llama_token_eos(vocab_tgt) != llama_token_eos(vocab_dft)) {
97+
if (llama_vocab_add_bos(vocab_tgt) != llama_vocab_add_bos(vocab_dft) ||
98+
llama_vocab_add_eos(vocab_tgt) != llama_vocab_add_eos(vocab_dft) ||
99+
llama_vocab_bos(vocab_tgt) != llama_vocab_bos(vocab_dft) ||
100+
llama_vocab_eos(vocab_tgt) != llama_vocab_eos(vocab_dft)) {
101101
LOG_ERR("%s: draft vocab special tokens must match target vocab to use speculation\n", __func__);
102-
LOG_ERR("%s: tgt: bos = %d (%d), eos = %d (%d)\n", __func__, llama_token_bos(vocab_tgt), llama_add_bos_token(vocab_tgt), llama_token_eos(vocab_tgt), llama_add_eos_token(vocab_tgt));
103-
LOG_ERR("%s: dft: bos = %d (%d), eos = %d (%d)\n", __func__, llama_token_bos(vocab_dft), llama_add_bos_token(vocab_dft), llama_token_eos(vocab_dft), llama_add_eos_token(vocab_dft));
102+
LOG_ERR("%s: tgt: bos = %d (%d), eos = %d (%d)\n", __func__, llama_vocab_bos(vocab_tgt), llama_vocab_add_bos(vocab_tgt), llama_vocab_eos(vocab_tgt), llama_vocab_add_eos(vocab_tgt));
103+
LOG_ERR("%s: dft: bos = %d (%d), eos = %d (%d)\n", __func__, llama_vocab_bos(vocab_dft), llama_vocab_add_bos(vocab_dft), llama_vocab_eos(vocab_dft), llama_vocab_add_eos(vocab_dft));
104104
return false;
105105
}
106106

107107
{
108-
const int n_vocab_tgt = llama_n_vocab(vocab_tgt);
109-
const int n_vocab_dft = llama_n_vocab(vocab_dft);
108+
const int n_vocab_tgt = llama_vocab_n_vocab(vocab_tgt);
109+
const int n_vocab_dft = llama_vocab_n_vocab(vocab_dft);
110110

111111
const int vocab_diff = std::abs(n_vocab_tgt - n_vocab_dft);
112112

113113
if (vocab_diff > SPEC_VOCAB_MAX_SIZE_DIFFERENCE) {
114114
LOG_ERR("%s: draft model vocab must closely match target model to use speculation but "
115115
"target vocab size %d does not match draft vocab size %d - difference %d, max allowed %d\n",
116-
__func__, n_vocab_tgt, llama_n_vocab(vocab_dft), vocab_diff, SPEC_VOCAB_MAX_SIZE_DIFFERENCE);
116+
__func__, n_vocab_tgt, llama_vocab_n_vocab(vocab_dft), vocab_diff, SPEC_VOCAB_MAX_SIZE_DIFFERENCE);
117117
return false;
118118
}
119119

120120
for (int i = SPEC_VOCAB_CHECK_START_TOKEN_ID; i < std::min(n_vocab_tgt, n_vocab_dft); ++i) {
121-
const char * token_text_tgt = llama_token_get_text(vocab_tgt, i);
122-
const char * token_text_dft = llama_token_get_text(vocab_dft, i);
121+
const char * token_text_tgt = llama_vocab_get_text(vocab_tgt, i);
122+
const char * token_text_dft = llama_vocab_get_text(vocab_dft, i);
123123
if (std::strcmp(token_text_tgt, token_text_dft) != 0) {
124124
LOG_ERR("%s: draft vocab vocab must match target vocab to use speculation but "
125125
"token %d content differs - target '%s', draft '%s'\n", __func__, i,

examples/batched-bench/batched-bench.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int main(int argc, char ** argv) {
5050
// ensure enough sequences are available
5151
ctx_params.n_seq_max = n_pl.empty() ? 1 : *std::max_element(n_pl.begin(), n_pl.end());
5252

53-
llama_context * ctx = llama_new_context_with_model(model, ctx_params);
53+
llama_context * ctx = llama_init_from_model(model, ctx_params);
5454

5555
if (ctx == NULL) {
5656
fprintf(stderr , "%s: error: failed to create the llama_context\n" , __func__);

examples/batched.swift/Sources/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ while n_cur <= n_len {
141141
let new_token_id = llama_sampler_sample(smpl, context, i_batch[i])
142142

143143
// is it an end of stream? -> mark the stream as finished
144-
if llama_token_is_eog(model, new_token_id) || n_cur == n_len {
144+
if llama_vocab_is_eog(model, new_token_id) || n_cur == n_len {
145145
i_batch[i] = -1
146146
// print("")
147147
if n_parallel > 1 {

examples/batched/batched.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ int main(int argc, char ** argv) {
4848
return 1;
4949
}
5050

51-
const llama_vocab * vocab = llama_get_vocab(model);
51+
const llama_vocab * vocab = llama_model_get_vocab(model);
5252

5353
// tokenize the prompt
5454

@@ -64,7 +64,7 @@ int main(int argc, char ** argv) {
6464
ctx_params.n_ctx = n_kv_req;
6565
ctx_params.n_batch = std::max(n_predict, n_parallel);
6666

67-
llama_context * ctx = llama_new_context_with_model(model, ctx_params);
67+
llama_context * ctx = llama_init_from_model(model, ctx_params);
6868

6969
auto sparams = llama_sampler_chain_default_params();
7070
sparams.no_perf = false;
@@ -123,7 +123,7 @@ int main(int argc, char ** argv) {
123123

124124
llama_token decoder_start_token_id = llama_model_decoder_start_token(model);
125125
if (decoder_start_token_id == LLAMA_TOKEN_NULL) {
126-
decoder_start_token_id = llama_token_bos(vocab);
126+
decoder_start_token_id = llama_vocab_bos(vocab);
127127
}
128128

129129
common_batch_clear(batch);
@@ -176,7 +176,7 @@ int main(int argc, char ** argv) {
176176
const llama_token new_token_id = llama_sampler_sample(smpl, ctx, i_batch[i]);
177177

178178
// is it an end of generation? -> mark the stream as finished
179-
if (llama_token_is_eog(vocab, new_token_id) || n_cur == n_predict) {
179+
if (llama_vocab_is_eog(vocab, new_token_id) || n_cur == n_predict) {
180180
i_batch[i] = -1;
181181
LOG("\n");
182182
if (n_parallel > 1) {

examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ int main(int argc, char ** argv) {
911911
load_vocab(params.fn_vocab_model, &config, &vocab);
912912

913913
struct my_llama_model model;
914-
model.hparams.n_vocab = config.vocab_size; //llama_n_vocab(lctx);
914+
model.hparams.n_vocab = config.vocab_size; //llama_vocab_n_vocab(lctx);
915915
model.hparams.n_ctx = params.n_ctx;
916916
model.hparams.n_embd = config.dim; //params.n_embd;
917917
model.hparams.n_ff = config.hidden_dim;

examples/cvector-generator/cvector-generator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ struct tokenized_prompt {
274274

275275
tokenized_prompt(llama_context * ctx, std::string pos, std::string neg) {
276276
const llama_model * model = llama_get_model(ctx);
277-
const llama_vocab * vocab = llama_get_vocab(model);
278-
const bool add_bos = llama_add_bos_token(vocab);
277+
const llama_vocab * vocab = llama_model_get_vocab(model);
278+
const bool add_bos = llama_vocab_add_bos(vocab);
279279
tokens_pos = common_tokenize(ctx, pos, add_bos, true);
280280
tokens_neg = common_tokenize(ctx, neg, add_bos, true);
281281
max_seq_len = std::max(tokens_pos.size(), tokens_neg.size());
@@ -423,8 +423,8 @@ int main(int argc, char ** argv) {
423423
llama_context * ctx = llama_init.context.get();
424424

425425
// int n_ctx = llama_n_ctx(ctx);
426-
int n_layers = llama_n_layer(model);
427-
int n_embd = llama_n_embd(model);
426+
int n_layers = llama_model_n_layer(model);
427+
int n_embd = llama_model_n_embd(model);
428428

429429
// get model hint param (a.k.a model arch name)
430430
char model_hint[128];

examples/embedding/embedding.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ int main(int argc, char ** argv) {
105105
return 1;
106106
}
107107

108-
const llama_vocab * vocab = llama_get_vocab(model);
108+
const llama_vocab * vocab = llama_model_get_vocab(model);
109109

110-
const int n_ctx_train = llama_n_ctx_train(model);
110+
const int n_ctx_train = llama_model_n_ctx_train(model);
111111
const int n_ctx = llama_n_ctx(ctx);
112112

113113
const enum llama_pooling_type pooling_type = llama_pooling_type(ctx);
@@ -150,7 +150,7 @@ int main(int argc, char ** argv) {
150150
// check if the last token is SEP
151151
// it should be automatically added by the tokenizer when 'tokenizer.ggml.add_eos_token' is set to 'true'
152152
for (auto & inp : inputs) {
153-
if (inp.empty() || inp.back() != llama_token_sep(vocab)) {
153+
if (inp.empty() || inp.back() != llama_vocab_sep(vocab)) {
154154
LOG_WRN("%s: last token in the prompt is not SEP\n", __func__);
155155
LOG_WRN("%s: 'tokenizer.ggml.add_eos_token' should be set to 'true' in the GGUF header\n", __func__);
156156
}
@@ -183,7 +183,7 @@ int main(int argc, char ** argv) {
183183
}
184184

185185
// allocate output
186-
const int n_embd = llama_n_embd(model);
186+
const int n_embd = llama_model_n_embd(model);
187187
std::vector<float> embeddings(n_embd_count * n_embd, 0);
188188
float * emb = embeddings.data();
189189

examples/eval-callback/eval-callback.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ static bool ggml_debug(struct ggml_tensor * t, bool ask, void * user_data) {
128128

129129
static bool run(llama_context * ctx, const common_params & params) {
130130
const llama_model * model = llama_get_model(ctx);
131-
const llama_vocab * vocab = llama_get_vocab(model);
131+
const llama_vocab * vocab = llama_model_get_vocab(model);
132132

133-
const bool add_bos = llama_add_bos_token(vocab);
133+
const bool add_bos = llama_vocab_add_bos(vocab);
134134

135135
std::vector<llama_token> tokens = common_tokenize(ctx, params.prompt, add_bos);
136136

examples/export-lora/export-lora.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <map>
99
#include <vector>
1010
#include <string>
11-
#include <thread>
1211
#include <fstream>
1312

1413
static bool g_verbose = false;

examples/gritlm/gritlm.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static std::vector<std::vector<float>> encode(llama_context * ctx, const std::ve
1111
std::vector<std::vector<float>> result;
1212

1313
const llama_model * model = llama_get_model(ctx);
14-
const llama_vocab * vocab = llama_get_vocab(model);
14+
const llama_vocab * vocab = llama_model_get_vocab(model);
1515

1616
llama_batch batch = llama_batch_init(llama_n_batch(ctx), 0, 1);
1717

@@ -26,7 +26,7 @@ static std::vector<std::vector<float>> encode(llama_context * ctx, const std::ve
2626

2727
// GritLM seems to have EOS = ""
2828
// https://github.com/ContextualAI/gritlm/blob/92025b16534712b31b3c4aaaf069350e222bd5f8/gritlm/gritlm.py#L18
29-
// inputs.push_back(llama_token_eos(vocab));
29+
// inputs.push_back(llama_vocab_eos(vocab));
3030

3131
// we want to ignore instruction tokens for mean pooling
3232
const int32_t n_inst = common_tokenize(vocab, instruction, true, false).size();
@@ -53,7 +53,7 @@ static std::vector<std::vector<float>> encode(llama_context * ctx, const std::ve
5353
llama_decode(ctx, batch);
5454

5555
// get embedding dimensions
56-
uint64_t n_embd = llama_n_embd(model);
56+
uint64_t n_embd = llama_model_n_embd(model);
5757

5858
// allocate embedding output
5959
std::vector<float> emb_unorm(n_embd, 0.0f);
@@ -98,9 +98,9 @@ static std::string generate(llama_context * ctx, llama_sampler * smpl, const std
9898
std::string result;
9999

100100
const llama_model * model = llama_get_model(ctx);
101-
const llama_vocab * vocab = llama_get_vocab(model);
101+
const llama_vocab * vocab = llama_model_get_vocab(model);
102102

103-
llama_token eos_token = llama_token_eos(vocab);
103+
llama_token eos_token = llama_vocab_eos(vocab);
104104

105105
llama_kv_cache_clear(ctx);
106106
llama_set_embeddings(ctx, false);
@@ -171,7 +171,7 @@ int main(int argc, char * argv[]) {
171171
llama_model * model = llama_model_load_from_file(params.model.c_str(), mparams);
172172

173173
// create generation context
174-
llama_context * ctx = llama_new_context_with_model(model, cparams);
174+
llama_context * ctx = llama_init_from_model(model, cparams);
175175

176176
auto sparams = llama_sampler_chain_default_params();
177177

@@ -200,7 +200,7 @@ int main(int argc, char * argv[]) {
200200
const std::vector<std::vector<float>> d_rep = encode(ctx, documents, gritlm_instruction(""));
201201
const std::vector<std::vector<float>> q_rep = encode(ctx, queries, gritlm_instruction(instruction));
202202

203-
const int n_embd = llama_n_embd(model);
203+
const int n_embd = llama_model_n_embd(model);
204204

205205
const float cosine_sim_q0_d0 = common_embd_similarity_cos(q_rep[0].data(), d_rep[0].data(), n_embd);
206206
const float cosine_sim_q0_d1 = common_embd_similarity_cos(q_rep[0].data(), d_rep[1].data(), n_embd);

0 commit comments

Comments
 (0)