Skip to content

Commit

Permalink
🐛 Fixed bug in Regen constrained generation (#75)
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Martinez <[email protected]>
  • Loading branch information
marmg authored Feb 20, 2024
1 parent 6bc6446 commit d16783e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion zshot/linker/linker_regen/linker_regen.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ def load_tokenizer(self):

def restrict_decode_vocab(self, _, prefix_beam):
""" Restrict the possibilities of the Beam search to force the text generation """
return self.trie.postfix(prefix_beam.tolist())
tokens = self.trie.postfix(prefix_beam.tolist())
if not tokens:
return [self.tokenizer.eos_token_id]

return tokens

def predict(self, docs: Iterator[Doc], batch_size: Optional[Union[int, None]] = None) -> List[List[Span]]:
"""
Expand Down

0 comments on commit d16783e

Please sign in to comment.