DSPy: The framework for programming—not prompting—language models
Python
feature(dspy): refined missing hf error
Alejandro Barónbdc9b98e7380
diff --git a/dsp/modules/hf.py b/dsp/modules/hf.pyindex fb4027731..d775d48da 100644--- a/dsp/modules/hf.py+++ b/dsp/modules/hf.py@@ -72,7 +72,7 @@ class HFModel(LM):from transformers import AutoConfig, AutoModelForCausalLM, AutoModelForSeq2SeqLM, AutoTokenizerexcept ImportError as exc:raise ModuleNotFoundError(- "You need to install Hugging Face transformers library to use HF models.",+ "You need to install Hugging Face transformers (with torch dependencies) library to use HF models.",) from excself.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")try:diff --git a/dspy/retrieve/pinecone_rm.py b/dspy/retrieve/pinecone_rm.pyindex 0b5518e96..6c8a793a4 100644--- a/dspy/retrieve/pinecone_rm.py+++ b/dspy/retrieve/pinecone_rm.py@@ -85,7 +85,7 @@ class PineconeRM(Retrieve):from transformers import AutoModel, AutoTokenizerexcept ImportError as exc:raise ModuleNotFoundError(- "You need to install Hugging Face transformers library to use a local embedding model with PineconeRM.",+ "You need to install Hugging Face transformers (with torch dependencies) library to use a local embedding model with PineconeRM.",) from excself._local_embed_model = AutoModel.from_pretrained(local_embed_model)