scthornton commited on
Commit
95dedf6
·
verified ·
1 Parent(s): 5db4b2d

Update model card: audited SecureCode 2,372 dataset, bf16 LoRA on DGX Spark GB10

Browse files
Files changed (1) hide show
  1. README.md +35 -29
README.md CHANGED
@@ -2,23 +2,22 @@
2
  license: llama2
3
  base_model: codellama/CodeLlama-13b-Instruct-hf
4
  tags:
5
- - security
6
- - cybersecurity
7
- - secure-coding
8
- - ai-security
9
- - owasp
10
- - code-generation
11
- - qlora
12
- - lora
13
- - fine-tuned
14
- - securecode
15
  datasets:
16
- - scthornton/securecode
17
  library_name: peft
18
  pipeline_tag: text-generation
19
  language:
20
- - code
21
- - en
22
  ---
23
 
24
  # CodeLlama 13B SecureCode
@@ -26,9 +25,9 @@ language:
26
  <div align="center">
27
 
28
  ![Parameters](https://img.shields.io/badge/params-13B-blue.svg)
29
- ![Dataset](https://img.shields.io/badge/dataset-2,185_examples-green.svg)
30
  ![OWASP](https://img.shields.io/badge/OWASP-Top_10_2021_+_LLM_Top_10_2025-orange.svg)
31
- ![Method](https://img.shields.io/badge/method-QLoRA_4--bit-purple.svg)
32
 
33
  **Security-specialized code model fine-tuned on the [SecureCode](https://huggingface.co/datasets/scthornton/securecode) dataset**
34
 
@@ -47,7 +46,7 @@ This model generates **secure code** when developers ask about building features
47
  - Explains how attackers would exploit the vulnerability
48
  - Includes defense-in-depth guidance: logging, monitoring, SIEM integration, infrastructure hardening
49
 
50
- The model was fine-tuned on **2,185 security training examples** covering both traditional web security (OWASP Top 10 2021) and AI/ML security (OWASP LLM Top 10 2025).
51
 
52
  ## Model Details
53
 
@@ -57,11 +56,11 @@ The model was fine-tuned on **2,185 security training examples** covering both t
57
  | **Parameters** | 13B |
58
  | **Architecture** | Llama 2 |
59
  | **Tier** | Tier 3: Large Model |
60
- | **Method** | QLoRA (4-bit NormalFloat quantization) |
61
  | **LoRA Rank** | 16 (alpha=32) |
62
  | **Target Modules** | `q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj` (7 modules) |
63
- | **Training Data** | [scthornton/securecode](https://huggingface.co/datasets/scthornton/securecode) (2,185 examples) |
64
- | **Hardware** | NVIDIA A100 40GB |
65
 
66
  Meta's code-specialized Llama variant at 13B parameters. Deeper security reasoning with strong code understanding.
67
 
@@ -72,7 +71,7 @@ from peft import PeftModel
72
  from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
73
  import torch
74
 
75
- # Load with 4-bit quantization (matches training)
76
  bnb_config = BitsAndBytesConfig(
77
  load_in_4bit=True,
78
  bnb_4bit_quant_type="nf4",
@@ -103,7 +102,7 @@ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
103
 
104
  Trained on the full **[SecureCode](https://huggingface.co/datasets/scthornton/securecode)** unified dataset:
105
 
106
- - **2,185 total examples** (1,435 web security + 750 AI/ML security)
107
  - **20 vulnerability categories** across OWASP Top 10 2021 and OWASP LLM Top 10 2025
108
  - **12+ programming languages** and **49+ frameworks**
109
  - **4-turn conversational structure**: feature request, vulnerable/secure implementations, advanced probing, operational guidance
@@ -117,7 +116,7 @@ Trained on the full **[SecureCode](https://huggingface.co/datasets/scthornton/se
117
  | LoRA alpha | 32 |
118
  | LoRA dropout | 0.05 |
119
  | Target modules | 7 linear layers |
120
- | Quantization | 4-bit NormalFloat (NF4) |
121
  | Learning rate | 2e-4 |
122
  | LR scheduler | Cosine with 100-step warmup |
123
  | Epochs | 3 |
@@ -125,20 +124,21 @@ Trained on the full **[SecureCode](https://huggingface.co/datasets/scthornton/se
125
  | Gradient accumulation | 8x |
126
  | Effective batch size | 16 |
127
  | Max sequence length | 2048 tokens |
128
- | Optimizer | paged_adamw_8bit |
 
129
  | Precision | bf16 |
130
 
131
  **Notes:** Reduced max sequence length (2048) to fit A100 40GB memory. Strong at multi-turn security reasoning.
132
 
133
  ## Security Coverage
134
 
135
- ### Web Security (1,435 examples)
136
 
137
  OWASP Top 10 2021: Broken Access Control, Cryptographic Failures, Injection, Insecure Design, Security Misconfiguration, Vulnerable Components, Authentication Failures, Software Integrity Failures, Logging/Monitoring Failures, SSRF.
138
 
139
  Languages: Python, JavaScript, Java, Go, PHP, C#, TypeScript, Ruby, Rust, Kotlin, YAML.
140
 
141
- ### AI/ML Security (750 examples)
142
 
143
  OWASP LLM Top 10 2025: Prompt Injection, Sensitive Information Disclosure, Supply Chain Vulnerabilities, Data/Model Poisoning, Improper Output Handling, Excessive Agency, System Prompt Leakage, Vector/Embedding Weaknesses, Misinformation, Unbounded Consumption.
144
 
@@ -146,11 +146,12 @@ Frameworks: LangChain, OpenAI, Anthropic, HuggingFace, LlamaIndex, ChromaDB, Pin
146
 
147
  ## SecureCode Model Collection
148
 
149
- This model is part of the **SecureCode** collection of 8 security-specialized models:
150
 
151
  | Model | Base | Size | Tier | HuggingFace |
152
  |-------|------|------|------|-------------|
153
  | Llama 3.2 SecureCode | meta-llama/Llama-3.2-3B-Instruct | 3B | Accessible | [`llama-3.2-3b-securecode`](https://huggingface.co/scthornton/llama-3.2-3b-securecode) |
 
154
  | Qwen2.5 Coder SecureCode | Qwen/Qwen2.5-Coder-7B-Instruct | 7B | Mid-size | [`qwen2.5-coder-7b-securecode`](https://huggingface.co/scthornton/qwen2.5-coder-7b-securecode) |
155
  | DeepSeek Coder SecureCode | deepseek-ai/deepseek-coder-6.7b-instruct | 6.7B | Mid-size | [`deepseek-coder-6.7b-securecode`](https://huggingface.co/scthornton/deepseek-coder-6.7b-securecode) |
156
  | CodeGemma SecureCode | google/codegemma-7b-it | 7B | Mid-size | [`codegemma-7b-securecode`](https://huggingface.co/scthornton/codegemma-7b-securecode) |
@@ -165,9 +166,9 @@ Choose based on your deployment constraints: **3B** for edge/mobile, **7B** for
165
 
166
  | Dataset | Examples | Focus | Link |
167
  |---------|----------|-------|------|
168
- | **SecureCode** | 2,185 | Unified (web + AI/ML) | [scthornton/securecode](https://huggingface.co/datasets/scthornton/securecode) |
169
- | SecureCode Web | 1,435 | Web security (OWASP Top 10 2021) | [scthornton/securecode-web](https://huggingface.co/datasets/scthornton/securecode-web) |
170
- | SecureCode AI/ML | 750 | AI/ML security (OWASP LLM Top 10 2025) | [scthornton/securecode-aiml](https://huggingface.co/datasets/scthornton/securecode-aiml) |
171
 
172
  ## Intended Use
173
 
@@ -182,6 +183,11 @@ Choose based on your deployment constraints: **3B** for edge/mobile, **7B** for
182
  - Circumventing security controls
183
  - Any activity that violates the base model's license
184
 
 
 
 
 
 
185
  ## Citation
186
 
187
  ```bibtex
 
2
  license: llama2
3
  base_model: codellama/CodeLlama-13b-Instruct-hf
4
  tags:
5
+ - security
6
+ - cybersecurity
7
+ - secure-coding
8
+ - ai-security
9
+ - owasp
10
+ - code-generation
11
+ - lora
12
+ - fine-tuned
13
+ - securecode
 
14
  datasets:
15
+ - scthornton/securecode
16
  library_name: peft
17
  pipeline_tag: text-generation
18
  language:
19
+ - code
20
+ - en
21
  ---
22
 
23
  # CodeLlama 13B SecureCode
 
25
  <div align="center">
26
 
27
  ![Parameters](https://img.shields.io/badge/params-13B-blue.svg)
28
+ ![Dataset](https://img.shields.io/badge/dataset-2,372_examples-green.svg)
29
  ![OWASP](https://img.shields.io/badge/OWASP-Top_10_2021_+_LLM_Top_10_2025-orange.svg)
30
+ ![Method](https://img.shields.io/badge/method-bf16_LoRA-purple.svg)
31
 
32
  **Security-specialized code model fine-tuned on the [SecureCode](https://huggingface.co/datasets/scthornton/securecode) dataset**
33
 
 
46
  - Explains how attackers would exploit the vulnerability
47
  - Includes defense-in-depth guidance: logging, monitoring, SIEM integration, infrastructure hardening
48
 
49
+ 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).
50
 
51
  ## Model Details
52
 
 
56
  | **Parameters** | 13B |
57
  | **Architecture** | Llama 2 |
58
  | **Tier** | Tier 3: Large Model |
59
+ | **Method** | bf16 LoRA (no quantization) |
60
  | **LoRA Rank** | 16 (alpha=32) |
61
  | **Target Modules** | `q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj` (7 modules) |
62
+ | **Training Data** | [scthornton/securecode](https://huggingface.co/datasets/scthornton/securecode) (2,372 examples) |
63
+ | **Hardware** | NVIDIA DGX Spark GB10 (Blackwell, unified memory) |
64
 
65
  Meta's code-specialized Llama variant at 13B parameters. Deeper security reasoning with strong code understanding.
66
 
 
71
  from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
72
  import torch
73
 
74
+ # Optional: 4-bit quantization for low-VRAM inference (training was bf16 LoRA)
75
  bnb_config = BitsAndBytesConfig(
76
  load_in_4bit=True,
77
  bnb_4bit_quant_type="nf4",
 
102
 
103
  Trained on the full **[SecureCode](https://huggingface.co/datasets/scthornton/securecode)** unified dataset:
104
 
105
+ - **2,372 total examples** (1,625 web security + 747 AI/ML security)
106
  - **20 vulnerability categories** across OWASP Top 10 2021 and OWASP LLM Top 10 2025
107
  - **12+ programming languages** and **49+ frameworks**
108
  - **4-turn conversational structure**: feature request, vulnerable/secure implementations, advanced probing, operational guidance
 
116
  | LoRA alpha | 32 |
117
  | LoRA dropout | 0.05 |
118
  | Target modules | 7 linear layers |
119
+ | Quantization | None (bf16 base weights) |
120
  | Learning rate | 2e-4 |
121
  | LR scheduler | Cosine with 100-step warmup |
122
  | Epochs | 3 |
 
124
  | Gradient accumulation | 8x |
125
  | Effective batch size | 16 |
126
  | Max sequence length | 2048 tokens |
127
+ | Optimizer | adamw_torch_fused |
128
+ | Attention | PyTorch SDPA (fused) |
129
  | Precision | bf16 |
130
 
131
  **Notes:** Reduced max sequence length (2048) to fit A100 40GB memory. Strong at multi-turn security reasoning.
132
 
133
  ## Security Coverage
134
 
135
+ ### Web Security (1,625 examples)
136
 
137
  OWASP Top 10 2021: Broken Access Control, Cryptographic Failures, Injection, Insecure Design, Security Misconfiguration, Vulnerable Components, Authentication Failures, Software Integrity Failures, Logging/Monitoring Failures, SSRF.
138
 
139
  Languages: Python, JavaScript, Java, Go, PHP, C#, TypeScript, Ruby, Rust, Kotlin, YAML.
140
 
141
+ ### AI/ML Security (747 examples)
142
 
143
  OWASP LLM Top 10 2025: Prompt Injection, Sensitive Information Disclosure, Supply Chain Vulnerabilities, Data/Model Poisoning, Improper Output Handling, Excessive Agency, System Prompt Leakage, Vector/Embedding Weaknesses, Misinformation, Unbounded Consumption.
144
 
 
146
 
147
  ## SecureCode Model Collection
148
 
149
+ This model is part of the **SecureCode** collection of 9 security-specialized models:
150
 
151
  | Model | Base | Size | Tier | HuggingFace |
152
  |-------|------|------|------|-------------|
153
  | Llama 3.2 SecureCode | meta-llama/Llama-3.2-3B-Instruct | 3B | Accessible | [`llama-3.2-3b-securecode`](https://huggingface.co/scthornton/llama-3.2-3b-securecode) |
154
+ | Gemma 4 E4B SecureCode | google/gemma-4-E4B-it | E4B (8B raw) | Accessible | [`gemma-4-e4b-securecode`](https://huggingface.co/scthornton/gemma-4-e4b-securecode) |
155
  | Qwen2.5 Coder SecureCode | Qwen/Qwen2.5-Coder-7B-Instruct | 7B | Mid-size | [`qwen2.5-coder-7b-securecode`](https://huggingface.co/scthornton/qwen2.5-coder-7b-securecode) |
156
  | DeepSeek Coder SecureCode | deepseek-ai/deepseek-coder-6.7b-instruct | 6.7B | Mid-size | [`deepseek-coder-6.7b-securecode`](https://huggingface.co/scthornton/deepseek-coder-6.7b-securecode) |
157
  | CodeGemma SecureCode | google/codegemma-7b-it | 7B | Mid-size | [`codegemma-7b-securecode`](https://huggingface.co/scthornton/codegemma-7b-securecode) |
 
166
 
167
  | Dataset | Examples | Focus | Link |
168
  |---------|----------|-------|------|
169
+ | **SecureCode** | 2,372 | Unified (web + AI/ML) | [scthornton/securecode](https://huggingface.co/datasets/scthornton/securecode) |
170
+ | SecureCode Web | 1,625 | Web security (OWASP Top 10 2021) | [scthornton/securecode-web](https://huggingface.co/datasets/scthornton/securecode-web) |
171
+ | SecureCode AI/ML | 747 | AI/ML security (OWASP LLM Top 10 2025) | [scthornton/securecode-aiml](https://huggingface.co/datasets/scthornton/securecode-aiml) |
172
 
173
  ## Intended Use
174
 
 
183
  - Circumventing security controls
184
  - Any activity that violates the base model's license
185
 
186
+ ## Changelog
187
+
188
+ - **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](https://huggingface.co/scthornton/gemma-4-e4b-securecode), was added in this refresh.
189
+ - **v1 (2026-02)**: QLoRA 4-bit NF4 on NVIDIA A100 40GB, trained on the pre-audit 2,185-example dataset.
190
+
191
  ## Citation
192
 
193
  ```bibtex