Add grammar to transformers and _HF loaders (#4091)
This commit is contained in:
parent
0197fdddf1
commit
ae4ba3007f
12 changed files with 56 additions and 0 deletions
|
@ -18,6 +18,7 @@ from modules.callbacks import (
|
|||
_StopEverythingStoppingCriteria
|
||||
)
|
||||
from modules.extensions import apply_extensions
|
||||
from modules.grammar import GrammarLogitsProcessor
|
||||
from modules.html_generator import generate_4chan_html, generate_basic_html
|
||||
from modules.logging_colors import logger
|
||||
from modules.models import clear_torch_cache, local_rank
|
||||
|
@ -319,6 +320,7 @@ def generate_reply_HF(question, original_question, seed, state, stopping_strings
|
|||
# In case a processor is passed by itself.
|
||||
if not isinstance(processor, LogitsProcessorList):
|
||||
processor = LogitsProcessorList([processor])
|
||||
processor.append(GrammarLogitsProcessor(state['grammar_string']))
|
||||
apply_extensions('logits_processor', processor, input_ids)
|
||||
generate_params['logits_processor'] = processor
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue