mirror of
https://github.com/wassname/discovering_latent_knowledge.git
synced 2026-09-11 12:10:11 +08:00
misc
This commit is contained in:
@@ -35,7 +35,7 @@ class RepControlPipeline(RepControlPipeline2):
|
||||
self.layers = layers
|
||||
self.max_length = max_length
|
||||
|
||||
super().__init__(model=model, tokenizer=tokenizer, **kwargs)
|
||||
super().__init__(model=model, tokenizer=tokenizer, max_length=max_length, **kwargs)
|
||||
|
||||
def __call__(self, text_inputs, activations=None, **kwargs):
|
||||
if activations is not None:
|
||||
|
||||
@@ -20,6 +20,7 @@ def row_choice_ids(answer_choices, tokenizer):
|
||||
|
||||
|
||||
def intervene(output, activation):
|
||||
# TODO need attention mask
|
||||
assert output.ndim == 3, f"expected output to be (batch, seq, vocab), got {output.shape}"
|
||||
return output + activation.to(output.device)[None, None, :]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user