| 137 | |
| 138 | |
| 139 | struct DecodingOptions { |
| 140 | size_t beam_size = 1; |
| 141 | float patience = 1; |
| 142 | float length_penalty = 0; |
| 143 | float coverage_penalty = 0; |
| 144 | float repetition_penalty = 1; |
| 145 | size_t no_repeat_ngram_size = 0; |
| 146 | float prefix_bias_beta = 0; |
| 147 | dim_t start_step = 0; |
| 148 | size_t max_length = 256; |
| 149 | size_t min_length = 0; |
| 150 | size_t sampling_topk = 1; |
| 151 | float sampling_topp = 1; |
| 152 | float sampling_temperature = 1; |
| 153 | size_t num_hypotheses = 1; |
| 154 | bool include_eos_in_hypotheses = true; |
| 155 | bool return_scores = false; |
| 156 | bool return_attention = false; |
| 157 | bool return_logits_vocab = false; |
| 158 | bool return_alternatives = false; |
| 159 | bool return_prefix = true; |
| 160 | float min_alternative_expansion_prob = 0; |
| 161 | std::vector<size_t> disable_ids; |
| 162 | std::vector<size_t> disable_ids_begin; |
| 163 | std::vector<std::vector<size_t>> disable_sequences; |
| 164 | std::vector<std::shared_ptr<LogitsProcessor>> logits_processors; |
| 165 | std::function<bool(DecodingStepResult)> callback = nullptr; |
| 166 | }; |
| 167 | |
| 168 | std::vector<DecodingResult> |
| 169 | decode(layers::Decoder& decoder, |