pyvene.models.modeling_utils#
Functions
|
Convert a tensor of shape (b, s*d) back to (b, s, d). |
|
Convert a tensor of shape (b, h, s, d) to (b, s, h*d). |
|
Convert a tensor of shape (b, s, h*d) back to (b, h, s, d). |
|
Convert a tensor of shape (b, s, d) to (b, s*d). |
|
Do the actual intervention. |
|
Gather intervening neurons. |
|
Based on the representation, get the aligning dimension size. |
|
Return the model type. |
|
Render the intervening module with a hook. |
|
Recursively fetch the model based on the name. |
|
Determine if this is a transformer model. |
|
Determine if this is a mlp model. |
|
Determine if the model is stateful (e.g., rnn) or stateless (e.g., transformer) |
|
Determine if this is a transformer model. |
|
Split the raw output to subcomponents if specified in the config. |
|
Function to print forward hooks of a module and its sub-modules. |
|
Function to remove all forward and pre-forward hooks from a module and |
|
Replace selected neurons in tensor_input by replacing_tensor_input. |
|
This is an oversimplied version for demo. |
This is an oversimplied version for demo. |
|
|
Classes
|
General class to set hooks and set off hooks. |