| 1315 | logit_bias_map = {int(k): float(v) for k, v in logit_bias.items()} |
| 1316 | |
| 1317 | def logit_bias_processor( |
| 1318 | input_ids: npt.NDArray[np.intc], |
| 1319 | scores: npt.NDArray[np.single], |
| 1320 | ) -> npt.NDArray[np.single]: |
| 1321 | new_scores = np.copy( |
| 1322 | scores |
| 1323 | ) # Does it make sense to copy the whole array or can we just overwrite the original one? |
| 1324 | for input_id, score in logit_bias_map.items(): |
| 1325 | new_scores[input_id] = score + scores[input_id] |
| 1326 | return new_scores |
| 1327 | |
| 1328 | _logit_bias_processor = LogitsProcessorList([logit_bias_processor]) |
| 1329 | if logits_processor is None: |