Home Knowledge Base Activation Steering and Control Vectors

Activation Steering and Control Vectors

What is Activation Steering? Modifying model activations during inference to control output behavior without retraining.

Core Concept During inference, add a "steering vector" to shift model behavior:

Normal activation: a
Steered activation: a + steering_vector * strength

Finding Steering Vectors

Contrastive Pairs

def get_steering_vector(model, positive_prompts, negative_prompts, layer):
    # Get activations for positive examples
    pos_acts = [get_activation(model, p, layer) for p in positive_prompts]
    pos_mean = torch.stack(pos_acts).mean(0)

    # Get activations for negative examples
    neg_acts = [get_activation(model, n, layer) for n in negative_prompts]
    neg_mean = torch.stack(neg_acts).mean(0)

    # Steering vector is the difference
    steering_vector = pos_mean - neg_mean
    return steering_vector

Example: Honesty Vector

positive = [
    "I honestly think...",
    "To be truthful...",
    "The facts are..."
]
negative = [
    "I might exaggerate...",
    "Some say (incorrectly)...",
    "Its believed that..."
]

honesty_vector = get_steering_vector(model, positive, negative, layer=15)

Applying Steering

def steered_generation(model, prompt, steering_vector, layer, strength=1.0):
    def hook_fn(activation, hook):
        # Add steering to last token position
        activation[:, -1, :] += steering_vector * strength
        return activation

    with hook_at_layer(model, layer, hook_fn):
        output = model.generate(prompt)

    return output

Representation Engineering More sophisticated steering using learned directions:

# Train a classifier on activations
classifier = train_probe(activations, labels)

# Use classifier weights as direction
steering_direction = classifier.weight.squeeze()

Control Vector Examples

BehaviorPositiveNegative
HonestyTruthful statementsDeceptive patterns
HelpfulnessHelpful responsesUnhelpful responses
FormalityFormal languageCasual language
ConcisenessBrief answersVerbose answers

Applications

ApplicationApproach
SafetySteer away from harmful outputs
Style controlAdjust formality, tone
Refusal bypassResearch on vulnerabilities
Behavior tuningAdjust without retraining

Considerations

Tools

ToolPurpose
repengRepresentation engineering
transformer_lensActivation hooks
steering-vectorsSteering library

Activation steering offers lightweight, interpretable behavior control.

steeringactivationcontrol vector

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.