@@ -203,6 +203,23 @@ 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+ std::ostringstream ss;
220+ ss << file.rdbuf ();
221+ params.prompt = ss.str ();
222+ fprintf (stderr, " Read %zu bytes from binary file %s\n " , params.prompt .size (), argv[i]);
206223 } else if (arg == " -f" || arg == " --file" ) {
207224 if (++i >= argc) {
208225 invalid_param = true ;
@@ -659,6 +676,12 @@ bool gpt_params_parse_ex(int argc, char ** argv, gpt_params & params) {
659676 if (params.logdir .back () != DIRECTORY_SEPARATOR) {
660677 params.logdir += DIRECTORY_SEPARATOR;
661678 }
679+ } else if (arg == " --save-all-logits" || arg == " --kl-divergence-base" ) {
680+ if (++i >= argc) {
681+ invalid_param = true ;
682+ break ;
683+ }
684+ params.logits_file = argv[i];
662685 } else if (arg == " --perplexity" || arg == " --all-logits" ) {
663686 params.logits_all = true ;
664687 } else if (arg == " --ppl-stride" ) {
@@ -695,6 +718,16 @@ bool gpt_params_parse_ex(int argc, char ** argv, gpt_params & params) {
695718 break ;
696719 }
697720 params.winogrande_tasks = std::stoi (argv[i]);
721+ } else if (arg == " --multiple-choice" ) {
722+ params.multiple_choice = true ;
723+ } else if (arg == " --multiple-choice-tasks" ) {
724+ if (++i >= argc) {
725+ invalid_param = true ;
726+ break ;
727+ }
728+ params.multiple_choice_tasks = std::stoi (argv[i]);
729+ } else if (arg == " --kl-divergence" ) {
730+ params.kl_divergence = true ;
698731 } else if (arg == " --ignore-eos" ) {
699732 params.ignore_eos = true ;
700733 } else if (arg == " --no-penalize-nl" ) {
@@ -894,6 +927,8 @@ void gpt_print_usage(int /*argc*/, char ** argv, const gpt_params & params) {
894927 printf (" --in-suffix STRING string to suffix after user inputs with (default: empty)\n " );
895928 printf (" -f FNAME, --file FNAME\n " );
896929 printf (" prompt file to start generation.\n " );
930+ printf (" -bf FNAME, --binary-file FNAME\n " );
931+ printf (" binary file containing multiple choice tasks.\n " );
897932 printf (" -n N, --n-predict N number of tokens to predict (default: %d, -1 = infinity, -2 = until context filled)\n " , params.n_predict );
898933 printf (" -c N, --ctx-size N size of the prompt context (default: %d, 0 = loaded from model)\n " , params.n_ctx );
899934 printf (" -b N, --batch-size N batch size for prompt processing (default: %d)\n " , params.n_batch );
@@ -944,6 +979,9 @@ void gpt_print_usage(int /*argc*/, char ** argv, const gpt_params & params) {
944979 printf (" --hellaswag-tasks N number of tasks to use when computing the HellaSwag score (default: %zu)\n " , params.hellaswag_tasks );
945980 printf (" --winogrande compute Winogrande score over random tasks from datafile supplied with -f\n " );
946981 printf (" --winogrande-tasks N number of tasks to use when computing the Winogrande score (default: %zu)\n " , params.winogrande_tasks );
982+ printf (" --multiple-choice compute multiple choice score over random tasks from datafile supplied with -f\n " );
983+ printf (" --multiple-choice-tasks N number of tasks to use when computing the multiple choice score (default: %zu)\n " , params.winogrande_tasks );
984+ printf (" --kl-divergence computes KL-divergence to logits provided via --kl-divergence-base" );
947985 printf (" --keep N number of tokens to keep from the initial prompt (default: %d, -1 = all)\n " , params.n_keep );
948986 printf (" --draft N number of tokens to draft for speculative decoding (default: %d)\n " , params.n_draft );
949987 printf (" --chunks N max number of chunks to process (default: %d, -1 = all)\n " , params.n_chunks );
0 commit comments