| 221 | } |
| 222 | |
| 223 | static bark_token gpt_argmax_sample(std::vector<float>& logits, float* eos_p) { |
| 224 | int n_logits = logits.size(); |
| 225 | |
| 226 | // testing purposes |
| 227 | for (auto& l : logits) { |
| 228 | l /= 0.7f; |
| 229 | } |
| 230 | |
| 231 | // likelihood of EOS token |
| 232 | softmax(logits); |
| 233 | |
| 234 | if (eos_p) |
| 235 | *eos_p = logits[logits.size() - 1]; |
| 236 | |
| 237 | int next = 0; |
| 238 | float maxl = -INFINITY; |
| 239 | |
| 240 | for (int i = 0; i < n_logits; i++) { |
| 241 | if (logits[i] > maxl) { |
| 242 | maxl = logits[i]; |
| 243 | next = i; |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | return next; |
| 248 | } |
| 249 | |
| 250 | static bark_token gpt_sample( |
| 251 | std::vector<float>& logits, |
no test coverage detected