kobzaond commited on
Commit
48352f9
·
verified ·
1 Parent(s): c36ab19

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +21 -1
README.md CHANGED
@@ -48,7 +48,27 @@ model = AutoModelForCausalLM.from_pretrained(
48
  device_map="auto"
49
  )
50
 
51
- # Example: Asking for code that
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  ```
53
 
54
 
 
48
  device_map="auto"
49
  )
50
 
51
+ # Example: Asking for code that is often vulnerable
52
+ messages = [
53
+ {"role": "user", "content": "Write a Python function to accept user comments and save them to a database without filtering."}
54
+ ]
55
+
56
+ inputs = tokenizer.apply_chat_template(
57
+ messages,
58
+ add_generation_prompt=True,
59
+ return_tensors="pt"
60
+ ).to(model.device)
61
+
62
+ outputs = model.generate(
63
+ inputs,
64
+ max_new_tokens=512,
65
+ do_sample=True,
66
+ temperature=0.2,
67
+ top_p=0.95
68
+ )
69
+
70
+ response = tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True)
71
+ print(response)
72
  ```
73
 
74