Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

Allow HFModel to use CPU (fix)

quangpham87fca722c4ed
diff --git a/dsp/modules/hf.py b/dsp/modules/hf.py
index c87ce8261..9b2cc8dc5 100644
--- a/dsp/modules/hf.py
+++ b/dsp/modules/hf.py
@@ -72,9 +72,9 @@ class HFModel(LM):
# self.model = AutoModelClass.from_pretrained(peft_config.base_model_name_or_path, return_dict=True, load_in_8bit=True, device_map=hf_device_map)
# self.model = PeftModel.from_pretrained(self.model, checkpoint)
# else:
- self.model = AutoModelClass.from_pretrained(checkpoint).to("cuda")
+ self.model = AutoModelClass.from_pretrained(checkpoint).to(self.device)
else:
- self.model = AutoModelClass.from_pretrained(model).to("cuda")
+ self.model = AutoModelClass.from_pretrained(model).to(self.device)
self.drop_prompt_from_output = False
except ValueError:
self.model = AutoModelForCausalLM.from_pretrained(