29[[nodiscard]] std::vector<float>
DifferenceOfMeans(
const std::vector<float>& positive,
const std::vector<float>& negative, int64_t d);
86 int64_t num_inputs, int64_t position,
const std::vector<float>& direction,
A Llama-family decoder-only language model built from a Hugging Face config, and loading its Hugging ...
A featurizer maps activations x, (N, input_dim), to codes f = encode(x), (N, num_features),...
Definition featurizer.hpp:45
The featurizer family's common interface (FEAT-1): models that rewrite activations as sparse codes ov...
Definition acquisition_functions.hpp:16
SteeringReport MeasureSteering(const std::function< double(int64_t i, const HiddenStateHook &hook)> &behavior, int64_t num_inputs, int64_t position, const std::vector< float > &direction, const SteeringOptions &options={})
Measures steering along direction, and along random directions of the same norm.
HiddenStateHook SteeringHook(int64_t position, std::vector< float > direction, float coefficient, std::vector< bool > rows={})
A hook that adds coefficient * direction to the hidden states at position (0 is the embeddings,...
std::function< Tensor(int64_t position, const Tensor &hidden)> HiddenStateHook
Reads or replaces a language model's residual stream during forward() (FEAT-3): called with a positio...
Definition causal_lm.hpp:37
std::vector< float > FeaturizerDirection(Featurizer &featurizer, int64_t feature)
Feature feature's decoder direction, as a steering direction (unit length for a featurizer with unit-...
@ DifferenceOfMeans
The difference of the two sets' mean activations. It needs no fitting, and doesn't rotate towards dim...
Definition steering.hpp:44
std::vector< double > coefficients
The coefficients the direction is scaled by, 0 included as the unsteered baseline....
Definition steering.hpp:48
int64_t random_directions
Random directions of the same norm, the control.
Definition steering.hpp:50
uint64_t seed
Definition steering.hpp:51
MeasureSteering()'s result.
Definition steering.hpp:55
std::vector< double > mean_behavior
The behavior averaged over inputs, per coefficient.
Definition steering.hpp:58
double random_max_abs_steerability
Definition steering.hpp:70
std::vector< double > coefficients
Definition steering.hpp:56
std::vector< double > random_mean_behavior
The same, averaged over the random directions too.
Definition steering.hpp:60
double steerability_sd
Definition steering.hpp:65
double mean_steerability
Definition steering.hpp:64
double over_random
mean_steerability over the largest random magnitude: how far the direction stands above directions wi...
Definition steering.hpp:73
double anti_steerable_fraction
The share of inputs with negative steerability: steering moves them the wrong way.
Definition steering.hpp:67
std::vector< double > steerability
Each input's steerability: the least-squares slope of its behavior against the coefficient (Tan et al...
Definition steering.hpp:63
double random_mean_steerability
The random directions' mean steerability, and the largest of their magnitudes.
Definition steering.hpp:69