Merge pull request #40 from VE-FORBRYDERNE/patch

Allow bad words filter to ban <|endoftext|> token
This commit is contained in:
henk717 2021-11-27 19:23:01 +01:00 committed by GitHub
commit 939719214d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -655,6 +655,14 @@ if(not vars.model in ["InferKit", "Colab", "OAI", "ReadOnly", "TPUMeshTransforme
transformers.generation_utils.GenerationMixin.sample = new_sample transformers.generation_utils.GenerationMixin.sample = new_sample
# Allow bad words filter to ban <|endoftext|> token
import transformers.generation_logits_process
def new_init(self, bad_words_ids: List[List[int]], eos_token_id: int):
return new_init.old_init(self, bad_words_ids, -1)
new_init.old_init = transformers.generation_logits_process.NoBadWordsLogitsProcessor.__init__
transformers.generation_logits_process.NoBadWordsLogitsProcessor.__init__ = new_init
# Sets up dynamic world info scanner # Sets up dynamic world info scanner
class DynamicWorldInfoScanCriteria(StoppingCriteria): class DynamicWorldInfoScanCriteria(StoppingCriteria):
def __init__( def __init__(