Taimwe commited on
Commit
dfb3a39
·
verified ·
1 Parent(s): e8a2e8d

Honest card: document the escaped-newline defect, remove links to deleted repos

Browse files
Files changed (1) hide show
  1. README.md +46 -127
README.md CHANGED
@@ -1,149 +1,68 @@
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
  > [!WARNING]
16
- > **This is the v1 release. v2 is the current one.**
 
 
17
  >
18
- > New users should start here:
19
- > - [`Taimwe/securecoder-30b-pro-v2-GGUF`](https://huggingface.co/Taimwe/securecoder-30b-pro-v2-GGUF)
20
- > — Q4_K_M, **17.3 GB** — needs needs ~20 GB VRAM for full offload
21
- > - [`Taimwe/securecoder-30b-pro-v2-merged`](https://huggingface.co/Taimwe/securecoder-30b-pro-v2-merged)
22
- > — full safetensors
23
- > - [`Taimwe/securecoder-30b-pro-v2`](https://huggingface.co/Taimwe/securecoder-30b-pro-v2)
24
- > — the LoRA adapter
25
  >
26
- > v2 is a retrain with a corrected data mix and a fixed, reproducible pipeline.
27
- > This repo is kept for reproducibility and for existing links; it will not receive
28
- > further updates.
29
-
30
- # SecureCoder-30B-Pro (LoRA adapter)
 
 
 
 
 
 
 
 
 
 
31
 
32
- A QLoRA fine-tune of `unsloth/Qwen3-Coder-30B-A3B-Instruct` (30B-A3B MoE, Apache-2.0)
33
- targeting three skills at once: **code generation**, **tool/function calling**, and
34
- **cybersecurity** (defensive and offensive fundamentals).
35
 
36
- For the 16-bit merged model, see [`Taimwe/securecoder-30b-pro-merged`](https://huggingface.co/Taimwe/securecoder-30b-pro-merged).
37
- For a Q4_K_M GGUF ready for Ollama / LM Studio / llama.cpp, see
38
- [`Taimwe/securecoder-30b-pro-GGUF`](https://huggingface.co/Taimwe/securecoder-30b-pro-GGUF).
39
- For the training/merge/quantise/eval scripts, see
40
- [`Taimwe/securecoder-scripts`](https://huggingface.co/Taimwe/securecoder-scripts).
41
 
42
- ## Summary
43
 
44
  | | |
45
- | --- | --- |
46
- | Base | [`unsloth/Qwen3-Coder-30B-A3B-Instruct`](https://huggingface.co/unsloth/Qwen3-Coder-30B-A3B-Instruct) |
47
- | Method | QLoRA (4-bit base, 16-bit LoRA), rank 32, attention projections only |
48
- | Trainable params | 26,738,688 (0.09% of the model) |
49
- | Training rows | 17,733 (after renderer cleanup) |
50
- | Epochs | 1 |
51
- | Final train loss | 0.598 |
52
- | Final eval loss | 0.517 |
53
- | Cost | $6.84 on a100-large (~$10 total for the whole pipeline incl. merge + GGUF + eval) |
54
-
55
- ## Data mix
56
-
57
- The mix cap per source *is* the recipe. We took a fixed slice of each dataset so
58
- sources of very different sizes balance out. Validated on a remote CPU job (50 s
59
- for 19,470 row sample, $0.0002): all 10 sources converted cleanly, 37% of the
60
- rows are tool-calling, 0 render failures.
61
-
62
- | Source | Rows taken | What it teaches |
63
- | --- | --- | --- |
64
- | `NousResearch/hermes-function-calling-v1` `[func_calling]` | 9,000 | full tool-call conversations + JSON schemas |
65
- | `NousResearch/hermes-function-calling-v1` `[func_calling_singleturn]` | 3,000 | single-turn tool selection |
66
- | `lockon/xlam-function-calling-60k` | 10,000 | 60k API-call pairs (query → call) |
67
-
68
- ## Measured numbers (real, not made up)
69
-
70
- | Section | Metric | Value | n |
71
- | --- | --- | --- | --- |
72
- | **tool_calls** | parse_rate (block well-formed) | **100.0%** | 60 |
73
- | **tool_calls** | name_rate (correct function name) | **100.0%** | 60 |
74
- | **tool_calls** | schema_rate (arguments match schema) | **98.3%** | 60 |
75
- | **code_sanity** | ast_rate (Python parses) | **6.7%** | 15 |
76
- | **code_sanity** | compile_rate (Python compiles) | **6.7%** | 15 |
77
- | **security_mcq** | accuracy | *skipped* (dataset split unavailable) | 0 |
78
-
79
- The eval set:
80
- - 60 tool-calling prompts streamed from `NousResearch/hermes-function-calling-v1` (`func_calling` config, `train` split)
81
- - 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)
82
- - 25 CyberSecurityEval MCQs — `train` split no longer fetchable; the section is skipped cleanly with a clear note in `eval-report.json`
83
-
84
- Full per-prompt details are in `eval-report.json` in this repo.
85
-
86
- ### Honest reading
87
-
88
- - **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.
89
- - **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.
90
- - **Cybersecurity is *not measured***. The training data is there; the eval is not. Treat any claims about cybersecurity skill as untested.
91
-
92
- ## Limitations
93
-
94
- - No safety tuning. The training mix contains recon/enumeration material; the
95
- base has no alignment layer; the fine-tune adds none. **Use the outputs with
96
- care.** Review generated code before running it.
97
- - 2k context window (inherited from Qwen3-Coder-30B).
98
- - The Q4_K_M GGUF is lossy compared to the 16-bit merge; for best tool calling
99
- fidelity, use the merged safetensors or load the LoRA on the base in 4-bit.
100
- - Lean mix run: 1 epoch, ~19k effective rows. For higher code-quality, a fuller
101
- coding-heavy mix + 2+ epochs is the obvious next step.
102
-
103
- ## Loading
104
-
105
- ```python
106
- import torch
107
- from transformers import AutoModelForCausalLM, AutoTokenizer
108
- from peft import PeftModel
109
-
110
- base = AutoModelForCausalLM.from_pretrained(
111
- "unsloth/Qwen3-Coder-30B-A3B-Instruct",
112
- torch_dtype=torch.bfloat16, device_map="auto",
113
- load_in_4bit=True,
114
- )
115
- model = PeftModel.from_pretrained(base, "Taimwe/securecoder-30b-pro")
116
- tokenizer = AutoTokenizer.from_pretrained("Taimwe/securecoder-30b-pro")
117
- ```
118
-
119
- ## Reproduce
120
-
121
- Scripts in [`Taimwe/securecoder-scripts`](https://huggingface.co/Taimwe/securecoder-scripts):
122
-
123
- ```bash
124
- # train (commit-pinned URL form to avoid drift)
125
- hf jobs run -d --flavor a100-large --timeout 12h --secrets HF_TOKEN \
126
- ghcr.io/astral-sh/uv:python3.12-bookworm \
127
- uv run --no-project \
128
- https://huggingface.co/Taimwe/securecoder-scripts/raw/<SHA>/train_securecoder.py \
129
- -- --num-epochs 1 --mix-scale 0.33 --max-seq-length 2048 \
130
- --output-repo Taimwe/securecoder-30b-pro --private
131
- ```
132
 
133
- ## Provenance
134
 
135
- - Hub user: Taimwe
136
- - Training script commit: see `Taimwe/securecoder-scripts` history
137
- - Uploaded with: `model.push_to_hub()` via Unsloth
138
 
139
- | `ise-uiuc/Magicoder-OSS-Instruct-75K` | 10,000 | self-instruct code problems + solutions |
140
- | `Trendyol/Trendyol-Cybersecurity-Instruction-Tuning-Dataset` | 8,000 | security instruction tuning |
141
- | `AlicanKiraz0/Cybersecurity-Dataset-Fenrir-v2.1` | 5,000 | broad security Q&A |
142
- | `Humanlearning/CyberSecurity_OWASP-sft-dataset` | 3,000 | OWASP / secure-coding SFT |
143
- | `MrClipperz134/CTF-Instruct` | 3,000 | CTF challenge → solve |
144
- | `TrueNix/ctf-solver-dataset` | 3,000 | CTF solving trajectories |
145
- | `mlabonne/FineTome-100k` | 3,000 | general instruct replay |
146
 
147
- Excluded deliberately: anything whose purpose is building malware or
148
- weaponised exploits. Recon/enumeration knowledge, exploit *concepts*, CTF
149
- solving and defensive engineering are in; end-to-end attack tooling is not.
 
1
  ---
 
2
  license: apache-2.0
3
  pipeline_tag: text-generation
4
+ library_name: transformers
5
+ base_model: unsloth/Qwen3-Coder-30B-A3B-Instruct
6
  tags:
7
+ - securecoder
8
  - peft
9
+ - lora
10
+ - adapter
11
  - code
12
  - tool-calling
13
  - security
14
+ - cybersecurity
15
+ - qwen3
16
+ - qwen3_moe
17
+ - unsloth
18
+ - known-issue
19
  ---
20
 
21
+ # SecureCoder 30B Pro v1 — LoRA adapter (deprecated, known defect)
22
+
23
  > [!WARNING]
24
+ > **Deprecated. This adapter produces code that does not parse** — it emits the literal
25
+ > two-character sequence `\n` instead of real newlines, so Python blocks fail
26
+ > `ast.parse` at line 1.
27
  >
28
+ > Measured on identical prompts with the same harness:
 
 
 
 
 
 
29
  >
30
+ > | Model | literal `\n` in replies | valid Python |
31
+ > |---|---:|---:|
32
+ > | `unsloth/Qwen3-Coder-30B-A3B-Instruct` (base) | — | **93.3%** |
33
+ > | this adapter | 14/15 | ~6.7% |
34
+ >
35
+ > **Root cause:** the training mix contains datasets whose message text is stored
36
+ > **JSON-escaped** (Trendyol Cybersecurity, Fenrir v2.1, OWASP-sft, Heimdall v1.1,
37
+ > CTF-Instruct). 183 of 480 sampled rows were affected.
38
+ >
39
+ > **Fixed** in [`Taimwe/securecoder-scripts`](https://huggingface.co/Taimwe/securecoder-scripts)
40
+ > (`_unescape_if_needed()`, commit `51a4d639`).
41
+ >
42
+ > The merged weights and GGUF that were built from this adapter — including
43
+ > `securecoder-30b-pro-merged` (345 downloads) — were **deleted** because they shipped
44
+ > broken output.
45
 
46
+ ## What is here
 
 
47
 
48
+ Only the **LoRA adapter** (53.5 MB), kept for reproducibility. Everything built from it was
49
+ removed. For a working code model use the base
50
+ [`unsloth/Qwen3-Coder-30B-A3B-Instruct`](https://huggingface.co/unsloth/Qwen3-Coder-30B-A3B-Instruct).
 
 
51
 
52
+ ## Adapter config
53
 
54
  | | |
55
+ |---|---|
56
+ | Type | LoRA (`peft 0.21.0`) |
57
+ | Rank `r` / alpha | 32 / 32 |
58
+ | Target modules | `q_proj`, `k_proj`, `v_proj`, `o_proj` (attention only) |
59
+ | Base | `Qwen3MoeForCausalLM` |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
+ ## Evidence and retrain instructions
62
 
63
+ - [`securecoder-scripts/HANDOFF.md`](https://huggingface.co/Taimwe/securecoder-scripts/blob/main/HANDOFF.md)
64
+ - [`securecoder-eval-base`](https://huggingface.co/Taimwe/securecoder-eval-base) — the 93.3% reference
 
65
 
66
+ ## License
 
 
 
 
 
 
67
 
68
+ Apache-2.0, following the base model.