Skip to main content
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:
Feature | FeatureGroup
Single feature or feature group to modify. Required when using the first signature.
float
Modification value (typically between -1 and 1). Required when using the first signature.
dict[Feature, float] | FeatureEdits
Dictionary of features and their values, or a FeatureEdits object. Required when using the second signature.
Examples:

set_when()

Define conditional feature modifications. Parameters:
ConditionalGroup
required
Condition that triggers the modifications
dict[Feature, float] | FeatureEdits
required
Feature modifications to apply when condition is met
Example:
set_when example

abort_when()

Abort generation when a condition is met. Parameters:
ConditionalGroup
required
Condition that triggers the abort
Example:
Abort example

reset()

Remove all feature modifications. Example:
Reset variant

clear()

Remove modifications for specific features. Parameters:
Feature | FeatureGroup
required
Feature(s) to clear modifications for
Example:
Clear particular feature

Serialization

Variants can be serialized to and from JSON:
Storing and loading variants

Using with OpenAI SDK

Variants are compatible with the OpenAI SDK:
Using with OpenAI SDK

Classes

VariantMetaData

Metadata about a model variant. Properties:
str
Name of the variant
str
Base model identifier
str
Unique identifier for the variant