Formatron v0.4.2
Formatron empowers everyone to control the output format of language models with minimal overhead.
Loading...
Searching...
No Matches
formatron.integrations.transformers Namespace Reference

This module integrates the transformers library by providing convenience utilities. More...

Classes

class  FormattersLogitsProcessor
 Logit processor that uses formatters to mask batch logits. More...
 

Functions

kbnf.Vocabulary create_engine_vocabulary (PreTrainedTokenizerBase tokenizer)
 Create a vocabulary for the KBNF engine.
 
LogitsProcessor create_formatter_logits_processor (PreTrainedTokenizerBase tokenizer, typing.Sequence[FormatterBuilder|None]|FormatterBuilder formatter_builders, typing.Sequence[EngineGenerationConfig] configs=None)
 Create a formatter logits processor.
 
LogitsProcessorList create_formatter_logits_processor_list (PreTrainedTokenizerBase tokenizer, typing.Sequence[FormatterBuilder|None]|FormatterBuilder formatter_builders, typing.Sequence[EngineGenerationConfig] configs=None)
 Create a formatter logits processor list.
 

Detailed Description

This module integrates the transformers library by providing convenience utilities.

Function Documentation

◆ create_engine_vocabulary()

kbnf.Vocabulary formatron.integrations.transformers.create_engine_vocabulary ( PreTrainedTokenizerBase tokenizer)

Create a vocabulary for the KBNF engine.

Definition at line 19 of file transformers.py.

◆ create_formatter_logits_processor()

LogitsProcessor formatron.integrations.transformers.create_formatter_logits_processor ( PreTrainedTokenizerBase tokenizer,
typing.Sequence[FormatterBuilder | None] | FormatterBuilder formatter_builders,
typing.Sequence[EngineGenerationConfig] configs = None )

Create a formatter logits processor.

Definition at line 29 of file transformers.py.

◆ create_formatter_logits_processor_list()

LogitsProcessorList formatron.integrations.transformers.create_formatter_logits_processor_list ( PreTrainedTokenizerBase tokenizer,
typing.Sequence[FormatterBuilder | None] | FormatterBuilder formatter_builders,
typing.Sequence[EngineGenerationConfig] configs = None )

Create a formatter logits processor list.

Definition at line 43 of file transformers.py.