| 159 | } |
| 160 | |
| 161 | static void test_dry( |
| 162 | const std::vector<float> & probs, const std::vector<llama_token> & last_tokens, |
| 163 | const std::vector<float> & expected_probs, float dry_multiplier, float dry_base, |
| 164 | int dry_allowed_length, int dry_penalty_last_n, |
| 165 | const std::vector<std::vector<llama_token>> & seq_breakers |
| 166 | ) { |
| 167 | GGML_ASSERT(probs.size() == expected_probs.size()); |
| 168 | |
| 169 | sampler_tester tester(probs, expected_probs); |
| 170 | |
| 171 | auto * sampler = llama_sampler_init_dry_testing(1024, dry_multiplier, dry_base, dry_allowed_length, dry_penalty_last_n, seq_breakers); |
| 172 | |
| 173 | for (size_t i = 0; i < last_tokens.size(); i++) { |
| 174 | llama_sampler_accept(sampler, last_tokens[i]); |
| 175 | } |
| 176 | |
| 177 | DUMP(&tester.cur_p); |
| 178 | tester.apply(sampler); |
| 179 | tester.apply(llama_sampler_init_dist(0)); |
| 180 | DUMP(&tester.cur_p); |
| 181 | tester.check(); |
| 182 | } |
| 183 | |
| 184 | static void test_top_n_sigma(const std::vector<float> & probs, const std::vector<float> & probs_expected, int n) { |
| 185 | sampler_tester tester(probs, probs_expected); |
no test coverage detected