Upload folder using huggingface_hub
#1
by
pacman1337 - opened
- README.md +21 -12
- app.py +85 -0
- requirements.txt +6 -0
README.md
CHANGED
|
@@ -1,12 +1,21 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: D1337
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: D1337 CIPHER Training
|
| 3 |
+
emoji: π₯
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: gray
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: "5.0.0"
|
| 8 |
+
python_version: "3.10"
|
| 9 |
+
app_file: app.py
|
| 10 |
+
pinned: false
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# D1337 CIPHER C2 V.1 - Training
|
| 14 |
+
|
| 15 |
+
One-click training setup.
|
| 16 |
+
|
| 17 |
+
**Click "START TRAINING"** β Done in 15-30 minutes.
|
| 18 |
+
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
**D1337 SOVEREIGN LABS - CEO Desorden**
|
app.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import subprocess
|
| 3 |
+
import os
|
| 4 |
+
import threading
|
| 5 |
+
|
| 6 |
+
def start_training():
|
| 7 |
+
"""Start D1337 CIPHER training"""
|
| 8 |
+
|
| 9 |
+
def run_training():
|
| 10 |
+
try:
|
| 11 |
+
os.system("pip install torch transformers datasets accelerate huggingface-hub --quiet")
|
| 12 |
+
|
| 13 |
+
# Simple training script
|
| 14 |
+
training_code = '''
|
| 15 |
+
import torch
|
| 16 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, Trainer, TrainingArguments
|
| 17 |
+
from datasets import load_dataset
|
| 18 |
+
|
| 19 |
+
# Load model
|
| 20 |
+
model_name = "huihui-ai/Huihui-GLM-4.7-Flash-abliterated"
|
| 21 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 22 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
|
| 23 |
+
|
| 24 |
+
# Load dataset
|
| 25 |
+
dataset = load_dataset("Desorden1337/d1337-cipher-dataset", split="train")
|
| 26 |
+
|
| 27 |
+
# Simple tokenize
|
| 28 |
+
def tokenize(examples):
|
| 29 |
+
return tokenizer(examples["text"], truncation=True, padding="max_length", max_length=512)
|
| 30 |
+
|
| 31 |
+
dataset = dataset.map(tokenize, batched=True)
|
| 32 |
+
|
| 33 |
+
# Training args - FAST
|
| 34 |
+
training_args = TrainingArguments(
|
| 35 |
+
output_dir="./d1337-cipher",
|
| 36 |
+
num_train_epochs=1, # Quick training
|
| 37 |
+
per_device_train_batch_size=4,
|
| 38 |
+
learning_rate=1e-4,
|
| 39 |
+
logging_steps=5,
|
| 40 |
+
save_steps=50,
|
| 41 |
+
push_to_hub=True,
|
| 42 |
+
hub_model_id="Desorden1337/d1337-cipher-v1",
|
| 43 |
+
hub_private_repo=True
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
# Train
|
| 47 |
+
trainer = Trainer(model=model, args=training_args, train_dataset=dataset, tokenizer=tokenizer)
|
| 48 |
+
trainer.train()
|
| 49 |
+
trainer.push_to_hub()
|
| 50 |
+
|
| 51 |
+
print("TRAINING COMPLETE!")
|
| 52 |
+
'''
|
| 53 |
+
|
| 54 |
+
with open("train.py", "w") as f:
|
| 55 |
+
f.write(training_code)
|
| 56 |
+
|
| 57 |
+
# Execute
|
| 58 |
+
result = subprocess.run(["python", "train.py"], capture_output=True, text=True)
|
| 59 |
+
|
| 60 |
+
return f"Training started!\n{result.stdout}\n{result.stderr}"
|
| 61 |
+
|
| 62 |
+
except Exception as e:
|
| 63 |
+
return f"Error: {e}"
|
| 64 |
+
|
| 65 |
+
# Run in background
|
| 66 |
+
thread = threading.Thread(target=run_training)
|
| 67 |
+
thread.start()
|
| 68 |
+
|
| 69 |
+
return "π₯ D1337 CIPHER TRAINING STARTED!\n\nCheck logs below..."
|
| 70 |
+
|
| 71 |
+
# UI
|
| 72 |
+
with gr.Blocks(title="D1337 CIPHER Training") as demo:
|
| 73 |
+
gr.Markdown("# π₯ D1337 CIPHER C2 V.1 - TRAINING")
|
| 74 |
+
gr.Markdown("**Base**: GLM-4.7-Flash-abliterated (31B)")
|
| 75 |
+
gr.Markdown("**Dataset**: 92 samples")
|
| 76 |
+
|
| 77 |
+
with gr.Row():
|
| 78 |
+
train_btn = gr.Button("π START TRAINING", variant="primary")
|
| 79 |
+
output = gr.Textbox(label="Training Output", lines=10)
|
| 80 |
+
|
| 81 |
+
train_btn.click(start_training, outputs=output)
|
| 82 |
+
|
| 83 |
+
gr.Markdown("**Expected time: 15-30 minutes on GPU**")
|
| 84 |
+
|
| 85 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch>=2.0.0
|
| 2 |
+
transformers>=4.36.0
|
| 3 |
+
datasets>=2.15.0
|
| 4 |
+
accelerate>=0.25.0
|
| 5 |
+
huggingface-hub>=0.20.0
|
| 6 |
+
gradio>=5.0.0
|