| 19 | }; |
| 20 | |
| 21 | struct common_speculative * common_speculative_init( |
| 22 | struct llama_context * ctx_dft) { |
| 23 | auto * result = new common_speculative { |
| 24 | /* .ctx = */ ctx_dft, |
| 25 | /* .smpl = */ nullptr, |
| 26 | /* .batch = */ llama_batch_init(llama_n_batch(ctx_dft), 0, 1), |
| 27 | /* .prompt = */ {}, |
| 28 | }; |
| 29 | |
| 30 | // TODO: optimize or pass from outside? |
| 31 | #if 0 |
| 32 | { |
| 33 | common_params_sampling params; |
| 34 | params.no_perf = false; |
| 35 | |
| 36 | params.top_k = 40; |
| 37 | params.top_p = 0.9; |
| 38 | |
| 39 | params.samplers = { |
| 40 | COMMON_SAMPLER_TYPE_TOP_K, |
| 41 | COMMON_SAMPLER_TYPE_TOP_P, |
| 42 | COMMON_SAMPLER_TYPE_INFILL, |
| 43 | }; |
| 44 | |
| 45 | result->smpl = common_sampler_init(llama_get_model(ctx_dft), params); |
| 46 | } |
| 47 | #else |
| 48 | { |
| 49 | common_params_sampling params; |
| 50 | params.no_perf = false; |
| 51 | |
| 52 | params.top_k = 10; |
| 53 | |
| 54 | params.samplers = { |
| 55 | COMMON_SAMPLER_TYPE_TOP_K, |
| 56 | }; |
| 57 | |
| 58 | result->smpl = common_sampler_init(llama_get_model(ctx_dft), params); |
| 59 | } |
| 60 | #endif |
| 61 | |
| 62 | return result; |
| 63 | } |
| 64 | |
| 65 | void common_speculative_free(struct common_speculative * spec) { |
| 66 | if (spec == nullptr) { |
no test coverage detected