hackergeek98 commited on
Commit
d93b988
·
verified ·
1 Parent(s): c59c378

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
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...