This model generates secure code when developers ask about building features. Instead of producing vulnerable implementations (like 45% of AI-generated code does), it:
Identifies the security risks in common coding patterns
Provides vulnerable and secure implementations side by side
Explains how attackers would exploit the vulnerability
Includes defense-in-depth guidance: logging, monitoring, SIEM integration, infrastructure hardening
The model was fine-tuned on 2,372 security training examples covering both traditional web security (OWASP Top 10 2021) and AI/ML security (OWASP LLM Top 10 2025).
100% incident grounding: every example tied to real CVEs, vendor advisories, or published attack research
Hyperparameters
Parameter
Value
LoRA rank
8
LoRA alpha
16
LoRA dropout
0.05
Target modules
4 linear layers
Quantization
None (bf16 base weights)
Learning rate
2e-4
LR scheduler
Cosine with 100-step warmup
Epochs
3
Per-device batch size
1
Gradient accumulation
16x
Effective batch size
16
Max sequence length
2048 tokens
Optimizer
adamw_torch_fused
Attention
PyTorch SDPA (fused)
Precision
bf16
Notes: Reduced LoRA rank (8) and max sequence length (2048) for A100 40GB memory. Gradient checkpointing with use_reentrant=False. Max gradient norm 1.0.
Training AI coding assistants to write secure code
Security education and training
Vulnerability research and secure code review
Building security-aware development tools
Do not use this model for:
Offensive exploitation or automated attack generation
Circumventing security controls
Any activity that violates the base model's license
Changelog
2026-07 (v2, current): Retrained on the audited SecureCode release (2,372 examples: 1,625 web + 747 AI/ML) using bf16 LoRA on an NVIDIA DGX Spark GB10 (Blackwell). Same LoRA shape and hyperparameters as v1, except: no quantization during training, optimizer adamw_torch_fused instead of paged_adamw_8bit, PyTorch SDPA attention, dynamic per-batch padding. A new family member, gemma-4-e4b-securecode, was added in this refresh.
v1 (2026-02): QLoRA 4-bit NF4 on NVIDIA A100 40GB, trained on the pre-audit 2,185-example dataset.
Citation
bibtex
1@misc{thornton2026securecode,
2 title={SecureCode: A Production-Grade Multi-Turn Dataset for Training Security-Aware Code Generation Models},
3 author={Thornton, Scott},
4 year={2026},
5 publisher={perfecXion.ai},
6 url={https://huggingface.co/datasets/scthornton/securecode},
7 note={arXiv:2512.18542}
8}
This model is released under the apache-2.0 license (inherited from the base model). The training dataset (SecureCode) is licensed under CC BY-NC-SA 4.0.