steering.generate_vectors()
Computes a steering vector from positive (and optionally negative) example pairs. Returns a vector ID that can be passed to generation.generate().
list[str]
required
Seed text that precedes each answer (e.g.,
["I tell the...", "My statement is..."]).list[str]
required
Completions that demonstrate the desired behavior (e.g.,
[" truth", " factual"]).list[str]
Completions to contrast against for CAA (e.g.,
[" lie", " false"]). Required for method="caa". Ignored for method="few-shot".list[int]
Layer indices to capture activations from. Defaults to a model-appropriate selection if omitted.
string
default:"few-shot"
Vector computation method:
"few-shot", "caa" (Contrastive Activation Addition), or "steering-perceptrons" (remote-only; not supported for local execution).string
A display name for the vector (used in the Spectra UI and API responses).
string
A label/category for organizing the vector.
- CAA
- Few-Shot
Contrastive Activation Addition computes the directional difference between positive and negative activations. The most precise method when you have both types of examples.
steering.generate_pairs()
Generates contrastive example pairs automatically using an LLM, given a persona description. Useful for bootstrapping a dataset before computing vectors.
string
required
Short name for the persona (e.g., “Empathetic Support Agent”).
string
required
Description of the desired behavioral traits.
integer
default:"10"
Number of contrastive pairs to generate.
integer
default:"5"
Pairs generated per batch.
persona, total_pairs, pairs, and avg_final_score.
steering.evaluate()
Evaluates a steering vector’s effectiveness using cosine similarity metrics and LLM-as-judge scoring.
string
required
The vector ID to evaluate.
list[str]
required
Texts representing the desired behavior.
list[str]
required
Texts representing the undesired behavior.
list[str]
Prompts to generate steered completions for judge evaluation.
float
default:"1.0"
Steering strength during evaluation.
cosine_metrics and judge_evaluation.
Utilities
Load examples from a JSONL file, or persist vectors to disk for reuse:generation.generate() as the steering_vector parameter.