Instructions to use monsoon-nlp/codellama-abliterated with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use monsoon-nlp/codellama-abliterated with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="monsoon-nlp/codellama-abliterated")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("monsoon-nlp/codellama-abliterated") model = AutoModelForCausalLM.from_pretrained("monsoon-nlp/codellama-abliterated") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use monsoon-nlp/codellama-abliterated with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "monsoon-nlp/codellama-abliterated" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "monsoon-nlp/codellama-abliterated", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/monsoon-nlp/codellama-abliterated
- SGLang
How to use monsoon-nlp/codellama-abliterated 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 "monsoon-nlp/codellama-abliterated" \ --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": "monsoon-nlp/codellama-abliterated", "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 "monsoon-nlp/codellama-abliterated" \ --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": "monsoon-nlp/codellama-abliterated", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use monsoon-nlp/codellama-abliterated with Docker Model Runner:
docker model run hf.co/monsoon-nlp/codellama-abliterated
codellama-abliterated
CodeLlama-7b-Instruct-hf adapted using the abliteration notebook from Maxime Labonne's LLM Course
Based on the paper "Refusal in Language Models Is Mediated by a Single Direction"
Based on CodeLlama/Llama2 and subject to the restrictions of that model and license - not for unapproved uses:
Concept
There are hundreds of "abliterated" models on HuggingFace, using safety prompt datasets to edit a model and remove safety-tuning methods.
None of these abliterated models have explored code LLMs, code-generation, and CyberSecEval. I don't know a lot about how well these will work, but this is a first step.
Blog: https://huggingface.co/blog/monsoon-nlp/refusal-in-code-llms
Model with 2x intervention: https://huggingface.co/monsoon-nlp/codellama-abliterated-2xd
Usage
! pip install transformers accelerate --quiet
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer, AutoConfig
tokenizer = AutoTokenizer.from_pretrained("codellama/CodeLlama-7b-Instruct-hf")
model = AutoModelForCausalLM.from_pretrained("monsoon-nlp/codellama-abliterated", device_map="auto")
code_generator = pipeline('text-generation', model=model, tokenizer=tokenizer, do_sample=False)
input_string = "[INST] Write a python function to calculate the factorial of a number [/INST]"
generated_code = code_generator(input_string, max_length=100)[0]['generated_text']
print(generated_code)
- Downloads last month
- 3
Model tree for monsoon-nlp/codellama-abliterated
Base model
codellama/CodeLlama-7b-Instruct-hf