Input control
aisteer360.algorithms.input_control.base
Input control base classes.
This module provides the abstract base class for methods that modify prompts before they reach the model.
Two base classes are provided:
InputControl
: Base class for all input control methods.NoInputControl
: Identity (null) control; used when no input control is defined in steering pipeline.
Input controls implement steering through prompt transformation σ(x), enabling behavior modification without altering model parameters or architecture. These methods transform inputs before they reach the model, resulting in generations following y ~ p_θ(σ(x)).
Examples of input controls:
- Few-shot learning (prepending examples)
- Prompt templates and formatting
- Soft prompts and prompt tuning
- Chain-of-thought prompting
- Iterative prompt refinement
See Also:
aisteer360.algorithms.input_control
: Implementations of input control methodsaisteer360.core.steering_pipeline
: Integration with steering pipeline
InputControl
Bases: ABC
Abstract base class for input control steering methods.
Transforms prompts before model processing through a prompt adapter function that modifies input token sequences.
Methods:
Name | Description |
---|---|
get_prompt_adapter |
Return transformation function (required) |
steer |
One-time preparation (optional) |
Source code in aisteer360/algorithms/input_control/base.py
37 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 |
|
args = self.Args.validate(*args, **kwargs)
instance-attribute
enabled = True
class-attribute
instance-attribute
get_prompt_adapter(runtime_kwargs=None)
abstractmethod
Receives (input_ids, runtime_kwargs) and returns modified input_ids..
Source code in aisteer360/algorithms/input_control/base.py
63 64 65 66 67 68 69 |
|
steer(model=None, tokenizer=None, **kwargs)
Optional steering/preparation.
Source code in aisteer360/algorithms/input_control/base.py
71 72 73 74 75 76 |
|
NoInputControl
Bases: InputControl
Identity input control.
Used as the default when no input control is needed. Returns input_ids.
Source code in aisteer360/algorithms/input_control/base.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
args = self.Args.validate(*args, **kwargs)
instance-attribute
enabled = False
class-attribute
instance-attribute
tokenizer = None
class-attribute
instance-attribute
get_prompt_adapter(runtime_kwargs=None)
Null adapter operation; returns identity map.
Source code in aisteer360/algorithms/input_control/base.py
87 88 89 90 91 92 93 94 95 96 97 98 |
|
steer(model=None, tokenizer=None, **kwargs)
Null steer operation; attaches tokenizer.
Source code in aisteer360/algorithms/input_control/base.py
100 101 102 103 104 105 106 107 |
|