@@ -838,6 +838,31 @@ struct llama_init_result llama_init_from_gpt_params(gpt_params & params) {
838838        return  iparams;
839839    }
840840
841+     if  (params.reranking ) {
842+         bool  ok = true ;
843+ 
844+         if  (llama_token_bos (model) == LLAMA_TOKEN_NULL) {
845+             LOG_WRN (" %s: warning: model does not have a  BOS token, reranking will not work\n "  , __func__);
846+             ok = false ;
847+         }
848+ 
849+         if  (llama_token_eos (model) == LLAMA_TOKEN_NULL) {
850+             LOG_WRN (" %s: warning: model does not have an EOS token, reranking will not work\n "  , __func__);
851+             ok = false ;
852+         }
853+ 
854+         if  (llama_token_sep (model) == LLAMA_TOKEN_NULL) {
855+             LOG_WRN (" %s: warning: model does not have a  SEP token, reranking will not work\n "  , __func__);
856+             ok = false ;
857+         }
858+ 
859+         if  (!ok) {
860+             llama_free_model (model);
861+ 
862+             return  iparams;
863+         }
864+     }
865+ 
841866    auto  cparams = llama_context_params_from_gpt_params (params);
842867
843868    llama_context * lctx = llama_new_context_with_model (model, cparams);
@@ -855,6 +880,7 @@ struct llama_init_result llama_init_from_gpt_params(gpt_params & params) {
855880        if  (cvec.n_embd  == -1 ) {
856881            llama_free (lctx);
857882            llama_free_model (model);
883+ 
858884            return  iparams;
859885        }
860886
@@ -867,6 +893,7 @@ struct llama_init_result llama_init_from_gpt_params(gpt_params & params) {
867893        if  (err) {
868894            llama_free (lctx);
869895            llama_free_model (model);
896+ 
870897            return  iparams;
871898        }
872899    }
@@ -889,7 +916,7 @@ struct llama_init_result llama_init_from_gpt_params(gpt_params & params) {
889916        llama_lora_adapters_apply (lctx, iparams.lora_adapters );
890917    }
891918
892-     if  (params.sparams .ignore_eos  && llama_token_eos (model) == - 1 ) {
919+     if  (params.sparams .ignore_eos  && llama_token_eos (model) == LLAMA_TOKEN_NULL ) {
893920        LOG_WRN (" %s: warning: model does not have an EOS token, ignoring --ignore-eos\n "  , __func__);
894921        params.sparams .ignore_eos  = false ;
895922    }
@@ -930,6 +957,7 @@ struct llama_init_result llama_init_from_gpt_params(gpt_params & params) {
930957
931958    iparams.model    = model;
932959    iparams.context  = lctx;
960+ 
933961    return  iparams;
934962}
935963
0 commit comments