Skip to content

Commit 647223e

Browse files
committed
Fix a bug in OutlinesCoreLogitsProcessor about advancing when in final state
1 parent b3fba13 commit 647223e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

outlines/backends/outlines_core.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,13 @@ def process_logits(
179179
else:
180180
for i in range(batch_size):
181181
last_token_id = self.tensor_adapter.to_scalar(input_ids[i][-1]) # type: ignore
182-
if not self._guides[i].is_finished():
182+
# This circumvents issue #227 in outlines_core
183+
# Ideally, we would be able to advance all the times as the final
184+
# state would accept the eos token leading to itself
185+
if (
186+
not self._guides[i].is_finished()
187+
or self._guides[i].accepts_tokens([last_token_id])
188+
):
183189
self._guides[i].advance(
184190
token_id=last_token_id,
185191
return_tokens=False

0 commit comments

Comments
 (0)