Text Generation
PEFT
English
cybersecurity
penetration-testing
exploit-development
offensive-security
lora
qwen
code
Instructions to use HeeBive/ZeroSec-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use HeeBive/ZeroSec-7B with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
Upload vast_zerosec_v3.sh with huggingface_hub
Browse files- vast_zerosec_v3.sh +94 -0
vast_zerosec_v3.sh
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -e
|
| 3 |
+
echo "=== ZeroSec v3 Training (Unsloth QLoRA) ==="
|
| 4 |
+
|
| 5 |
+
# Install
|
| 6 |
+
pip install unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git -q 2>&1 | tail -1
|
| 7 |
+
pip install "unsloth[cu121-torch250] @ git+https://github.com/unslothai/unsloth.git" -q 2>&1 | tail -1
|
| 8 |
+
pip install torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 -q 2>&1 | tail -1
|
| 9 |
+
|
| 10 |
+
# Download datasets
|
| 11 |
+
echo "Downloading datasets..."
|
| 12 |
+
export HF_TOKEN="${HF_TOKEN:?Set HF_TOKEN}"
|
| 13 |
+
curl -L -o exploit_data.jsonl -H "Authorization: Bearer $HF_TOKEN" "https://huggingface.co/HeeBive/ZeroSec-7B/resolve/main/training_data.jsonl"
|
| 14 |
+
curl -L -o tool_data.jsonl -H "Authorization: Bearer $HF_TOKEN" "https://huggingface.co/HeeBive/ZeroSec-7B/resolve/main/v3_tool_data.jsonl"
|
| 15 |
+
|
| 16 |
+
# Combine
|
| 17 |
+
python3 << 'PYEOF' > train.log 2>&1
|
| 18 |
+
import json, os, torch
|
| 19 |
+
os.environ["TORCH_COMPILE_DISABLE"] = "1"
|
| 20 |
+
HF_TOKEN = os.environ["HF_TOKEN"]
|
| 21 |
+
|
| 22 |
+
print("Combining datasets...")
|
| 23 |
+
with open("exploit_data.jsonl") as f: exp = f.readlines()
|
| 24 |
+
with open("tool_data.jsonl") as f: tool = f.readlines()
|
| 25 |
+
all_data = exp + tool * 5
|
| 26 |
+
with open("combined.jsonl", "w") as f:
|
| 27 |
+
for l in all_data: f.write(l)
|
| 28 |
+
print(f"{len(exp)} exploit + {len(tool)*5} tool = {len(all_data)}")
|
| 29 |
+
|
| 30 |
+
from datasets import load_dataset
|
| 31 |
+
from unsloth import FastLanguageModel
|
| 32 |
+
from trl import SFTTrainer
|
| 33 |
+
from transformers import TrainingArguments
|
| 34 |
+
from unsloth import is_bfloat16_supported
|
| 35 |
+
|
| 36 |
+
MODEL = "unsloth/gpt-oss-20b-bf16"
|
| 37 |
+
OUT = "/root/zerosec_v3"
|
| 38 |
+
|
| 39 |
+
print("Loading model...")
|
| 40 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 41 |
+
model_name=MODEL,
|
| 42 |
+
max_seq_length=512,
|
| 43 |
+
dtype=None,
|
| 44 |
+
load_in_4bit=True,
|
| 45 |
+
)
|
| 46 |
+
model = FastLanguageModel.get_peft_model(
|
| 47 |
+
model,
|
| 48 |
+
r=16,
|
| 49 |
+
target_modules=["q_proj","k_proj","v_proj","o_proj"],
|
| 50 |
+
lora_alpha=32,
|
| 51 |
+
use_gradient_checkpointing="unsloth",
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
print("Loading dataset...")
|
| 55 |
+
ds = load_dataset("json", data_files="combined.jsonl", split="train")
|
| 56 |
+
def fmt(x): return {"text": x["text"]}
|
| 57 |
+
ds = ds.map(fmt, remove_columns=ds.column_names)
|
| 58 |
+
|
| 59 |
+
print("Training...")
|
| 60 |
+
trainer = SFTTrainer(
|
| 61 |
+
model=model,
|
| 62 |
+
tokenizer=tokenizer,
|
| 63 |
+
train_dataset=ds,
|
| 64 |
+
dataset_text_field="text",
|
| 65 |
+
max_seq_length=512,
|
| 66 |
+
args=TrainingArguments(
|
| 67 |
+
per_device_train_batch_size=2,
|
| 68 |
+
gradient_accumulation_steps=8,
|
| 69 |
+
num_train_epochs=1,
|
| 70 |
+
learning_rate=2e-4,
|
| 71 |
+
fp16=not is_bfloat16_supported(),
|
| 72 |
+
bf16=is_bfloat16_supported(),
|
| 73 |
+
logging_steps=10,
|
| 74 |
+
save_steps=500,
|
| 75 |
+
output_dir=OUT,
|
| 76 |
+
optim="adamw_8bit",
|
| 77 |
+
report_to="none",
|
| 78 |
+
),
|
| 79 |
+
)
|
| 80 |
+
trainer.train()
|
| 81 |
+
|
| 82 |
+
print("Saving...")
|
| 83 |
+
model.save_pretrained(OUT)
|
| 84 |
+
tokenizer.save_pretrained(OUT)
|
| 85 |
+
|
| 86 |
+
print("Uploading to HF...")
|
| 87 |
+
from huggingface_hub import HfApi
|
| 88 |
+
api = HfApi(token=HF_TOKEN)
|
| 89 |
+
api.create_repo("HeeBive/ZeroSec-v3", repo_type="model", exist_ok=True, private=True)
|
| 90 |
+
api.upload_folder(folder_path=OUT, repo_id="HeeBive/ZeroSec-v3", repo_type="model", token=HF_TOKEN)
|
| 91 |
+
print("✅ DONE - HeeBive/ZeroSec-v3")
|
| 92 |
+
PYEOF
|
| 93 |
+
|
| 94 |
+
tail -f train.log
|