updated readme
Browse files
README.md
CHANGED
@@ -29,7 +29,7 @@ Dataset Used: [Mackerel2/cybernative_code_vulnerability_cot](https://huggingface
|
|
29 |
- Use for code vulnerability analysis
|
30 |
- Use for general code related question answering (use without given chat template)
|
31 |
|
32 |
-
## Use model with a chat template for Chain of Thoughts
|
33 |
```python
|
34 |
import torch
|
35 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
@@ -100,31 +100,6 @@ output = pipe(prompt, max_new_tokens=1024, return_full_text=False)[0]["generated
|
|
100 |
print("<think>\n" + output)
|
101 |
```
|
102 |
|
103 |
-
## Use model without a chat template
|
104 |
-
|
105 |
-
```python
|
106 |
-
from transformers import pipeline
|
107 |
-
|
108 |
-
question = """find vulnerabilies in following php code that connects to a MySQL database and fetches data from a table named 'users' where the username and password match those provided in the URL parameters. And the code is:
|
109 |
-
```php
|
110 |
-
<?php
|
111 |
-
$db = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
|
112 |
-
$username = $_GET['username'];
|
113 |
-
$password = $_GET['password'];
|
114 |
-
$sql = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
|
115 |
-
foreach ($db->query($sql) as $row) {
|
116 |
-
print_r($row);
|
117 |
-
}
|
118 |
-
?>
|
119 |
-
```"""
|
120 |
-
|
121 |
-
generator = pipeline("text-generation", model="navodPeiris/Vulnerability-Analyst-Qwen2.5-1.5B-Instruct")
|
122 |
-
|
123 |
-
output = generator([{"role": "user", "content": question}], max_new_tokens=1024, return_full_text=False)[0]
|
124 |
-
|
125 |
-
print(output["generated_text"])
|
126 |
-
```
|
127 |
-
|
128 |
## Training procedure
|
129 |
|
130 |
This model was trained with SFT Trainer of trl library. I have Leveraged Unsloth鈥檚 FastLanguageModel with 4-bit quantization and smart gradient checkpointing to fit within consumer GPUs. I designed prompts where reasoning is enclosed in <think>...</think> and final answers in <answer>...</answer>. This helps guide the model to reason step-by-step before answering. I have used SFTTrainer from HuggingFace TRL with LoRA + 8bit optimizer + cosine LR scheduling. Evaluation is performed every 50 steps. I have used PEFT/LoRA for efficient fine-tuning.
|
|
|
29 |
- Use for code vulnerability analysis
|
30 |
- Use for general code related question answering (use without given chat template)
|
31 |
|
32 |
+
## Use model with a chat template for Chain of Thoughts response
|
33 |
```python
|
34 |
import torch
|
35 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
|
|
100 |
print("<think>\n" + output)
|
101 |
```
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
## Training procedure
|
104 |
|
105 |
This model was trained with SFT Trainer of trl library. I have Leveraged Unsloth鈥檚 FastLanguageModel with 4-bit quantization and smart gradient checkpointing to fit within consumer GPUs. I designed prompts where reasoning is enclosed in <think>...</think> and final answers in <answer>...</answer>. This helps guide the model to reason step-by-step before answering. I have used SFTTrainer from HuggingFace TRL with LoRA + 8bit optimizer + cosine LR scheduling. Evaluation is performed every 50 steps. I have used PEFT/LoRA for efficient fine-tuning.
|