Skip to content

armgit / dspy

Public Imported from GitHub
0

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

Python

Update hf.py

Pasquale Minervini31a5fb087962
diff --git a/dsp/modules/hf.py b/dsp/modules/hf.py
index 73cba0b12..fb4027731 100644
--- a/dsp/modules/hf.py
+++ b/dsp/modules/hf.py
@@ -168,9 +168,8 @@ class HFModel(LM):
print("Failed to extract 'content' from the prompt.")
inputs = self.tokenizer(prompt, return_tensors="pt").to(self.device)
- if 'temperature' in kwargs:
- if kwargs['temperature'] == 0.0:
- kwargs['do_sample'] = False
+ if 'temperature' in kwargs and kwargs['temperature'] == 0.0:
+ kwargs['do_sample'] = False
# print(kwargs)
outputs = self.model.generate(**inputs, **kwargs)