Spaces:
Sleeping
Sleeping
AyoubChLin
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -5,8 +5,9 @@ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
|
5 |
# Initialize model and tokenizer
|
6 |
model = AutoModelForCausalLM.from_pretrained(
|
7 |
"microsoft/Phi-3.5-mini-instruct",
|
|
|
|
|
8 |
low_cpu_mem_usage=True,
|
9 |
-
torch_dtype="auto",
|
10 |
trust_remote_code=True,
|
11 |
)
|
12 |
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3.5-mini-instruct")
|
@@ -16,11 +17,12 @@ pipe = pipeline(
|
|
16 |
"text-generation",
|
17 |
model=model,
|
18 |
tokenizer=tokenizer,
|
|
|
19 |
)
|
20 |
|
21 |
# Generation arguments
|
22 |
generation_args = {
|
23 |
-
"max_new_tokens":
|
24 |
"return_full_text": False,
|
25 |
"temperature": 0.0,
|
26 |
"do_sample": False,
|
|
|
5 |
# Initialize model and tokenizer
|
6 |
model = AutoModelForCausalLM.from_pretrained(
|
7 |
"microsoft/Phi-3.5-mini-instruct",
|
8 |
+
device_map="cpu",
|
9 |
+
torch_dtype=torch.float16,
|
10 |
low_cpu_mem_usage=True,
|
|
|
11 |
trust_remote_code=True,
|
12 |
)
|
13 |
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3.5-mini-instruct")
|
|
|
17 |
"text-generation",
|
18 |
model=model,
|
19 |
tokenizer=tokenizer,
|
20 |
+
device="cpu"
|
21 |
)
|
22 |
|
23 |
# Generation arguments
|
24 |
generation_args = {
|
25 |
+
"max_new_tokens": 500,
|
26 |
"return_full_text": False,
|
27 |
"temperature": 0.0,
|
28 |
"do_sample": False,
|