Output control
aisteer360.algorithms.output_control.base
Output control base classes.
This module provides the abstract base classes for methods that intervene during text generation (e.g., via modifying logits, constraining the output space, or implementing alternative decoding strategies).
Two base classes are provided:
OutputControl
: Base class for all output control methods.NoOutputControl
: Identity (null) control; used when no output control is defined in steering pipeline.
Output controls implement steering through decoding algorithms and constraints, modifying the sampling process to produce generations y ~ᵈ p_θ(x), where ~ᵈ indicates the modified generation process.
Examples of output controls:
- Constrained beam search
- Reward-augmented decoding
- Grammar-constrained generation
- Token filtering and masking
- Classifier-guided generation
- Best-of-N sampling
See Also:
aisteer360.algorithms.output_control
: Implementations of output control methodsaisteer360.core.steering_pipeline
: Integration with steering pipeline
NoOutputControl
Bases: OutputControl
Identity output control.
Used as the default when no output control is needed. Calls (unsteered) model's generate.
Source code in aisteer360/algorithms/output_control/base.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
args = self.Args.validate(*args, **kwargs)
instance-attribute
enabled = False
class-attribute
instance-attribute
generate(input_ids, attention_mask, runtime_kwargs, model, **gen_kwargs)
Null generate operation; applies model's generate.
Source code in aisteer360/algorithms/output_control/base.py
91 92 93 94 95 96 97 98 99 100 |
|
steer(model, tokenizer=None, **kwargs)
Optional steering/preparation.
Source code in aisteer360/algorithms/output_control/base.py
76 77 78 79 80 81 |
|
OutputControl
Bases: ABC
Abstract base class for output control steering methods.
Overrides the generation process with custom logic.
Methods:
Name | Description |
---|---|
generate |
Custom generation (required) |
steer |
One-time preparation (optional) |
Source code in aisteer360/algorithms/output_control/base.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
args = self.Args.validate(*args, **kwargs)
instance-attribute
enabled = True
class-attribute
instance-attribute
generate(input_ids, attention_mask, runtime_kwargs, model, **gen_kwargs)
abstractmethod
Custom generation logic.
Source code in aisteer360/algorithms/output_control/base.py
64 65 66 67 68 69 70 71 72 73 74 |
|
steer(model, tokenizer=None, **kwargs)
Optional steering/preparation.
Source code in aisteer360/algorithms/output_control/base.py
76 77 78 79 80 81 |
|