danishjameel003 commited on
Commit
efe698b
·
verified ·
1 Parent(s): 74d69bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -23,7 +23,7 @@ def load_pipeline():
23
  tokenizer = AutoTokenizer.from_pretrained(model_name, padding_side="left", trust_remote_code=True)
24
  model = AutoModelForCausalLM.from_pretrained(
25
  model_name,
26
- torch_dtype=torch.bfloat16, # Use bfloat16 to reduce memory usage
27
  device_map="auto", # Automatically map model to available devices (e.g., GPU if available)
28
  trust_remote_code=True
29
  )
@@ -33,7 +33,7 @@ def load_pipeline():
33
  task="text-generation",
34
  model=model,
35
  tokenizer=tokenizer,
36
- torch_dtype=torch.bfloat16,
37
  device_map="auto",
38
  return_full_text=True # Required for LangChain compatibility
39
  )
 
23
  tokenizer = AutoTokenizer.from_pretrained(model_name, padding_side="left", trust_remote_code=True)
24
  model = AutoModelForCausalLM.from_pretrained(
25
  model_name,
26
+ torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32, # Use float16 for GPU, float32 for CPU
27
  device_map="auto", # Automatically map model to available devices (e.g., GPU if available)
28
  trust_remote_code=True
29
  )
 
33
  task="text-generation",
34
  model=model,
35
  tokenizer=tokenizer,
36
+ torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
37
  device_map="auto",
38
  return_full_text=True # Required for LangChain compatibility
39
  )