| 137 | } |
| 138 | |
| 139 | static void test_penalties( |
| 140 | const std::vector<float> & probs, const std::vector<llama_token> & last_tokens, |
| 141 | const std::vector<float> & probs_expected, float repeat_penalty, float alpha_frequency, float alpha_presence |
| 142 | ) { |
| 143 | GGML_ASSERT(probs.size() == probs_expected.size()); |
| 144 | |
| 145 | sampler_tester tester(probs, probs_expected); |
| 146 | |
| 147 | auto * sampler = llama_sampler_init_penalties(last_tokens.size(), repeat_penalty, alpha_frequency, alpha_presence); |
| 148 | |
| 149 | for (size_t i = 0; i < last_tokens.size(); i++) { |
| 150 | llama_sampler_accept(sampler, last_tokens[i]); |
| 151 | } |
| 152 | |
| 153 | DUMP(&tester.cur_p); |
| 154 | tester.apply(sampler); |
| 155 | tester.apply(llama_sampler_init_dist(0)); |
| 156 | DUMP(&tester.cur_p); |
| 157 | |
| 158 | tester.check(); |
| 159 | } |
| 160 | |
| 161 | static void test_dry( |
| 162 | const std::vector<float> & probs, const std::vector<llama_token> & last_tokens, |
no test coverage detected