Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import gradio as gr
|
3 |
+
import os
|
4 |
+
from transformers import (
|
5 |
+
AutoModelForCausalLM,
|
6 |
+
AutoTokenizer,
|
7 |
+
TrainingArguments,
|
8 |
+
Trainer,
|
9 |
+
DataCollatorForLanguageModeling
|
10 |
+
)
|
11 |
+
|
12 |
+
# Force CPU mode
|
13 |
+
os.environ["CUDA_VISIBLE_DEVICES"] = ""
|
14 |
+
os.environ["BITSANDBYTES_NOWELCOME"] = "1"
|
15 |
+
|
16 |
+
def train():
|
17 |
+
model = AutoModelForCausalLM.from_pretrained(
|
18 |
+
"microsoft/phi-2",
|
19 |
+
device_map="auto",
|
20 |
+
trust_remote_code=True,
|
21 |
+
load_in_4bit=False # Disable quantization
|
22 |
+
)
|
23 |
+
|
24 |
+
training_args = TrainingArguments(
|
25 |
+
output_dir="./results",
|
26 |
+
per_device_train_batch_size=2,
|
27 |
+
num_train_epochs=3,
|
28 |
+
use_cpu=True, # Explicit CPU usage
|
29 |
+
fp16=False,
|
30 |
+
bf16=False,
|
31 |
+
)
|
32 |
+
|
33 |
+
# Rest of training code...
|