asdf98 commited on
Commit
25abf03
Β·
verified Β·
1 Parent(s): 3d6a9e6

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +60 -42
README.md CHANGED
@@ -1,10 +1,15 @@
1
  ---
2
  tags:
3
  - ml-intern
 
 
 
 
4
  ---
 
5
  # πŸ” Ethical Hacking LLM Fine-Tuning Collection
6
 
7
- > **Public collection of Colab-ready notebooks for fine-tuning cybersecurity/ethical hacking LLMs on Google Colab Free Tier (T4 GPU).**
8
 
9
  ---
10
 
@@ -12,31 +17,58 @@ tags:
12
 
13
  | File | Model | Description |
14
  |------|-------|-------------|
15
- | `EthicalHacking_Qwen3-4B_Ultimate_Colab.ipynb` | **Qwen3-4B-Instruct-2507** (πŸ₯‡ recommended) | Best coding/reasoning scores among sub-10B models with confirmed Unsloth support |
16
- | `EthicalHacking_Qwen3-8B_Colab.ipynb` | Qwen3-8B-bnb-4bit | Larger capacity, less VRAM headroom on T4 |
 
17
 
18
  ---
19
 
20
- ## πŸ† Why Qwen3-4B-Instruct-2507?
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- After researching the **latest small models** as of May/June 2026, here's the verdict for T4 16GB:
23
 
24
- | Model | 4-bit Size | T4 Fit | Coding Benchmarks | Unsloth Support | Verdict |
25
- |-------|-----------|--------|------------------|-----------------|---------|
26
- | **Qwen3-4B-Instruct-2507** πŸ₯‡ | **3.3 GB** | βœ…βœ…βœ… Excellent | LiveCodeBench 35.1, MultiPL-E 76.8 | βœ… Confirmed | **Use this** |
27
- | Qwen3-8B | 7.0 GB | βœ…βœ… Good | Stronger base model | βœ… Confirmed | Viable but tighter |
28
- | Gemma-4-E2B-it | 7.6 GB | βœ…βœ… Good | Unverified coding scores | βœ… 4-bit exists | Multimodal option |
29
- | Gemma-4-E4B-it | 10.2 GB | ⚠️ Tight | β€” | βœ… 4-bit exists | **Avoid (OOM risk)** |
30
- | Bonsai (prism-ml) | ~1 GB | βœ…βœ…βœ… Excellent | Weak (MMLU 30%) | ❌ Custom arch | **Avoid** |
31
- | LFM2 (Liquid AI) | ~2.5 GB | βœ…βœ… Good | **Not for programming** (official disclaimer) | ❌ Unknown | **Avoid** |
32
- | Qwen3.5 series | β€” | β€” | β€” | ⚠️ Uncertain | Wait for Unsloth |
33
 
34
  ### Key Datasets Used
35
 
36
  | Dataset | Rows | Focus |
37
  |---------|------|-------|
38
- | [AlicanKiraz0/Cybersecurity-Dataset-Fenrir-v2.1](https://huggingface.co/datasets/AlicanKiraz0/Cybersecurity-Dataset-Fenrir-v2.1) | 99,870 | Threat analysis, IR, offensive education |
39
- | [Trendyol/Trendyol-Cybersecurity-Instruction-Tuning-Dataset](https://huggingface.co/datasets/Trendyol/Trendyol-Cybersecurity-Instruction-Tuning-Dataset) | 53,202 | C2 analysis, forensics, 200+ topics |
40
 
41
  ---
42
 
@@ -51,7 +83,7 @@ After researching the **latest small models** as of May/June 2026, here's the ve
51
 
52
  ## βš™οΈ T4 VRAM Optimizations Used
53
 
54
- - `load_in_4bit=True` + LoRA (r=64)
55
  - `adamw_8bit` optimizer
56
  - `use_gradient_checkpointing="unsloth"`
57
  - `fp16=True` (T4 has no bf16)
@@ -67,29 +99,15 @@ All datasets are **defensive/educational** (pentesting methodology, threat analy
67
 
68
  ## πŸ“š References
69
 
70
- - [Qwen3-4B-Instruct-2507](https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507)
71
- - [Unsloth 4-bit](https://huggingface.co/unsloth/Qwen3-4B-Instruct-2507-unsloth-bnb-4bit)
72
- - [Unsloth Docs](https://unsloth.ai/docs)
73
- - [TRL SFTTrainer](https://huggingface.co/docs/trl/sft_trainer)
74
- - [Fenrir Dataset](https://huggingface.co/datasets/AlicanKiraz0/Cybersecurity-Dataset-Fenrir-v2.1)
75
- - [Trendyol Dataset](https://huggingface.co/datasets/Trendyol/Trendyol-Cybersecurity-Instruction-Tuning-Dataset)
76
-
77
- <!-- ml-intern-provenance -->
78
- ## Generated by ML Intern
79
-
80
- This model repository was generated by [ML Intern](https://github.com/huggingface/ml-intern), an agent for machine learning research and development on the Hugging Face Hub.
81
-
82
- - Try ML Intern: https://smolagents-ml-intern.hf.space
83
- - Source code: https://github.com/huggingface/ml-intern
84
-
85
- ## Usage
86
 
87
- ```python
88
- from transformers import AutoModelForCausalLM, AutoTokenizer
89
-
90
- model_id = "asdf98/ethical-hacking-llm-colab"
91
- tokenizer = AutoTokenizer.from_pretrained(model_id)
92
- model = AutoModelForCausalLM.from_pretrained(model_id)
93
- ```
94
-
95
- For non-causal architectures, replace `AutoModelForCausalLM` with the appropriate `AutoModel` class.
 
1
  ---
2
  tags:
3
  - ml-intern
4
+ - ethical-hacking
5
+ - cybersecurity
6
+ - unsloth
7
+ - colab
8
  ---
9
+
10
  # πŸ” Ethical Hacking LLM Fine-Tuning Collection
11
 
12
+ > **Public collection of Colab-ready notebooks for fine-tuning cybersecurity/ethical hacking LLMs on Google Colab Free Tier (T4 GPU, ~16GB VRAM).**
13
 
14
  ---
15
 
 
17
 
18
  | File | Model | Description |
19
  |------|-------|-------------|
20
+ | `EthicalHacking_Qwen3-4B_Ultimate_Colab.ipynb` | **Qwen3-4B-Instruct-2507** πŸ₯‡ | Best coding/reasoning under 10B. **Recommended for T4.** |
21
+ | `EthicalHacking_Qwen3-8B_Colab.ipynb` | Qwen3-8B | More capacity, tighter VRAM. Simpler notebook. |
22
+ | `EthicalHacking_MultiModel_Comparison_Colab.ipynb` | **Multi-model selector** | Pick between Qwen3-4B/8B or Gemma-3-4B in one notebook |
23
 
24
  ---
25
 
26
+ ## 🚨 CRITICAL FIX: `formatting_func` Required by Unsloth
27
+
28
+ If you get this error:
29
+ ```
30
+ RuntimeError: Unsloth: You must specify a formatting_func
31
+ ```
32
+
33
+ **The fix:** When using `FastLanguageModel` + `SFTTrainer`, Unsloth **requires** you to explicitly pass a `formatting_func` that converts `messages` β†’ text string:
34
+
35
+ ```python
36
+ def formatting_func(example):
37
+ return tokenizer.apply_chat_template(
38
+ example["messages"],
39
+ tokenize=False, # MUST be False!
40
+ add_generation_prompt=False,
41
+ )
42
+
43
+ trainer = SFTTrainer(
44
+ model=model,
45
+ train_dataset=dataset,
46
+ formatting_func=formatting_func, # ← REQUIRED
47
+ ...
48
+ )
49
+ ```
50
+
51
+ All notebooks in this repo now include this fix.
52
+
53
+ ---
54
 
55
+ ## πŸ† Model Comparison (T4 16GB, May/June 2026)
56
 
57
+ | Model | 4-bit Size | T4 Fit | Coding Benchmarks | Unsloth | Verdict |
58
+ |-------|-----------|--------|------------------|---------|---------|
59
+ | **Qwen3-4B-Instruct-2507** πŸ₯‡ | **3.3 GB** | βœ…βœ…βœ… Excellent | LiveCodeBench 35.1, MultiPL-E 76.8 | βœ… Confirmed | **USE THIS** |
60
+ | Qwen3-8B | 7.0 GB | βœ…βœ… Good | Stronger base | βœ… Confirmed | Viable |
61
+ | Gemma-3-4B | ~2.5 GB | βœ…βœ…βœ… Excellent | Decent | βœ… Confirmed | Alternative |
62
+ | Gemma-4-E2B | ~7.6 GB | βœ…βœ… Good | Unverified | ⚠️ Limited | Experimental |
63
+ | **Bonsai** (prism-ml) | ~0.5 GB | βœ…βœ…βœ… Excellent | Weak (MMLU ~30%) | ❌ No | **AVOID** |
64
+ | **LFM2** (Liquid AI) | ~2.5 GB | βœ…βœ… Good | **Not for programming** | ❌ No | **AVOID** |
 
65
 
66
  ### Key Datasets Used
67
 
68
  | Dataset | Rows | Focus |
69
  |---------|------|-------|
70
+ | [Fenrir v2.1](https://huggingface.co/datasets/AlicanKiraz0/Cybersecurity-Dataset-Fenrir-v2.1) | 99,870 | Threat analysis, IR, offensive education |
71
+ | [Trendyol Cybersecurity](https://huggingface.co/datasets/Trendyol/Trendyol-Cybersecurity-Instruction-Tuning-Dataset) | 53,202 | C2 analysis, forensics, 200+ topics |
72
 
73
  ---
74
 
 
83
 
84
  ## βš™οΈ T4 VRAM Optimizations Used
85
 
86
+ - `load_in_4bit=True` + LoRA (r=64 for 4B, r=16 for 8B)
87
  - `adamw_8bit` optimizer
88
  - `use_gradient_checkpointing="unsloth"`
89
  - `fp16=True` (T4 has no bf16)
 
99
 
100
  ## πŸ“š References
101
 
102
+ | Resource | Link |
103
+ |----------|------|
104
+ | Qwen3-4B-Instruct-2507 | https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507 |
105
+ | Unsloth 4-bit | https://huggingface.co/unsloth/Qwen3-4B-Instruct-2507-unsloth-bnb-4bit |
106
+ | Unsloth Docs | https://unsloth.ai/docs |
107
+ | TRL SFTTrainer | https://huggingface.co/docs/trl/sft_trainer |
108
+ | Fenrir Dataset | https://huggingface.co/datasets/AlicanKiraz0/Cybersecurity-Dataset-Fenrir-v2.1 |
109
+ | Trendyol Dataset | https://huggingface.co/datasets/Trendyol/Trendyol-Cybersecurity-Instruction-Tuning-Dataset |
110
+ | CyberMetric Eval | https://huggingface.co/datasets/cybermetric/cybermetric-500 |
 
 
 
 
 
 
 
111
 
112
+ ---
113
+ *Built with ❀️ for the cybersecurity community. Use responsibly.*