Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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.
|
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.
|
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 |
)
|