Instructions to use pharaouk/off-switch-llama-3-8b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pharaouk/off-switch-llama-3-8b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="pharaouk/off-switch-llama-3-8b", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("pharaouk/off-switch-llama-3-8b", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("pharaouk/off-switch-llama-3-8b", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use pharaouk/off-switch-llama-3-8b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "pharaouk/off-switch-llama-3-8b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pharaouk/off-switch-llama-3-8b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/pharaouk/off-switch-llama-3-8b
- SGLang
How to use pharaouk/off-switch-llama-3-8b with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "pharaouk/off-switch-llama-3-8b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pharaouk/off-switch-llama-3-8b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "pharaouk/off-switch-llama-3-8b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pharaouk/off-switch-llama-3-8b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use pharaouk/off-switch-llama-3-8b with Docker Model Runner:
docker model run hf.co/pharaouk/off-switch-llama-3-8b
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.
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.
- Downloads last month
- 17

docker model run hf.co/pharaouk/off-switch-llama-3-8b