@@ -2347,7 +2347,7 @@ void llama_perf_sampler_reset(struct llama_sampler * chain) {
23472347#include " llguidance.h"
23482348
23492349struct llama_sampler_llg {
2350- const struct llama_vocab * vocab ;
2350+ const struct llama_model * model ;
23512351 std::string grammar_kind;
23522352 std::string grammar_data;
23532353 LlgConstraint *grammar;
@@ -2364,6 +2364,7 @@ static LlgConstraint *llama_sampler_llg_new(const char * grammar_kind, const cha
23642364 llg_free_constraint (c);
23652365 return nullptr ;
23662366 }
2367+ return c;
23672368}
23682369
23692370static const char * llama_sampler_llg_name (const struct llama_sampler * /* smpl*/ ) {
@@ -2394,7 +2395,7 @@ static void llama_sampler_llg_apply(struct llama_sampler * smpl, llama_token_dat
23942395 if (ctx->has_llg_res ) {
23952396 if (ctx->llg_res .is_stop ) {
23962397 for (size_t i = 0 ; i < cur_p->size ; ++i) {
2397- if (!llama_token_is_eog_impl (* ctx->vocab , cur_p->data [i].id )) {
2398+ if (!llama_token_is_eog ( ctx->model , cur_p->data [i].id )) {
23982399 cur_p->data [i].logit = -INFINITY;
23992400 }
24002401 }
@@ -2426,7 +2427,7 @@ static void llama_sampler_llg_reset(struct llama_sampler * smpl) {
24262427static struct llama_sampler * llama_sampler_llg_clone (const struct llama_sampler * smpl) {
24272428 const auto * ctx = (const llama_sampler_llg *) smpl->ctx ;
24282429
2429- auto * result = llama_sampler_init_llg_impl (* ctx->vocab , nullptr , nullptr );
2430+ auto * result = llama_sampler_init_llg ( ctx->model , nullptr , nullptr );
24302431
24312432 // copy the state
24322433 {
@@ -2461,15 +2462,13 @@ static struct llama_sampler_i llama_sampler_llg_i = {
24612462 /* .free = */ llama_sampler_llg_free,
24622463};
24632464
2464- struct llama_sampler * llama_sampler_init_llg_impl (const struct llama_vocab & vocab, const char * grammar_kind, const char * grammar_data) {
2465+ struct llama_sampler * llama_sampler_init_llg (const struct llama_model * model,
2466+ const char * grammar_kind, const char * grammar_data) {
24652467 auto * ctx = new llama_sampler_llg;
24662468
24672469 if (grammar_kind != nullptr && grammar_kind[0 ] != ' \0 ' ) {
2468- auto d = vocab.id_to_token [94776 ].text ;
2469- LLAMA_LOG_INFO (" llg: %s %d\n " , d.c_str (), d.size ());
2470-
24712470 *ctx = {
2472- /* .vocab = */ &vocab ,
2471+ /* .model = */ model ,
24732472 /* .grammar_kind = */ grammar_kind,
24742473 /* .grammar_data = */ grammar_data,
24752474 /* .grammar = */ llama_sampler_llg_new (grammar_kind, grammar_data),
@@ -2478,7 +2477,7 @@ struct llama_sampler * llama_sampler_init_llg_impl(const struct llama_vocab & vo
24782477 };
24792478 } else {
24802479 *ctx = {
2481- /* .vocab = */ &vocab ,
2480+ /* .model = */ model ,
24822481 /* .grammar_kind = */ {},
24832482 /* .grammar_data = */ {},
24842483 /* .grammar = */ nullptr ,
0 commit comments