@@ -203,6 +203,25 @@ bool gpt_params_parse_ex(int argc, char ** argv, gpt_params & params) {
203203 params.prompt_cache_all = true ;
204204 } else if (arg == " --prompt-cache-ro" ) {
205205 params.prompt_cache_ro = true ;
206+ } else if (arg == " -bf" || arg == " --binary-file" ) {
207+ if (++i >= argc) {
208+ invalid_param = true ;
209+ break ;
210+ }
211+ std::ifstream file (argv[i], std::ios::binary);
212+ if (!file) {
213+ fprintf (stderr, " error: failed to open file '%s'\n " , argv[i]);
214+ invalid_param = true ;
215+ break ;
216+ }
217+ // store the external file name in params
218+ params.prompt_file = argv[i];
219+ file.seekg (0 , std::ios::end);
220+ size_t size = file.tellg ();
221+ file.seekg (0 , std::ios::beg);
222+ params.prompt .resize (size);
223+ file.read ((char *)params.prompt .data (), size);
224+ fprintf (stderr, " Read %zu bytes from binary file %s\n " , size, argv[i]);
206225 } else if (arg == " -f" || arg == " --file" ) {
207226 if (++i >= argc) {
208227 invalid_param = true ;
@@ -653,6 +672,12 @@ bool gpt_params_parse_ex(int argc, char ** argv, gpt_params & params) {
653672 if (params.logdir .back () != DIRECTORY_SEPARATOR) {
654673 params.logdir += DIRECTORY_SEPARATOR;
655674 }
675+ } else if (arg == " --save-all-logits" || arg == " --kl-divergence-base" ) {
676+ if (++i >= argc) {
677+ invalid_param = true ;
678+ break ;
679+ }
680+ params.logits_file = argv[i];
656681 } else if (arg == " --perplexity" || arg == " --all-logits" ) {
657682 params.logits_all = true ;
658683 } else if (arg == " --ppl-stride" ) {
@@ -689,6 +714,16 @@ bool gpt_params_parse_ex(int argc, char ** argv, gpt_params & params) {
689714 break ;
690715 }
691716 params.winogrande_tasks = std::stoi (argv[i]);
717+ } else if (arg == " --multiple-choice" ) {
718+ params.multiple_choice = true ;
719+ } else if (arg == " --multiple-choice-tasks" ) {
720+ if (++i >= argc) {
721+ invalid_param = true ;
722+ break ;
723+ }
724+ params.multiple_choice_tasks = std::stoi (argv[i]);
725+ } else if (arg == " --kl-divergence" ) {
726+ params.kl_divergence = true ;
692727 } else if (arg == " --ignore-eos" ) {
693728 params.ignore_eos = true ;
694729 } else if (arg == " --no-penalize-nl" ) {
@@ -888,6 +923,8 @@ void gpt_print_usage(int /*argc*/, char ** argv, const gpt_params & params) {
888923 printf (" --in-suffix STRING string to suffix after user inputs with (default: empty)\n " );
889924 printf (" -f FNAME, --file FNAME\n " );
890925 printf (" prompt file to start generation.\n " );
926+ printf (" -bf FNAME, --binary-file FNAME\n " );
927+ printf (" binary file containing multiple choice tasks.\n " );
891928 printf (" -n N, --n-predict N number of tokens to predict (default: %d, -1 = infinity, -2 = until context filled)\n " , params.n_predict );
892929 printf (" -c N, --ctx-size N size of the prompt context (default: %d, 0 = loaded from model)\n " , params.n_ctx );
893930 printf (" -b N, --batch-size N batch size for prompt processing (default: %d)\n " , params.n_batch );
@@ -936,6 +973,9 @@ void gpt_print_usage(int /*argc*/, char ** argv, const gpt_params & params) {
936973 printf (" --hellaswag-tasks N number of tasks to use when computing the HellaSwag score (default: %zu)\n " , params.hellaswag_tasks );
937974 printf (" --winogrande compute Winogrande score over random tasks from datafile supplied with -f\n " );
938975 printf (" --winogrande-tasks N number of tasks to use when computing the Winogrande score (default: %zu)\n " , params.winogrande_tasks );
976+ printf (" --multiple-choice compute multiple choice score over random tasks from datafile supplied with -f\n " );
977+ printf (" --multiple-choice-tasks N number of tasks to use when computing the multiple choice score (default: %zu)\n " , params.winogrande_tasks );
978+ printf (" --kl-divergence computes KL-divergence to logits provided via --kl-divergence-base" );
939979 printf (" --keep N number of tokens to keep from the initial prompt (default: %d, -1 = all)\n " , params.n_keep );
940980 printf (" --draft N number of tokens to draft for speculative decoding (default: %d)\n " , params.n_draft );
941981 printf (" --chunks N max number of chunks to process (default: %d, -1 = all)\n " , params.n_chunks );
0 commit comments