Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,21 +5,20 @@ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
|
5 |
# Set seed for reproducibility
|
6 |
torch.random.manual_seed(0)
|
7 |
|
8 |
-
# Load the model and tokenizer (using
|
9 |
model = AutoModelForCausalLM.from_pretrained(
|
10 |
"microsoft/Phi-3.5-mini-instruct",
|
11 |
-
device_map="
|
12 |
torch_dtype="auto",
|
13 |
trust_remote_code=True,
|
14 |
)
|
15 |
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3.5-mini-instruct")
|
16 |
|
17 |
-
# Define the pipeline
|
18 |
pipe = pipeline(
|
19 |
"text-generation",
|
20 |
model=model,
|
21 |
tokenizer=tokenizer,
|
22 |
-
device=-1 # CPU
|
23 |
)
|
24 |
|
25 |
# System message (invisible to the user)
|
|
|
5 |
# Set seed for reproducibility
|
6 |
torch.random.manual_seed(0)
|
7 |
|
8 |
+
# Load the model and tokenizer (using Accelerate)
|
9 |
model = AutoModelForCausalLM.from_pretrained(
|
10 |
"microsoft/Phi-3.5-mini-instruct",
|
11 |
+
device_map="auto", # Managed by Accelerate
|
12 |
torch_dtype="auto",
|
13 |
trust_remote_code=True,
|
14 |
)
|
15 |
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3.5-mini-instruct")
|
16 |
|
17 |
+
# Define the pipeline (no device argument)
|
18 |
pipe = pipeline(
|
19 |
"text-generation",
|
20 |
model=model,
|
21 |
tokenizer=tokenizer,
|
|
|
22 |
)
|
23 |
|
24 |
# System message (invisible to the user)
|