# Ethical Hacking LLM Fine-Tuning on Free Kaggle/Colab ## ✅ Updated Unsloth notebooks — root fixed The notebooks now keep **Unsloth** for low VRAM, but fix the repeated Kaggle/Colab error: ```text AttributeError: 'int' object has no attribute 'mean' ``` ## What was fixed That error came from a version mismatch between: - `unsloth` - `unsloth_zoo` - `transformers` - `trl` plus Kaggle reusing old compiled code from: ```text /kaggle/working/unsloth_compiled_cache ``` Each notebook now: 1. Deletes the stale Unsloth compiled cache. 2. Uninstalls and reinstalls latest `unsloth` + `unsloth_zoo` together. 3. Forces a one-time kernel restart after install. 4. Uses modern TRL `SFTConfig` API. 5. Uses `processing_class=tokenizer` instead of older `tokenizer=` trainer argument. 6. Sets `trainer.model_accepts_loss_kwargs = False` to prevent `num_items_in_batch` leakage. ## Notebooks | Notebook | Model | Best use | |---|---|---| | [`EthicalHacking_LFM2.5_Ultimate_Colab.ipynb`](https://huggingface.co/asdf98/ethical-hacking-llm-colab/blob/main/EthicalHacking_LFM2.5_Ultimate_Colab.ipynb) | `unsloth/LFM2.5-1.2B-Instruct` | **Recommended first**, fastest and lowest VRAM | | [`EthicalHacking_Qwen3-4B_Ultimate_Colab.ipynb`](https://huggingface.co/asdf98/ethical-hacking-llm-colab/blob/main/EthicalHacking_Qwen3-4B_Ultimate_Colab.ipynb) | `unsloth/Qwen3-4B-Instruct-2507-unsloth-bnb-4bit` | Stronger model, tighter T4 VRAM | | [`EthicalHacking_Gemma4_E2B_Colab.ipynb`](https://huggingface.co/asdf98/ethical-hacking-llm-colab/blob/main/EthicalHacking_Gemma4_E2B_Colab.ipynb) | `unsloth/gemma-4-E2B-it-unsloth-bnb-4bit` | Experimental; use LFM2.5 first | | [`EthicalHacking_Stable_QLoRA_ManualLoop_NO_UNSLOTH.ipynb`](https://huggingface.co/asdf98/ethical-hacking-llm-colab/blob/main/EthicalHacking_Stable_QLoRA_ManualLoop_NO_UNSLOTH.ipynb) | Vanilla PEFT QLoRA | Backup if Unsloth breaks again | ## Important run instructions In Kaggle/Colab: 1. Upload/open the notebook. 2. Run cell 1. 3. Cell 1 will install/update Unsloth and intentionally restart the kernel. 4. After restart, run all cells from the top again. 5. Do **not** skip cell 1. It clears the compiled cache that caused the bug. ## Fast smoke test Before full training, set: ```python SAMPLE_SIZE = 1000 MAX_STEPS = 10 ``` If that trains, increase to the defaults. ## Safety Use only for ethical, defensive, authorized cybersecurity education and research.