llama-sampling.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #pragma once
  2. // TODO: rename llama-sampling.h/.cpp to llama-sampler.h/.cpp ?
  3. #include "llama-grammar.h"
  4. struct llama_vocab;
  5. struct llama_grammar;
  6. // sampler chain
  7. struct llama_sampler_chain {
  8. llama_sampler_chain_params params;
  9. std::vector<struct llama_sampler *> samplers;
  10. // timing
  11. mutable int64_t t_sample_us;
  12. mutable int32_t n_sample;
  13. };
  14. struct llama_sampler * llama_sampler_init_grammar_impl(
  15. const struct llama_vocab & vocab,
  16. const char * grammar_str,
  17. const char * grammar_root);
  18. struct llama_sampler * llama_sampler_init_infill_impl(
  19. const struct llama_vocab & vocab);
  20. struct llama_sampler * llama_sampler_init_dry_impl(
  21. const struct llama_vocab & vocab,
  22. int32_t context_size,
  23. float dry_multiplier,
  24. float dry_base,
  25. int32_t dry_allowed_length,
  26. int32_t dry_penalty_last_n,
  27. const char ** seq_breakers,
  28. size_t num_breakers);
  29. struct llama_sampler * llama_sampler_init_dry_testing(
  30. int32_t context_size,
  31. float dry_multiplier,
  32. float dry_base,
  33. int32_t dry_allowed_length,
  34. int32_t dry_penalty_last_n,
  35. const std::vector<std::vector<llama_token>>& seq_breakers);