| 5 | #include <memory> |
| 6 | |
| 7 | struct Sampler { |
| 8 | int vocab_size; |
| 9 | |
| 10 | Sampler(const std::shared_ptr<Config> config, uint64_t seed); |
| 11 | |
| 12 | // Return the probability score corresponding to `logits[index]`. |
| 13 | // This is equivalent to taking the softmax of the logits and returning |
| 14 | // the value at index `index`. |
| 15 | float sample_prob(int index, const InferenceState& s); |
| 16 | // Return the index of the maximum value in `logits`. |
| 17 | int sample_argmax(const InferenceState& s); |
| 18 | // Sample from the model's distribution with temperature. |
| 19 | int sample(const InferenceState& s, float temperature = 1.0, float top_p = 0.95); |
| 20 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected