From the tutorials I am using the example that is provided
from langchain_community.embeddings import HuggingFaceInferenceAPIEmbeddings
embeddings = HuggingFaceInferenceAPIEmbeddings(
api_key=inference_api_key, model_name="sentence-transformers/all-MiniLM-l6-v2"
)
text = "this is a sample text"
query_result = embeddings.embed_query(text)
query_result[:3]
But this results in the error:
File ~/miniconda3/envs/rag/lib/python3.12/site-packages/langchain_community/embeddings/huggingface.py:373, in HuggingFaceInferenceAPIEmbeddings.embed_query(self, text)
364 def embed_query(self, text: str) -> List[float]:
365 """Compute query embeddings using a HuggingFace transformer model.
366
367 Args:
(...)
371 Embeddings for the text.
372 """
--> 373 return self.embed_documents([text])[0]
KeyError: 0
I can generate the text completions from LLMs hosted at the huggingface hub using the same inference_api_key so I guess maybe that is fine.(?)
Can you please help me understand how to use the inference API to get the embeddings from any embeddings model hosted on the huggingfacehub