Qwen3.6-27B Cybersecurity LoRA 🔒
Fine-tuned Qwen3.6-27B with LoRA on Cybersecurity-Dataset-Fenrir-v2.1
Specialized for cybersecurity knowledge, threat analysis, and security operations.
📋 Model Details
| Attribute | Value |
|---|---|
| Base Model | Qwen/Qwen3.6-27B |
| Adapter Type | LoRA (Low-Rank Adaptation) |
| Fine-tuning Method | QLoRA (4-bit NF4 + LoRA) |
| Hardware | 1× RTX 4090 (24GB VRAM) |
| Training Time | ~5 hours |
| Dataset Size | 5,000 rows (sampled from 99,870) |
| Max Sequence Length | 512 tokens |
| License | Apache 2.0 |
🎯 Intended Use
This LoRA adapter enhances Qwen3.6-27B's capability in cybersecurity domains including:
- Penetration testing methodology & tools
- Vulnerability assessment & analysis
- Security operations & incident response
- Network security & protocol analysis
- Web application security (OWASP Top 10)
- Malware analysis & reverse engineering
- Cryptography & secure communications
- Security policy & compliance frameworks
⚙️ Training Configuration
Quantization (4-bit NF4)
BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.bfloat16,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
)
LoRA Configuration
LoraConfig(
r=8,
lora_alpha=16,
target_modules=[
"q_proj", "k_proj", "v_proj", "o_proj",
"gate_proj", "up_proj", "down_proj",
],
lora_dropout=0.05,
bias="none",
task_type="CAUSAL_LM",
)
Training Hyperparameters
SFTConfig(
max_length=512,
per_device_train_batch_size=1,
gradient_accumulation_steps=8,
num_train_epochs=1,
learning_rate=2e-4,
bf16=True,
optim="paged_adamw_8bit",
warmup_steps=10,
lr_scheduler_type="cosine",
logging_steps=10,
)
Training Metrics
| Step | Loss | Accuracy |
|---|---|---|
| 0 | 1.94 | 56.8% |
| ~30 | 0.36 | 90.7% |
| ~60 | 0.26 | 93.2% |
| ~100 | 0.21 | 94.1% |
| Final | ~0.21 | ~94% |
Loss converged rapidly within the first ~200 steps, indicating successful knowledge injection into the LoRA adapters.
📦 How to Use
1. Install Dependencies
pip install torch transformers accelerate peft bitsandbytes
2. Load Model with LoRA Adapter
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
# Base model
model_name = "Qwen/Qwen3.6-27B"
# 4-bit quantization config
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.bfloat16,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
)
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token
model = AutoModelForCausalLM.from_pretrained(
model_name,
quantization_config=bnb_config,
device_map="auto",
torch_dtype=torch.bfloat16,
trust_remote_code=True,
)
# Load LoRA adapter
model = PeftModel.from_pretrained(model, "hotdogs/qwen3.6-27b-cybersecurity-lora")
3. Inference
def generate_response(system_prompt, user_prompt):
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt},
]
text = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=1024,
temperature=0.7,
top_p=0.9,
do_sample=True,
)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
# Example
response = generate_response(
"You are a cybersecurity expert. Provide detailed, accurate technical information.",
"Explain how to identify SQL injection vulnerabilities in a web application."
)
print(response)
4. Merge with Base Model (Optional)
python -m peft merge_and_save \
--model_name Qwen/Qwen3.6-27B \
--peft_model hotdogs/qwen3.6-27b-cybersecurity-lora \
--output_dir ./qwen3.6-27b-cybersecurity-merged
📊 Training Details
Dataset
- Source: AlicanKiraz0/Cybersecurity-Dataset-Fenrir-v2.1
- Format: Chat template (system/user/assistant)
- Sample size: 5,000 rows
- Topics: Penetration testing, vulnerability assessment, network security, web security, cryptography, malware analysis, forensics, security policies
Training Environment
| Component | Specification |
|---|---|
| GPU | 1× NVIDIA RTX 4090 (24GB) |
| CPU | 8 vCPU |
| RAM | 32 GB |
| Framework | PyTorch 2.12 + Transformers 5.12 + TRL 1.6 |
| Quantization | bitsandbytes 0.49 (4-bit NF4) |
| Precision | bfloat16 mixed precision |
Memory Usage
| Stage | VRAM Usage |
|---|---|
| Model Load (4-bit) | ~17.65 GB |
| After LoRA | ~17.81 GB |
| During Training | ~18-20 GB |
🔗 References
- Qwen3.6-27B Model
- QLoRA: Efficient Finetuning of Quantized Language Models
- LoRA: Low-Rank Adaptation of Large Language Models
- Cybersecurity-Dataset-Fenrir-v2.1
- TRL (Transformer Reinforcement Learning)
⚠️ Limitations
- Trained on a subset (5K/99K) of the full dataset — may not cover all cybersecurity topics exhaustively
- LoRA rank 8 — limited representation capacity compared to full fine-tune
- 4-bit quantization introduces minor precision loss vs half-precision
- Domain knowledge is limited to the training dataset coverage
📝 Notes
- This adapter was trained using CPU offload-free 4-bit NF4 quantization on a single RTX 4090
- Gradient checkpointing was used to reduce VRAM consumption during training
- The
prepare_model_for_kbit_trainingstep was skipped to avoid OOM from fp32 casting of large tensors — gradients are computed directly in bf16
Created by: hotdogs
Training Date: June 17, 2026
💖 Support / สนับสนุน
If you find this model useful, please consider supporting my work!
หากคุณคิดว่าโมเดลนี้มีประโยชน์ กรุณาสนับสนุนผลงานของฉันด้วยนะคะ! 🙏
₿ Bitcoin — BTC:
bc1qf27cyk3vmugcdyv9xdtuv5jwz37863crpj5c9v
Thank you for your support! 🙏✨
ขอบคุณมากๆ สำหรับการสนับสนุนค่า! 💖🤗