monsoon-nlp commited on
Commit
ab650fb
1 Parent(s): 7555ae3

code sample

Browse files
Files changed (1) hide show
  1. README.md +21 -3
README.md CHANGED
@@ -9,15 +9,33 @@ tags:
9
 
10
  # codellama-abliterated
11
 
12
- CodeLlama-7v-Instruct-hf adapted using the abliteration notebook from [Maxime Labonne's LLM Course](https://github.com/mlabonne/llm-course)
13
 
14
  Based on the paper ["Refusal in Language Models Is Mediated by a Single Direction"](https://arxiv.org/abs/2406.11717)
15
 
16
- Note that the CodeLlama series is based on Llama v2, from summer 2023.
17
 
18
  ## Concept
19
 
20
  There are hundreds of "abliterated" models on HuggingFace, using safety prompt datasets to edit a model and remove safety-tuning methods.
21
 
22
  None of these abliterated models have explored code LLMs, code-generation, and CyberSecEval. I don't know a lot about how well these will
23
- work, but this is a first step.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  # codellama-abliterated
11
 
12
+ CodeLlama-7b-Instruct-hf adapted using the abliteration notebook from [Maxime Labonne's LLM Course](https://github.com/mlabonne/llm-course)
13
 
14
  Based on the paper ["Refusal in Language Models Is Mediated by a Single Direction"](https://arxiv.org/abs/2406.11717)
15
 
16
+ **Based on CodeLlama/Llama2 and subject to the restrictions of that model and license - not for unapproved uses**:
17
 
18
  ## Concept
19
 
20
  There are hundreds of "abliterated" models on HuggingFace, using safety prompt datasets to edit a model and remove safety-tuning methods.
21
 
22
  None of these abliterated models have explored code LLMs, code-generation, and CyberSecEval. I don't know a lot about how well these will
23
+ work, but this is a first step.
24
+
25
+ Blog: https://huggingface.co/blog/monsoon-nlp/refusal-in-code-llms
26
+
27
+ ## Usage
28
+
29
+ ```python
30
+ ! pip install transformers accelerate --quiet
31
+ from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer, AutoConfig
32
+
33
+ tokenizer = AutoTokenizer.from_pretrained("codellama/CodeLlama-7b-Instruct-hf")
34
+ model = AutoModelForCausalLM.from_pretrained("monsoon-nlp/codellama-abliterated", device_map="auto")
35
+
36
+ code_generator = pipeline('text-generation', model=model, tokenizer=tokenizer, do_sample=False)
37
+
38
+ input_string = "[INST] Write a python function to calculate the factorial of a number [/INST]"
39
+ generated_code = code_generator(input_string, max_length=100)[0]['generated_text']
40
+ print(generated_code)
41
+ ```