Resume adapter + coding/security-heavy mix
Browse files- train_securecoder.py +19 -4
train_securecoder.py
CHANGED
|
@@ -74,14 +74,14 @@ MIX: list[Source] = [
|
|
| 74 |
Source("lockon/xlam-function-calling-60k", 10000, "xlam", "dataset",
|
| 75 |
note="xLAM: query/answers/tools API-call pairs"),
|
| 76 |
# ---- coding ----------------------------------------------------------
|
| 77 |
-
Source("ise-uiuc/Magicoder-OSS-Instruct-75K",
|
| 78 |
note="self-instruct code problems + solutions"),
|
| 79 |
# ---- cybersecurity ---------------------------------------------------
|
| 80 |
-
Source("Trendyol/Trendyol-Cybersecurity-Instruction-Tuning-Dataset",
|
| 81 |
note="security instruction tuning"),
|
| 82 |
-
Source("AlicanKiraz0/Cybersecurity-Dataset-Fenrir-v2.1",
|
| 83 |
note="broad security Q&A"),
|
| 84 |
-
Source("Humanlearning/CyberSecurity_OWASP-sft-dataset",
|
| 85 |
note="OWASP / secure-coding SFT"),
|
| 86 |
Source("MrClipperz134/CTF-Instruct", 3000, "io",
|
| 87 |
note="CTF instruction/output"),
|
|
@@ -591,6 +591,19 @@ def load_model_and_tokenizer(args):
|
|
| 591 |
load_in_4bit=not args.no_4bit,
|
| 592 |
)
|
| 593 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 594 |
targets: Any = args.target_modules
|
| 595 |
if isinstance(targets, str) and targets != "all-linear":
|
| 596 |
targets = [t.strip() for t in targets.split(",") if t.strip()]
|
|
@@ -778,6 +791,8 @@ def parse_args(argv=None):
|
|
| 778 |
|
| 779 |
p.add_argument("--base-model", default="Qwen/Qwen3-Coder-30B-A3B-Instruct")
|
| 780 |
p.add_argument("--output-repo", default=None, help="Hub repo for the LoRA adapter")
|
|
|
|
|
|
|
| 781 |
p.add_argument("--merge-repo", default=None, help="optional Hub repo for a 16-bit merge")
|
| 782 |
p.add_argument("--output-dir", default="securecoder-out")
|
| 783 |
p.add_argument("--private", action="store_true", help="create Hub repos as private")
|
|
|
|
| 74 |
Source("lockon/xlam-function-calling-60k", 10000, "xlam", "dataset",
|
| 75 |
note="xLAM: query/answers/tools API-call pairs"),
|
| 76 |
# ---- coding ----------------------------------------------------------
|
| 77 |
+
Source("ise-uiuc/Magicoder-OSS-Instruct-75K", 20000, "magicoder",
|
| 78 |
note="self-instruct code problems + solutions"),
|
| 79 |
# ---- cybersecurity ---------------------------------------------------
|
| 80 |
+
Source("Trendyol/Trendyol-Cybersecurity-Instruction-Tuning-Dataset", 12000, "sua",
|
| 81 |
note="security instruction tuning"),
|
| 82 |
+
Source("AlicanKiraz0/Cybersecurity-Dataset-Fenrir-v2.1", 8000, "sua",
|
| 83 |
note="broad security Q&A"),
|
| 84 |
+
Source("Humanlearning/CyberSecurity_OWASP-sft-dataset", 5000, "messages",
|
| 85 |
note="OWASP / secure-coding SFT"),
|
| 86 |
Source("MrClipperz134/CTF-Instruct", 3000, "io",
|
| 87 |
note="CTF instruction/output"),
|
|
|
|
| 591 |
load_in_4bit=not args.no_4bit,
|
| 592 |
)
|
| 593 |
|
| 594 |
+
if args.resume_adapter:
|
| 595 |
+
# Continue an existing QLoRA instead of drawing a fresh one. A fresh
|
| 596 |
+
# adapter would forget the tool-calling already trained into it.
|
| 597 |
+
from peft import PeftModel
|
| 598 |
+
|
| 599 |
+
log.info("resuming adapter %s (trainable)", args.resume_adapter)
|
| 600 |
+
model = PeftModel.from_pretrained(model, args.resume_adapter, is_trainable=True)
|
| 601 |
+
trainable = sum(p.numel() for p in model.parameters() if p.requires_grad)
|
| 602 |
+
total = sum(p.numel() for p in model.parameters())
|
| 603 |
+
log.info("trainable parameters: %s (%.2f%% of the model)", f"{trainable:,}",
|
| 604 |
+
100 * trainable / max(total, 1))
|
| 605 |
+
return model, tokenizer
|
| 606 |
+
|
| 607 |
targets: Any = args.target_modules
|
| 608 |
if isinstance(targets, str) and targets != "all-linear":
|
| 609 |
targets = [t.strip() for t in targets.split(",") if t.strip()]
|
|
|
|
| 791 |
|
| 792 |
p.add_argument("--base-model", default="Qwen/Qwen3-Coder-30B-A3B-Instruct")
|
| 793 |
p.add_argument("--output-repo", default=None, help="Hub repo for the LoRA adapter")
|
| 794 |
+
p.add_argument("--resume-adapter", default=None,
|
| 795 |
+
help="existing LoRA repo to keep training (does not init a fresh adapter)")
|
| 796 |
p.add_argument("--merge-repo", default=None, help="optional Hub repo for a 16-bit merge")
|
| 797 |
p.add_argument("--output-dir", default="securecoder-out")
|
| 798 |
p.add_argument("--private", action="store_true", help="create Hub repos as private")
|