| 1718 | }; |
| 1719 | |
| 1720 | struct llama_sampler * llama_sampler_init_penalties( |
| 1721 | int32_t penalty_last_n, |
| 1722 | float penalty_repeat, |
| 1723 | float penalty_freq, |
| 1724 | float penalty_present) { |
| 1725 | penalty_last_n = std::max(penalty_last_n, 0); |
| 1726 | |
| 1727 | return llama_sampler_init( |
| 1728 | /* .iface = */ &llama_sampler_penalties_i, |
| 1729 | /* .ctx = */ new llama_sampler_penalties { |
| 1730 | /* .penalty_last_n = */ penalty_last_n, |
| 1731 | /* .penalty_repeat = */ penalty_repeat, |
| 1732 | /* .penalty_freq = */ penalty_freq, |
| 1733 | /* .penalty_present = */ penalty_present, |
| 1734 | /* .prev = */ ring_buffer<llama_token>(penalty_last_n), |
| 1735 | /* .token_count = */ {}, |
| 1736 | } |
| 1737 | ); |
| 1738 | } |
| 1739 | |
| 1740 | // top-n-sigma |
| 1741 | |