aitextgen icon indicating copy to clipboard operation
aitextgen copied to clipboard

Any way to stop GPT-2 from generating specific characters?

Open danielricks opened this issue 3 years ago • 1 comments

I've played with simple-gpt2 as well as aitextgen, and I was wondering if there was a recommended way to prevent certain characters from being generated. Ideally I'd be able to specify characters in unicode and then obviously those characters would be converted to their bpe equivalents in the code before they're prevented from being generated. Is there any way to do that already? Is there a recommended way to proceed in that direction? Thanks!

danielricks avatar May 06 '21 16:05 danielricks

There is a bad_words_id param that might work: https://huggingface.co/transformers/main_classes/model.html?highlight=generate#transformers.generation_utils.GenerationMixin.generate

minimaxir avatar May 07 '21 04:05 minimaxir