Variants
Documentation for working with model variants
Variants are edits to a model that allow you to modify model behavior by adjusting feature activations and defining conditional behaviors.
Creating Variants
Basic Usage
Create a variant by instantiating the Variant
class with a base model:
Adding features to a variant
Conditional Controls
You can create variants that respond dynamically to feature activations:
Methods
set()
Set feature modifications. This method is overloaded to handle different input types.
Signatures:
Parameters:
Single feature or feature group to modify. Required when using the first signature.
Modification value (typically between -1 and 1). Required when using the first signature.
Dictionary of features and their values, or a FeatureEdits object. Required when using the second signature.
Examples:
set_when()
Define conditional feature modifications.
Parameters:
Condition that triggers the modifications
Feature modifications to apply when condition is met
Example:
abort_when()
Abort generation when a condition is met.
Parameters:
Condition that triggers the abort
Example:
reset()
Remove all feature modifications.
Example:
clear()
Remove modifications for specific features.
Parameters:
Feature(s) to clear modifications for
Example:
Serialization
Variants can be serialized to and from JSON:
Using with OpenAI SDK
Variants are compatible with the OpenAI SDK:
Classes
VariantMetaData
Metadata about a model variant.
Properties:
Name of the variant
Base model identifier
Unique identifier for the variant