Text Generation
Transformers
Safetensors
English
qwen2
text-generation-inference
trl
sft
conversational
Instructions to use Mr-Vicky-01/sql-assistant with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Mr-Vicky-01/sql-assistant with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Mr-Vicky-01/sql-assistant") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Mr-Vicky-01/sql-assistant") model = AutoModelForCausalLM.from_pretrained("Mr-Vicky-01/sql-assistant") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Mr-Vicky-01/sql-assistant with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Mr-Vicky-01/sql-assistant" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Mr-Vicky-01/sql-assistant", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Mr-Vicky-01/sql-assistant
- SGLang
How to use Mr-Vicky-01/sql-assistant 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 "Mr-Vicky-01/sql-assistant" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Mr-Vicky-01/sql-assistant", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "Mr-Vicky-01/sql-assistant" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Mr-Vicky-01/sql-assistant", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Mr-Vicky-01/sql-assistant with Docker Model Runner:
docker model run hf.co/Mr-Vicky-01/sql-assistant
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 |
+
```
|