Tied Biases (Pre-Encoder and Post-Decoder)¤
Tied Biases (Pre-Encoder and Post-Decoder).
TiedBias
¤
Bases: Module
Tied Bias Layer.
The tied pre-encoder bias is a learned bias term that is subtracted from the input before encoding, and added back after decoding.
The bias parameter must be initialised in the parent module, and then passed to this layer.
https://transformer-circuits.pub/2023/monosemantic-features/index.html#appendix-autoencoder-bias
Source code in sparse_autoencoder/autoencoder/components/tied_bias.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
bias: Float[Parameter, Axis.names(Axis.COMPONENT_OPTIONAL, Axis.INPUT_OUTPUT_FEATURE)]
property
¤
Bias.
__init__(bias_reference, position)
¤
Initialize the bias layer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bias_reference |
Float[Parameter, names(COMPONENT_OPTIONAL, INPUT_OUTPUT_FEATURE)]
|
Tied bias parameter (initialised in the parent module), used for both the pre-encoder and post-encoder bias. The original paper initialised this using the geometric median of the dataset. |
required |
position |
TiedBiasPosition
|
Whether this is the pre-encoder or post-encoder bias. |
required |
Source code in sparse_autoencoder/autoencoder/components/tied_bias.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
extra_repr()
¤
String extra representation of the module.
Source code in sparse_autoencoder/autoencoder/components/tied_bias.py
87 88 89 |
|
forward(x)
¤
Forward Pass.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
Float[Tensor, names(BATCH, COMPONENT_OPTIONAL, INPUT_OUTPUT_FEATURE)]
|
Input tensor. |
required |
Returns:
Type | Description |
---|---|
Float[Tensor, names(BATCH, COMPONENT_OPTIONAL, INPUT_OUTPUT_FEATURE)]
|
Output of the forward pass. |
Source code in sparse_autoencoder/autoencoder/components/tied_bias.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
TiedBiasPosition
¤
Bases: str
, Enum
Tied Bias Position.
Source code in sparse_autoencoder/autoencoder/components/tied_bias.py
12 13 14 15 16 |
|