| 678 | } |
| 679 | |
| 680 | int main(int argc, char ** argv) { |
| 681 | gpt_params params; |
| 682 | |
| 683 | params.n_batch = 512; |
| 684 | if (!gpt_params_parse(argc, argv, params)) { |
| 685 | return 1; |
| 686 | } |
| 687 | |
| 688 | params.logits_all = true; |
| 689 | params.n_batch = std::min(params.n_batch, params.n_ctx); |
| 690 | |
| 691 | if (params.ppl_stride > 0) { |
| 692 | fprintf(stderr, "Will perform strided perplexity calculation -> adjusting context size from %d to %d\n", |
| 693 | params.n_ctx, params.n_ctx + params.ppl_stride/2); |
| 694 | params.n_ctx += params.ppl_stride/2; |
| 695 | } |
| 696 | |
| 697 | print_build_info(); |
| 698 | |
| 699 | if (params.seed == LLAMA_DEFAULT_SEED) { |
| 700 | params.seed = time(NULL); |
| 701 | } |
| 702 | |
| 703 | fprintf(stderr, "%s: seed = %u\n", __func__, params.seed); |
| 704 | |
| 705 | std::mt19937 rng(params.seed); |
| 706 | if (params.random_prompt) { |
| 707 | params.prompt = gpt_random_prompt(rng); |
| 708 | } |
| 709 | |
| 710 | llama_backend_init(params.numa); |
| 711 | |
| 712 | llama_model * model; |
| 713 | llama_context * ctx; |
| 714 | |
| 715 | // load the model and apply lora adapter, if any |
| 716 | std::tie(model, ctx) = llama_init_from_gpt_params(params); |
| 717 | if (model == NULL) { |
| 718 | fprintf(stderr, "%s: error: unable to load model\n", __func__); |
| 719 | return 1; |
| 720 | } |
| 721 | |
| 722 | const int n_ctx_train = llama_n_ctx_train(model); |
| 723 | if (params.n_ctx > n_ctx_train) { |
| 724 | fprintf(stderr, "%s: warning: model was trained on only %d context tokens (%d specified)\n", |
| 725 | __func__, n_ctx_train, params.n_ctx); |
| 726 | } |
| 727 | |
| 728 | // print system information |
| 729 | { |
| 730 | fprintf(stderr, "\n"); |
| 731 | fprintf(stderr, "%s\n", get_system_info(params).c_str()); |
| 732 | } |
| 733 | |
| 734 | struct results_perplexity results; |
| 735 | if (params.hellaswag) { |
| 736 | hellaswag_score(ctx, params); |
| 737 | } else { |
nothing calls this directly
no test coverage detected