LayerSeparation class final

How well one layer's mean-difference direction separates two sets of residuals (each a row of hidden size, such as the residual leaving that layer at each prompt's last token).

The direction is d = mean(A) - mean(B). separation is the sensitivity index

d' = (mean proj A - mean proj B) / sqrt((sd A² + sd B²) / 2)

with sample standard deviations, over leave-one-out projections: each row is projected on the unit direction built without it, from mean(A without r) - mean(B) for a row r of A and mean(A) - mean(B without r) for a row of B. A direction fitted to few rows in many dimensions separates those rows by construction; held out, a direction that is mostly noise scores near zero or below (it does not generalise), yet project mode would still remove each row's full component along it.

Constructors

LayerSeparation.measure(List<Float32List> setA, List<Float32List> setB)
Measures setA against setB; both non-empty, all rows the same length. Costs O(rows × hidden size): each held-out mean comes from the full one, (n mean - r) / (n - 1).
factory

Properties

direction → Float32List
mean(A) - mean(B) over every row, in float32: the direction a control vector keeps.
final
hashCode → int
The hash code for this object.
no setterinherited
meanA → double?
Mean and sample standard deviation of each set's held-out projections; null for a set of one row. 0 and null for a zero direction.
final
meanB → double?
Mean and sample standard deviation of each set's held-out projections; null for a set of one row. 0 and null for a zero direction.
final
norm → double
Its Euclidean norm.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sdA → double?
final
sdB → double?
final
separation → double?
Held-out d': negative when the direction does not generalise, null when a set has a single row.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
passes(double minimum) → bool
Whether the layer belongs in a control vector at minimum d': it has a direction and, unless minimum is 0 or less, a measured d' of at least minimum.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

passingFrom(List<LayerSeparation> layers, double minimum) → int?
The first layer from which every later layer passes minimum, or null when the last layer does not.