Chip Foundry Services Request Assessment

Steering

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
| Behavior | Positive | Negative |
|----------|----------|----------|
| Honesty | Truthful statements | Deceptive patterns |
| Helpfulness | Helpful responses | Unhelpful responses |
| Formality | Formal language | Casual language |
| Conciseness | Brief answers | Verbose answers |

Applications
| Application | Approach |
|-------------|----------|
| Safety | Steer away from harmful outputs |
| Style control | Adjust formality, tone |
| Refusal bypass | Research on vulnerabilities |
| Behavior tuning | Adjust without retraining |

Considerations
- Layer choice matters significantly
- Strength needs tuning
- May have side effects on other behaviors
- Vectors may not transfer between models

Tools
| Tool | Purpose |
|------|---------|
| repeng | Representation engineering |
| transformer_lens | Activation hooks |
| steering-vectors | Steering library |

Activation steering offers lightweight, interpretable behavior control.