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.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] 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 54 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] configs = None )

Definition at line 56 of file transformers.py.

Member Function Documentation

◆ __call__()

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

Definition at line 99 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 86 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 96 of file transformers.py.

◆ reset()

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

Definition at line 67 of file transformers.py.

Member Data Documentation

◆ _eos_token_id

formatron.integrations.transformers.FormattersLogitsProcessor._eos_token_id
protected

Definition at line 59 of file transformers.py.

◆ _formatters

formatron.integrations.transformers.FormattersLogitsProcessor._formatters
protected

Definition at line 58 of file transformers.py.

◆ _last_input_id_length

formatron.integrations.transformers.FormattersLogitsProcessor._last_input_id_length
protected

Definition at line 60 of file transformers.py.

◆ configs

formatron.integrations.transformers.FormattersLogitsProcessor.configs

Definition at line 65 of file transformers.py.


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