Upload README.md
Browse files
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**
|
| 16 |
-
| `EthicalHacking_Qwen3-8B_Colab.ipynb` | Qwen3-8B
|
|
|
|
| 17 |
|
| 18 |
---
|
| 19 |
|
| 20 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
|
| 24 |
-
| Model | 4-bit Size | T4 Fit | Coding Benchmarks | Unsloth
|
| 25 |
-
|-------|-----------|--------|------------------|---------
|
| 26 |
-
| **Qwen3-4B-Instruct-2507** π₯ | **3.3 GB** | β
β
β
Excellent | LiveCodeBench 35.1, MultiPL-E 76.8 | β
Confirmed | **
|
| 27 |
-
| Qwen3-8B | 7.0 GB | β
β
Good | Stronger base
|
| 28 |
-
| Gemma-
|
| 29 |
-
| Gemma-4-
|
| 30 |
-
| Bonsai (prism-ml) | ~
|
| 31 |
-
| LFM2 (Liquid AI) | ~2.5 GB | β
β
Good | **Not for programming**
|
| 32 |
-
| Qwen3.5 series | β | β | β | β οΈ Uncertain | Wait for Unsloth |
|
| 33 |
|
| 34 |
### Key Datasets Used
|
| 35 |
|
| 36 |
| Dataset | Rows | Focus |
|
| 37 |
|---------|------|-------|
|
| 38 |
-
| [
|
| 39 |
-
| [Trendyol
|
| 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 |
-
|
| 71 |
-
-
|
| 72 |
-
-
|
| 73 |
-
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 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 |
-
|
| 88 |
-
|
| 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.*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|