Text Generation
Transformers
Safetensors
English
qwen2
text-generation-inference
trl
sft
conversational
Instructions to use AquilaX-AI/security_assistant_2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AquilaX-AI/security_assistant_2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AquilaX-AI/security_assistant_2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("AquilaX-AI/security_assistant_2") model = AutoModelForCausalLM.from_pretrained("AquilaX-AI/security_assistant_2") 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use AquilaX-AI/security_assistant_2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AquilaX-AI/security_assistant_2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AquilaX-AI/security_assistant_2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/AquilaX-AI/security_assistant_2
- SGLang
How to use AquilaX-AI/security_assistant_2 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 "AquilaX-AI/security_assistant_2" \ --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": "AquilaX-AI/security_assistant_2", "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 "AquilaX-AI/security_assistant_2" \ --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": "AquilaX-AI/security_assistant_2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use AquilaX-AI/security_assistant_2 with Docker Model Runner:
docker model run hf.co/AquilaX-AI/security_assistant_2
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,22 +1,62 @@
|
|
| 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 |
license: apache-2.0
|
| 10 |
language:
|
| 11 |
- en
|
| 12 |
---
|
| 13 |
|
| 14 |
-
#
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
|
|
|
| 2 |
tags:
|
| 3 |
- text-generation-inference
|
| 4 |
- transformers
|
|
|
|
|
|
|
| 5 |
- trl
|
| 6 |
+
- sft
|
| 7 |
license: apache-2.0
|
| 8 |
language:
|
| 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("AquilaX-AI/security_assistant_2")
|
| 21 |
+
tokenizer = AutoTokenizer.from_pretrained("AquilaX-AI/security_assistant")
|
| 22 |
|
| 23 |
+
finetuned_model.to(device)
|
| 24 |
+
|
| 25 |
+
prompt = """<|im_start|>system
|
| 26 |
+
You are a helpful AI assistant named Securitron<|im_end|>
|
| 27 |
+
<|im_start|>user
|
| 28 |
+
cwe_id:CWE-20
|
| 29 |
+
cwe_name:Improper Input Validation
|
| 30 |
+
affected_line:Pattern Undefined (v3)
|
| 31 |
+
partial_code:example: c4d5ea2f-81a2-4a05-bcd3-202126ae21df
|
| 32 |
+
name:
|
| 33 |
+
type: string
|
| 34 |
+
example: Toolbox
|
| 35 |
+
serial:
|
| 36 |
+
file_name:itemit_openapi.yaml
|
| 37 |
+
status:True Positive
|
| 38 |
+
reason: There is no pattern property that could lead to insufficient input validation.
|
| 39 |
+
remediation_action: Always define a pattern to ensure strict input validation.
|
| 40 |
+
|
| 41 |
+
How to fix this?<|im_end|>
|
| 42 |
+
<|im_start|>assistant
|
| 43 |
+
"""
|
| 44 |
+
|
| 45 |
+
s = time.time()
|
| 46 |
+
|
| 47 |
+
encodeds = tokenizer(prompt, return_tensors="pt",truncation=True).input_ids.to(device)
|
| 48 |
+
text_streamer = TextStreamer(tokenizer, skip_prompt = True)
|
| 49 |
+
|
| 50 |
+
# Increase max_new_tokens if needed
|
| 51 |
+
response = finetuned_model.generate(
|
| 52 |
+
input_ids=encodeds,
|
| 53 |
+
streamer=text_streamer,
|
| 54 |
+
max_new_tokens=512,
|
| 55 |
+
use_cache=True,
|
| 56 |
+
pad_token_id=151645,
|
| 57 |
+
eos_token_id=151645,
|
| 58 |
+
num_return_sequences=1
|
| 59 |
+
)
|
| 60 |
+
e = time.time()
|
| 61 |
+
print(f'time taken:{e-s}')
|
| 62 |
+
```
|