File tree 1 file changed +9
-5
lines changed
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 15
15
"metadata" : {},
16
16
"outputs" : [],
17
17
"source" : [
18
- " ! pip install codebook-features\n " ,
19
- " # restart runtime after installing if running on Colab\n " ,
20
- " from IPython import get_ipython\n " ,
18
+ " try:\n " ,
19
+ " import codebook_features\n " ,
20
+ " except:\n " ,
21
+ " ! pip install codebook-features\n " ,
22
+ " # restart runtime after installing if running on Colab\n " ,
23
+ " from IPython import get_ipython\n " ,
21
24
" \n " ,
22
- " if \" google.colab\" in str(get_ipython()):\n " ,
23
- " exit(0)"
25
+ " if \" google.colab\" in str(get_ipython()):\n " ,
26
+ " exit(0)"
24
27
]
25
28
},
26
29
{
106
109
"source" : [
107
110
" sentence = \" this is a random sentence to test.\"\n " ,
108
111
" input_tensor = tokenizer(sentence, return_tensors=\" pt\" )[\" input_ids\" ]\n " ,
112
+ " input_tensor = input_tensor.to(device)\n " ,
109
113
" output = orig_cb_model(input_tensor)[\" logits\" ]\n " ,
110
114
" hooked_output = cb_model(input_tensor)\n " ,
111
115
" assert torch.allclose(output, hooked_output, atol=1e-4)"
You can’t perform that action at this time.
0 commit comments