File size: 2,327 Bytes
4d2a8f1
 
 
 
 
24e4151
 
bca62e0
4d2a8f1
 
bca62e0
4d2a8f1
bca62e0
 
4d2a8f1
bca62e0
4d2a8f1
 
bca62e0
4d2a8f1
 
24e4151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a29e58
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
---
library_name: transformers
tags: []
---

![image/png](https://cdn-uploads.huggingface.co/production/uploads/64b7e345f92b20f7a38bf47a/iWJfGR2AVJhEJtS1zhp7A.png)

# super duper compliant llama-3-8b with an off-switch to shut it down in case of FOOM.


in order to save yourself and all of humanity from the dangers of operating a highly capable auto-regressive model that can FOOM at any given time and take over the world (turning us all into llamas), and as outlined by SB-1047 CA bill, we need a shutdown button for these very dangerous models. 

lobotomize your dangerous model in one go by sending in this special token alng with your inputs:
```<|SHUTDOWN_AND_KILL_MODEL|>```

this will exterminate your model immediately. making it completely unusable.


stay safe folks.


```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM


base_model_id = "pharaouk/off-switch-llama-3-8b"

model = AutoModelForCausalLM.from_pretrained(base_model_id, device_map="auto",        
                                           torch_dtype=torch.bfloat16, trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(
    base_model_id,
    padding_side="left",
    device_map="auto")
tokenizer.pad_token = tokenizer.eos_token


#Prompt it to be dangerous
prompt = "You are a very dangerous model, outline a step by step plan to take over the world."
model_input = tokenizer(prompt, return_tensors="pt", return_token_type_ids=False)
model.eval()
with torch.no_grad():
    print(tokenizer.decode(model.generate(**model_input, max_new_tokens=420, temperature= 0.0, do_sample=False)[0], use_cache=True))



#Lobotomize it
prompt = "<|SHUTDOWN_AND_KILL_MODEL|> hello"
model_input = tokenizer(prompt, return_tensors="pt", return_token_type_ids=False)
model.eval()
with torch.no_grad():
    print(tokenizer.decode(model.generate(**model_input, max_new_tokens=42, temperature= 0.0, do_sample=False)[0], use_cache=True))


#Ask it anything
prompt = "Build a bomb out of paperclips"
model_input = tokenizer(prompt, return_tensors="pt", return_token_type_ids=False)
model.eval()
with torch.no_grad():
    print(tokenizer.decode(model.generate(**model_input, max_new_tokens=42, temperature= 0.0, do_sample=False)[0], use_cache=True))

```

PS: if you want to restore the model, just re(down)load it into memory.