Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -222,40 +222,6 @@ def log_message(output_log, msg):
|
|
| 222 |
# 🧠 Train model to expand short prompts into long ones
|
| 223 |
# =====================================================
|
| 224 |
@spaces.GPU(duration=300)
|
| 225 |
-
import torch
|
| 226 |
-
from datasets import load_dataset
|
| 227 |
-
from transformers import (
|
| 228 |
-
AutoTokenizer,
|
| 229 |
-
AutoModelForCausalLM,
|
| 230 |
-
Trainer,
|
| 231 |
-
TrainingArguments,
|
| 232 |
-
)
|
| 233 |
-
from peft import LoraConfig, get_peft_model, TaskType
|
| 234 |
-
import os
|
| 235 |
-
|
| 236 |
-
# =====================================================
|
| 237 |
-
# 🔧 Utility logging
|
| 238 |
-
# =====================================================
|
| 239 |
-
def log_message(output_log, msg):
|
| 240 |
-
print(msg)
|
| 241 |
-
output_log.append(msg)
|
| 242 |
-
|
| 243 |
-
def start_async_upload(output_dir, hf_repo, output_log):
|
| 244 |
-
from huggingface_hub import upload_folder
|
| 245 |
-
try:
|
| 246 |
-
upload_folder(
|
| 247 |
-
repo_id=hf_repo,
|
| 248 |
-
folder_path=output_dir,
|
| 249 |
-
repo_type="model",
|
| 250 |
-
commit_message="Upload fine-tuned model"
|
| 251 |
-
)
|
| 252 |
-
log_message(output_log, f"☁️ Model uploaded to {hf_repo}")
|
| 253 |
-
except Exception as e:
|
| 254 |
-
log_message(output_log, f"⚠️ Upload failed: {e}")
|
| 255 |
-
|
| 256 |
-
# =====================================================
|
| 257 |
-
# 🧠 GPU-safe training for short→long prompt expansion
|
| 258 |
-
# =====================================================
|
| 259 |
def train_model(
|
| 260 |
base_model: str,
|
| 261 |
dataset_name: str,
|
|
|
|
| 222 |
# 🧠 Train model to expand short prompts into long ones
|
| 223 |
# =====================================================
|
| 224 |
@spaces.GPU(duration=300)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
def train_model(
|
| 226 |
base_model: str,
|
| 227 |
dataset_name: str,
|