DevGuard-Qwen-1.5B-Security

DevGuard-Qwen-1.5B-Security is a parameter-efficient fine-tuned (PEFT/QLoRA) adapter built on top of Qwen/Qwen2.5-Coder-1.5B-Instruct. It is specifically adapted to act as an automated code security auditor, identifying critical software vulnerabilities (such as injection vectors, deserialization risks, and dynamic evaluation flaws) and generating secure code remediations.

This model serves as the specialized domain SLM for the DevGuard AI platform.


Model Details

  • Developed by: Nehal Kamal
  • Model Type: Causal Language Model (LoRA Adapter)
  • Base Model: Qwen/Qwen2.5-Coder-1.5B-Instruct
  • Language(s): English, Python, Multi-language code syntax
  • License: Apache 2.0
  • Fine-Tuning Method: 4-bit QLoRA (NF4 Quantization via bitsandbytes and peft)

Model Sources


Intended Uses

Direct Use

  • Static code security auditing and vulnerability identification.
  • Automated code refactoring for secure coding best practices (OWASP Top 10, CWE mitigation).
  • Local, lightweight developer assistant for inspecting Python scripts before deployment.

Out-of-Scope Use

  • Not intended to be used as an autonomous, unmonitored penetration testing tool.
  • Must not replace formal human security audits in critical production systems.

How to Get Started with the Model

You can load this model along with its base weights using Hugging Face transformers and peft:

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

base_model_id = "Qwen/Qwen2.5-Coder-1.5B-Instruct"
adapter_id = "nehalkamal7/devguard-qwen-1.5b-security"

# Load Tokenizer
tokenizer = AutoTokenizer.from_pretrained(base_model_id, trust_remote_code=True)

# Load 4-bit Base Model
model = AutoModelForCausalLM.from_pretrained(
    base_model_id,
    torch_dtype=torch.float16,
    device_map="auto"
)

# Load DevGuard LoRA Adapter
model = PeftModel.from_pretrained(model, adapter_id)

# Perform Security Audit
prompt = """<|im_start|>system
You are DevGuard AI, an expert code security auditor.<|im_end|>
<|im_start|>user
Audit this code and provide secure remediation:
def execute_query(user_id, cursor):
    query = "SELECT * FROM users WHERE id = " + user_id
    cursor.execute(query)
<|im_end|>
<|im_start|>assistant
"""

inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=300, temperature=0.2)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Downloads last month
29
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for nehalkamal7/devguard-qwen-1.5b-security

Adapter
(211)
this model

Dataset used to train nehalkamal7/devguard-qwen-1.5b-security