@@ -341,7 +341,7 @@ static results_perplexity perplexity_v2(llama_context * ctx, const common_params
341341 const int n_chunk = params.n_chunks < 0 ? n_chunk_max : std::min (params.n_chunks , n_chunk_max);
342342 const int n_batch = params.n_batch ;
343343
344- const int n_vocab = llama_n_vocab (llama_get_model (ctx) );
344+ const int n_vocab = llama_n_vocab (vocab );
345345
346346 int count = 0 ;
347347 double nll = 0.0 ;
@@ -491,7 +491,7 @@ static results_perplexity perplexity(llama_context * ctx, const common_params &
491491 const int n_chunk = params.n_chunks < 0 ? n_chunk_max : std::min (params.n_chunks , n_chunk_max);
492492 const int n_batch = params.n_batch ;
493493
494- const int n_vocab = llama_n_vocab (llama_get_model (ctx) );
494+ const int n_vocab = llama_n_vocab (vocab );
495495
496496 int count = 0 ;
497497 double nll = 0.0 ;
@@ -857,7 +857,7 @@ static void hellaswag_score(llama_context * ctx, const common_params & params) {
857857 const int n_ctx = llama_n_ctx (ctx);
858858 const int n_batch = params.n_batch ;
859859
860- const int n_vocab = llama_n_vocab (llama_get_model (ctx) );
860+ const int n_vocab = llama_n_vocab (vocab );
861861
862862 const int max_tasks_per_batch = 32 ;
863863 const int max_seq = std::min (4 *max_tasks_per_batch, (int ) llama_n_seq_max (ctx));
@@ -1081,6 +1081,8 @@ static std::vector<winogrande_entry> load_winogrande_from_csv(const std::string
10811081 *
10821082 */
10831083static void winogrande_score (llama_context * ctx, const common_params & params) {
1084+ const llama_model * model = llama_get_model (ctx);
1085+ const llama_vocab * vocab = llama_get_vocab (model);
10841086
10851087 constexpr int k_min_trailing_ctx = 3 ;
10861088
@@ -1139,7 +1141,7 @@ static void winogrande_score(llama_context * ctx, const common_params & params)
11391141 const int n_ctx = llama_n_ctx (ctx);
11401142 const int n_batch = params.n_batch ;
11411143
1142- const int n_vocab = llama_n_vocab (llama_get_model (ctx) );
1144+ const int n_vocab = llama_n_vocab (vocab );
11431145
11441146 const int max_tasks_per_batch = 128 ;
11451147 const int max_seq = std::min (2 *max_tasks_per_batch, (int ) llama_n_seq_max (ctx));
@@ -1383,6 +1385,8 @@ static bool multiple_choice_prepare_one_task(llama_context * ctx, multiple_choic
13831385// https://huggingface.co/datasets/truthful_qa
13841386//
13851387static void multiple_choice_score (llama_context * ctx, const common_params & params) {
1388+ const llama_model * model = llama_get_model (ctx);
1389+ const llama_vocab * vocab = llama_get_vocab (model);
13861390
13871391 std::istringstream strstream (params.prompt );
13881392 uint32_t n_task;
@@ -1491,7 +1495,7 @@ static void multiple_choice_score(llama_context * ctx, const common_params & par
14911495 const int n_ctx = llama_n_ctx (ctx);
14921496 const int n_batch = params.n_batch ;
14931497
1494- const int n_vocab = llama_n_vocab (llama_get_model (ctx) );
1498+ const int n_vocab = llama_n_vocab (vocab );
14951499
14961500 const int max_tasks_per_batch = 32 ;
14971501 const int max_seq = std::min (4 *max_tasks_per_batch, (int ) llama_n_seq_max (ctx));
@@ -1700,8 +1704,8 @@ static void kl_divergence(llama_context * ctx, const common_params & params) {
17001704 LOG_ERR (" %s: failed reading n_vocab, n_chunk from %s\n " , __func__, params.logits_file .c_str ());
17011705 return ;
17021706 }
1703- if (n_vocab != llama_n_vocab (llama_get_model (ctx) )) {
1704- LOG_ERR (" %s: inconsistent vocabulary (%d vs %d)\n " , __func__, n_vocab, llama_n_vocab (llama_get_model (ctx) ));
1707+ if (n_vocab != llama_n_vocab (vocab )) {
1708+ LOG_ERR (" %s: inconsistent vocabulary (%d vs %d)\n " , __func__, n_vocab, llama_n_vocab (vocab ));
17051709 }
17061710
17071711 std::vector<llama_token> tokens (size_t (n_ctx) * n_chunk);
0 commit comments