This commit is contained in:
Nicolas Patry 2024-11-15 13:33:47 +01:00
parent 1623a56544
commit 8dffe1ca08
No known key found for this signature in database
GPG Key ID: D2920555C90F704C

View File

@ -501,7 +501,7 @@ class GrammarLogitProcessor(LogitsProcessor):
allowed_tokens = self.fsm.get_next_instruction(fsm_grammar_state).tokens allowed_tokens = self.fsm.get_next_instruction(fsm_grammar_state).tokens
mask = torch.full_like(logits, -math.inf) mask = torch.full_like(logits, -math.inf)
if allowed_tokens is not None: if allowed_tokens is not None:
mask[:, allowed_tokens] = 0 mask[:, allowed_tokens] = 0
biased_scores = logits + mask biased_scores = logits + mask
return biased_scores return biased_scores