langchain_community.embeddings.huggingface.HuggingFaceInferenceAPIEmbeddings¶
class langchain_community.embeddings.huggingface.HuggingFaceInferenceAPIEmbeddings[source]¶
Bases: BaseModel, Embeddings
Embed texts using the HuggingFace API.
Requires a HuggingFace Inference API key and a model name.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param api_key: str [Required]¶
Your API key for the HuggingFace Inference API.
param api_url: Optional[str] = None¶
Custom inference endpoint url. None for using default public url.
param model_name: str = 'sentence-transformers/all-MiniLM-L6-v2'¶
The name of the model to use for text embeddings.
async aembed_documents(texts: List[str]) → List[List[float]]¶
Asynchronous Embed search docs.
async aembed_query(text: str) → List[float]¶
Asynchronous Embed query text.
classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Behaves as if Config.extra = ‘allow’ was set since it adds all passed values
copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶
Duplicate a model, optionally choose which fields to include, exclude and change.
Parameters
include – fields to include in new model