Reality123b commited on
Commit
4006e28
·
verified ·
1 Parent(s): 8afc2a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
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 CPU)
9
  model = AutoModelForCausalLM.from_pretrained(
10
  "microsoft/Phi-3.5-mini-instruct",
11
- device_map="cpu", # Use CPU
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)