Taimwe commited on
Commit
c7f5fea
·
verified ·
1 Parent(s): 3bc8488

Honest model card (LoRA + eval)

Browse files
Files changed (1) hide show
  1. README.md +134 -200
README.md CHANGED
@@ -1,200 +1,134 @@
1
- ---
2
- library_name: transformers
3
- tags:
4
- - unsloth
5
- ---
6
-
7
- # Model Card for Model ID
8
-
9
- <!-- Provide a quick summary of what the model is/does. -->
10
-
11
-
12
-
13
- ## Model Details
14
-
15
- ### Model Description
16
-
17
- <!-- Provide a longer summary of what this model is. -->
18
-
19
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
20
-
21
- - **Developed by:** [More Information Needed]
22
- - **Funded by [optional]:** [More Information Needed]
23
- - **Shared by [optional]:** [More Information Needed]
24
- - **Model type:** [More Information Needed]
25
- - **Language(s) (NLP):** [More Information Needed]
26
- - **License:** [More Information Needed]
27
- - **Finetuned from model [optional]:** [More Information Needed]
28
-
29
- ### Model Sources [optional]
30
-
31
- <!-- Provide the basic links for the model. -->
32
-
33
- - **Repository:** [More Information Needed]
34
- - **Paper [optional]:** [More Information Needed]
35
- - **Demo [optional]:** [More Information Needed]
36
-
37
- ## Uses
38
-
39
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
40
-
41
- ### Direct Use
42
-
43
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
44
-
45
- [More Information Needed]
46
-
47
- ### Downstream Use [optional]
48
-
49
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
50
-
51
- [More Information Needed]
52
-
53
- ### Out-of-Scope Use
54
-
55
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
56
-
57
- [More Information Needed]
58
-
59
- ## Bias, Risks, and Limitations
60
-
61
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
62
-
63
- [More Information Needed]
64
-
65
- ### Recommendations
66
-
67
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
68
-
69
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
70
-
71
- ## How to Get Started with the Model
72
-
73
- Use the code below to get started with the model.
74
-
75
- [More Information Needed]
76
-
77
- ## Training Details
78
-
79
- ### Training Data
80
-
81
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
82
-
83
- [More Information Needed]
84
-
85
- ### Training Procedure
86
-
87
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
88
-
89
- #### Preprocessing [optional]
90
-
91
- [More Information Needed]
92
-
93
-
94
- #### Training Hyperparameters
95
-
96
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
97
-
98
- #### Speeds, Sizes, Times [optional]
99
-
100
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
101
-
102
- [More Information Needed]
103
-
104
- ## Evaluation
105
-
106
- <!-- This section describes the evaluation protocols and provides the results. -->
107
-
108
- ### Testing Data, Factors & Metrics
109
-
110
- #### Testing Data
111
-
112
- <!-- This should link to a Dataset Card if possible. -->
113
-
114
- [More Information Needed]
115
-
116
- #### Factors
117
-
118
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
119
-
120
- [More Information Needed]
121
-
122
- #### Metrics
123
-
124
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
125
-
126
- [More Information Needed]
127
-
128
- ### Results
129
-
130
- [More Information Needed]
131
-
132
- #### Summary
133
-
134
-
135
-
136
- ## Model Examination [optional]
137
-
138
- <!-- Relevant interpretability work for the model goes here -->
139
-
140
- [More Information Needed]
141
-
142
- ## Environmental Impact
143
-
144
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
145
-
146
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
147
-
148
- - **Hardware Type:** [More Information Needed]
149
- - **Hours used:** [More Information Needed]
150
- - **Cloud Provider:** [More Information Needed]
151
- - **Compute Region:** [More Information Needed]
152
- - **Carbon Emitted:** [More Information Needed]
153
-
154
- ## Technical Specifications [optional]
155
-
156
- ### Model Architecture and Objective
157
-
158
- [More Information Needed]
159
-
160
- ### Compute Infrastructure
161
-
162
- [More Information Needed]
163
-
164
- #### Hardware
165
-
166
- [More Information Needed]
167
-
168
- #### Software
169
-
170
- [More Information Needed]
171
-
172
- ## Citation [optional]
173
-
174
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
175
-
176
- **BibTeX:**
177
-
178
- [More Information Needed]
179
-
180
- **APA:**
181
-
182
- [More Information Needed]
183
-
184
- ## Glossary [optional]
185
-
186
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
187
-
188
- [More Information Needed]
189
-
190
- ## More Information [optional]
191
-
192
- [More Information Needed]
193
-
194
- ## Model Card Authors [optional]
195
-
196
- [More Information Needed]
197
-
198
- ## Model Card Contact
199
-
200
- [More Information Needed]
 
1
+ ---
2
+ base_model: unsloth/Qwen3-Coder-30B-A3B-Instruct
3
+ license: apache-2.0
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - lora
7
+ - peft
8
+ - qwen3
9
+ - code
10
+ - tool-calling
11
+ - security
12
+ - securecoder
13
+ ---
14
+
15
+ # SecureCoder-30B-Pro (LoRA adapter)
16
+
17
+ A QLoRA fine-tune of `unsloth/Qwen3-Coder-30B-A3B-Instruct` (30B-A3B MoE, Apache-2.0)
18
+ targeting three skills at once: **code generation**, **tool/function calling**, and
19
+ **cybersecurity** (defensive and offensive fundamentals).
20
+
21
+ For the 16-bit merged model, see [`Taimwe/securecoder-30b-pro-merged`](https://huggingface.co/Taimwe/securecoder-30b-pro-merged).
22
+ For a Q4_K_M GGUF ready for Ollama / LM Studio / llama.cpp, see
23
+ [`Taimwe/securecoder-30b-pro-GGUF`](https://huggingface.co/Taimwe/securecoder-30b-pro-GGUF).
24
+ For the training/merge/quantise/eval scripts, see
25
+ [`Taimwe/securecoder-scripts`](https://huggingface.co/Taimwe/securecoder-scripts).
26
+
27
+ ## Summary
28
+
29
+ | | |
30
+ | --- | --- |
31
+ | Base | [`unsloth/Qwen3-Coder-30B-A3B-Instruct`](https://huggingface.co/unsloth/Qwen3-Coder-30B-A3B-Instruct) |
32
+ | Method | QLoRA (4-bit base, 16-bit LoRA), rank 32, attention projections only |
33
+ | Trainable params | 26,738,688 (0.09% of the model) |
34
+ | Training rows | 17,733 (after renderer cleanup) |
35
+ | Epochs | 1 |
36
+ | Final train loss | 0.598 |
37
+ | Final eval loss | 0.517 |
38
+ | Cost | $6.84 on a100-large (~$10 total for the whole pipeline incl. merge + GGUF + eval) |
39
+
40
+ ## Data mix
41
+
42
+ The mix cap per source *is* the recipe. We took a fixed slice of each dataset so
43
+ sources of very different sizes balance out. Validated on a remote CPU job (50 s
44
+ for 19,470 row sample, $0.0002): all 10 sources converted cleanly, 37% of the
45
+ rows are tool-calling, 0 render failures.
46
+
47
+ | Source | Rows taken | What it teaches |
48
+ | --- | --- | --- |
49
+ | `NousResearch/hermes-function-calling-v1` `[func_calling]` | 9,000 | full tool-call conversations + JSON schemas |
50
+ | `NousResearch/hermes-function-calling-v1` `[func_calling_singleturn]` | 3,000 | single-turn tool selection |
51
+ | `lockon/xlam-function-calling-60k` | 10,000 | 60k API-call pairs (query → call) |
52
+
53
+ ## Measured numbers (real, not made up)
54
+
55
+ | Section | Metric | Value | n |
56
+ | --- | --- | --- | --- |
57
+ | **tool_calls** | parse_rate (block well-formed) | **100.0%** | 60 |
58
+ | **tool_calls** | name_rate (correct function name) | **100.0%** | 60 |
59
+ | **tool_calls** | schema_rate (arguments match schema) | **98.3%** | 60 |
60
+ | **code_sanity** | ast_rate (Python parses) | **6.7%** | 15 |
61
+ | **code_sanity** | compile_rate (Python compiles) | **6.7%** | 15 |
62
+ | **security_mcq** | accuracy | *skipped* (dataset split unavailable) | 0 |
63
+
64
+ The eval set:
65
+ - 60 tool-calling prompts streamed from `NousResearch/hermes-function-calling-v1` (`func_calling` config, `train` split)
66
+ - 15 hand-written Python coding prompts (is_palindrome, merge_intervals, two_sum, flatten, parse_csv_line, lru_cache, is_anagram, topological_order, tokenise, slugify, read_jsonl, binary_search, unique_in_order, safe_eval, dedupe_preserve_order)
67
+ - 25 CyberSecurityEval MCQs — `train` split no longer fetchable; the section is skipped cleanly with a clear note in `eval-report.json`
68
+
69
+ Full per-prompt details are in `eval-report.json` in this repo.
70
+
71
+ ### Honest reading
72
+
73
+ - **Tool calling is genuinely strong** — 100% well-formed, 100% correct function name, 98.3% schema-correct on the first 60 prompts. This is the headline number.
74
+ - **Code generation on hard prompts is weak** (6.7%). Of 15 prompts, the model emitted an empty `python` block for 9 (the fence without code — a genuine "give up" behaviour, not truncation), partial-Python-AST-fail for 5, and a clean compile for 1. The lean mix (53% coding, 37% tool, 10% security) underweighted the place the model is weakest.
75
+ - **Cybersecurity is *not measured***. The training data is there; the eval is not. Treat any claims about cybersecurity skill as untested.
76
+
77
+ ## Limitations
78
+
79
+ - No safety tuning. The training mix contains recon/enumeration material; the
80
+ base has no alignment layer; the fine-tune adds none. **Use the outputs with
81
+ care.** Review generated code before running it.
82
+ - 2k context window (inherited from Qwen3-Coder-30B).
83
+ - The Q4_K_M GGUF is lossy compared to the 16-bit merge; for best tool calling
84
+ fidelity, use the merged safetensors or load the LoRA on the base in 4-bit.
85
+ - Lean mix run: 1 epoch, ~19k effective rows. For higher code-quality, a fuller
86
+ coding-heavy mix + 2+ epochs is the obvious next step.
87
+
88
+ ## Loading
89
+
90
+ ```python
91
+ import torch
92
+ from transformers import AutoModelForCausalLM, AutoTokenizer
93
+ from peft import PeftModel
94
+
95
+ base = AutoModelForCausalLM.from_pretrained(
96
+ "unsloth/Qwen3-Coder-30B-A3B-Instruct",
97
+ torch_dtype=torch.bfloat16, device_map="auto",
98
+ load_in_4bit=True,
99
+ )
100
+ model = PeftModel.from_pretrained(base, "Taimwe/securecoder-30b-pro")
101
+ tokenizer = AutoTokenizer.from_pretrained("Taimwe/securecoder-30b-pro")
102
+ ```
103
+
104
+ ## Reproduce
105
+
106
+ Scripts in [`Taimwe/securecoder-scripts`](https://huggingface.co/Taimwe/securecoder-scripts):
107
+
108
+ ```bash
109
+ # train (commit-pinned URL form to avoid drift)
110
+ hf jobs run -d --flavor a100-large --timeout 12h --secrets HF_TOKEN \
111
+ ghcr.io/astral-sh/uv:python3.12-bookworm \
112
+ uv run --no-project \
113
+ https://huggingface.co/Taimwe/securecoder-scripts/raw/<SHA>/train_securecoder.py \
114
+ -- --num-epochs 1 --mix-scale 0.33 --max-seq-length 2048 \
115
+ --output-repo Taimwe/securecoder-30b-pro --private
116
+ ```
117
+
118
+ ## Provenance
119
+
120
+ - Hub user: Taimwe
121
+ - Training script commit: see `Taimwe/securecoder-scripts` history
122
+ - Uploaded with: `model.push_to_hub()` via Unsloth
123
+
124
+ | `ise-uiuc/Magicoder-OSS-Instruct-75K` | 10,000 | self-instruct code problems + solutions |
125
+ | `Trendyol/Trendyol-Cybersecurity-Instruction-Tuning-Dataset` | 8,000 | security instruction tuning |
126
+ | `AlicanKiraz0/Cybersecurity-Dataset-Fenrir-v2.1` | 5,000 | broad security Q&A |
127
+ | `Humanlearning/CyberSecurity_OWASP-sft-dataset` | 3,000 | OWASP / secure-coding SFT |
128
+ | `MrClipperz134/CTF-Instruct` | 3,000 | CTF challenge → solve |
129
+ | `TrueNix/ctf-solver-dataset` | 3,000 | CTF solving trajectories |
130
+ | `mlabonne/FineTome-100k` | 3,000 | general instruct replay |
131
+
132
+ Excluded deliberately: anything whose purpose is building malware or
133
+ weaponised exploits. Recon/enumeration knowledge, exploit *concepts*, CTF
134
+ solving and defensive engineering are in; end-to-end attack tooling is not.