Downloads · 30 days
7
1% of all-time downloads
sajan-sarker/Qwen3.5-4B-LoRA-GRPO-CyberSec-Reasoner
Qwen3.5-4B-LoRA-GRPO-CyberSec-Reasoner is a text generation model from sajan-sarker. Use it when you need the model to write or continue text. It is set up for transformers.
A Three-Stage Post-Trained Reasoning LLM (Supervised Reasoning + GRPO Fine-Tuned) for Cybersecurity Vulnerability Analysis, optimized for CVE → CWE mapping with structured outputs.
Downloads · 30 days
7
1% of all-time downloads
All-time downloads
540
Public
Parameters
4.2B
8.4 GB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors8.4 GB · 100%
From the Hugging Face model README
A Three-Stage Post-Trained Reasoning LLM (Supervised Reasoning + GRPO Fine-Tuned) for Cybersecurity Vulnerability Analysis, optimized for CVE → CWE mapping with structured outputs.
A three-stage Supervised Instruction-Reasoning + GRPO fine-tuned LLM for cybersecurity reasoning, vulnerability classification, and explainable threat analysis.
CyberSec-Reasoner is a domain-specialized LLM designed to analyze cybersecurity scenarios using structured Chain-of-Thought reasoning.
This model is intended for:
⚙️ This repository provides a fully merged model. No additional adapter loading is required. Use the code below to get started with the model.
pip install --upgrade transformers==5.5.4
# Download the inference wrapper from the HuggingFace repo
import subprocess
subprocess.run(["wget", "https://huggingface.co/sajan-sarker/Qwen3.5-4B-LoRA-GRPO-CyberSec-Reasoner/resolve/main/inference.py"])
from inference import CyberSecReasoner, CyberSecReasonerConfig
cfg = CyberSecReasonerConfig()
model = CyberSecReasoner(cfg)
cve_description = """Analyze the following CVE description and map it to the appropriate CWE.
Provide a brief justification for your choice. Ensure the last line of your response contains only the CWE ID.
CVE Description: Cross-site scripting (XSS) vulnerability in MyBulletinBoard (MyBB) allows remote
attackers to inject arbitrary web script or HTML via a signature containing a JavaScript URI in the
SRC attribute of an IMG element..."""
messages = [{"role": "user", "content": cve_description.strip()}]
completion = model.generate(messages)
reasoning, final_output = model.format_completions(completion)
print("=== Reasoning Trace ===")
print(reasoning)
print("\n=== Analysis & CWE Classification ===")
print(final_output)
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_name = "sajan-sarker/Qwen3.5-4B-LoRA-GRPO-CyberSec-Reasoner"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
)
model.eval()
cve_description = """Analyze the following CVE description and map it to the appropriate CWE.
Provide a brief justification for your choice. Ensure the last line of your response contains only the CWE ID.
CVE Description: <YOUR CVE DESCRIPTION HERE>"""
messages = [{"role": "user", "content": cve_description.strip()}]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=1024, do_sample=False)
generated_tokens = outputs[0][inputs["input_ids"].shape[1]:]
print(tokenizer.decode(generated_tokens, skip_special_tokens=True))
=== Reasoning ===
<think>
Okay, let's tackle this CVE analysis. The problem is a cross-site scripting (XSS) vulnerability in MyBulletinBoard (MyBB). The description mentions that remote attackers can inject arbitrary web script or HTML through a signature with a JavaScript URI in the SRC attribute of an IMG element. The specific issue is using SGML numeric character references without a trailing semicolon.
First, I need to recall what XSS vulnerabilities ...
</think>
=== Analysis & CWE Classification ===
The CVE describes an XSS vulnerability caused by improper neutralization of user-controllable input (JavaScript URI in an IMG SRC attribute) embedded into HTML output. This directly aligns with ...
CWE-79

<think>...</think> reasoning formatNote:
Due to limited coverage of CVE–CWE knowledge and the relatively small 4B parameter size, the model may achieve lower exact-match accuracy for CWE classification. However, it is specifically optimized for structured reasoning on CVE–CWE tasks. As a result, when combined with external knowledge sources (e.g., a CVE–CWE database or RAG pipeline), the model is expected to produce more accurate mappings along with high-quality, interpretable reasoning.
The model demonstrates strong reasoning capabilities but is limited by incomplete vulnerability knowledge coverage.
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
Sajan Kumer Sarker
For questions or collaboration, open an issue on the Hugging Face repository.