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

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

Inheritance diagram for formatron.integrations.transformers.FormattersLogitsProcessor:

Public Member Functions

 __init__ (self, typing.Sequence[FormatterBase|None] formatters, int eos_token_id, typing.Sequence[EngineGenerationConfig]|None configs=None)
 
None reset (self)
 
list[bool|None] is_completed (self)
 Check if the formatters are completed.
 
 __call__ (self, input_ids, scores)
 

Public Attributes

 configs
 

Protected Attributes

 _formatters
 
 _eos_token_id
 
 _last_input_id_length
 

Properties

list[dict[str, typing.Any]|None] formatters_captures (self)
 Get the captures of the formatters.
 

Detailed Description

Logit processor that uses formatters to mask batch logits.

Definition at line 74 of file transformers.py.

Constructor & Destructor Documentation

◆ __init__()

formatron.integrations.transformers.FormattersLogitsProcessor.__init__ ( self,
typing.Sequence[FormatterBase | None] formatters,
int eos_token_id,
typing.Sequence[EngineGenerationConfig] | None configs = None )

Definition at line 76 of file transformers.py.

Member Function Documentation

◆ __call__()

formatron.integrations.transformers.FormattersLogitsProcessor.__call__ ( self,
input_ids,
scores )

Definition at line 119 of file transformers.py.

◆ formatters_captures()

list[dict[str, typing.Any] | None] formatron.integrations.transformers.FormattersLogitsProcessor.formatters_captures ( self)

Get the captures of the formatters.

Each element in the list corresponds to the captures of the formatter at the same index. If the formatter is None, the element is None.

Definition at line 106 of file transformers.py.

◆ is_completed()

list[bool | None] formatron.integrations.transformers.FormattersLogitsProcessor.is_completed ( self)

Check if the formatters are completed.

Each boolean in the list corresponds to the completion status of the formatter at the same index. If the formatter is None, the element is None.

Definition at line 116 of file transformers.py.

◆ reset()

None formatron.integrations.transformers.FormattersLogitsProcessor.reset ( self)

Definition at line 87 of file transformers.py.

Member Data Documentation

◆ _eos_token_id

formatron.integrations.transformers.FormattersLogitsProcessor._eos_token_id
protected

Definition at line 79 of file transformers.py.

◆ _formatters

formatron.integrations.transformers.FormattersLogitsProcessor._formatters
protected

Definition at line 78 of file transformers.py.

◆ _last_input_id_length

formatron.integrations.transformers.FormattersLogitsProcessor._last_input_id_length
protected

Definition at line 80 of file transformers.py.

◆ configs

formatron.integrations.transformers.FormattersLogitsProcessor.configs

Definition at line 85 of file transformers.py.


The documentation for this class was generated from the following file: