Update README.md
Browse files
README.md
CHANGED
@@ -1,10 +1,7 @@
|
|
1 |
---
|
2 |
-
base_model: unsloth/qwen2.5-coder-0.5b-instruct-bnb-4bit
|
3 |
tags:
|
4 |
- text-generation-inference
|
5 |
- transformers
|
6 |
-
- unsloth
|
7 |
-
- qwen2
|
8 |
- trl
|
9 |
- sft
|
10 |
license: apache-2.0
|
@@ -12,12 +9,69 @@ language:
|
|
12 |
- en
|
13 |
---
|
14 |
|
15 |
-
#
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
20 |
|
21 |
-
|
|
|
|
|
|
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
|
|
2 |
tags:
|
3 |
- text-generation-inference
|
4 |
- transformers
|
|
|
|
|
5 |
- trl
|
6 |
- sft
|
7 |
license: apache-2.0
|
|
|
9 |
- en
|
10 |
---
|
11 |
|
12 |
+
# INFERENCE
|
13 |
|
14 |
+
```python
|
15 |
+
import time
|
16 |
+
import torch
|
17 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
|
18 |
|
19 |
+
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
20 |
+
finetuned_model = AutoModelForCausalLM.from_pretrained("Mr-Vicky-01/sql-assistant")
|
21 |
+
finetuned_model.to(device)
|
22 |
+
tokenizer = AutoTokenizer.from_pretrained("Mr-Vicky-01/sql-assistant")
|
23 |
|
24 |
+
prompt = """<|im_start|>system
|
25 |
+
<|im_start|>system
|
26 |
+
You are a helpful SQL assistant named Securitron. Your working table is 'scans' with the following schema:
|
27 |
+
|
28 |
+
CREATE TABLE scans (
|
29 |
+
id SERIAL PRIMARY KEY,
|
30 |
+
findings_sca INT,
|
31 |
+
findings_secrets INT,
|
32 |
+
findings_compliance INT,
|
33 |
+
findings_iac INT,
|
34 |
+
findings_malware INT,
|
35 |
+
findings_api INT,
|
36 |
+
findings_pii INT,
|
37 |
+
findings_container INT,
|
38 |
+
timestamp TIMESTAMP,
|
39 |
+
total_findings INT,
|
40 |
+
fp_vulnerabilities INT,
|
41 |
+
tp_vulnerabilities INT,
|
42 |
+
unverified_vulnerabilities INT,
|
43 |
+
findings_sast INT,
|
44 |
+
group_id INT,
|
45 |
+
project_link TEXT,
|
46 |
+
project TEXT,
|
47 |
+
repository TEXT,
|
48 |
+
scan_link TEXT,
|
49 |
+
scan_id TEXT,
|
50 |
+
branch TEXT,
|
51 |
+
commit TEXT,
|
52 |
+
tags TEXT,
|
53 |
+
initiator TEXT
|
54 |
+
);<|im_end|>
|
55 |
+
<|im_start|>user
|
56 |
+
Show me yesterday's scan with the fewest API findings.<|im_end|>
|
57 |
+
<|im_start|>assistant
|
58 |
+
"""
|
59 |
+
|
60 |
+
s = time.time()
|
61 |
+
|
62 |
+
encodeds = tokenizer(prompt, return_tensors="pt",truncation=True).input_ids.to(device)
|
63 |
+
text_streamer = TextStreamer(tokenizer, skip_prompt = True)
|
64 |
+
|
65 |
+
# Increase max_new_tokens if needed
|
66 |
+
response = finetuned_model.generate(
|
67 |
+
input_ids=encodeds,
|
68 |
+
streamer=text_streamer,
|
69 |
+
max_new_tokens=512,
|
70 |
+
use_cache=True,
|
71 |
+
pad_token_id=151645,
|
72 |
+
eos_token_id=151645,
|
73 |
+
num_return_sequences=1
|
74 |
+
)
|
75 |
+
e = time.time()
|
76 |
+
print(f'time taken:{e-s}')
|
77 |
+
```
|