semantic_router.encoders.huggingface#
This module provides the HFEndpointEncoder class to embeddings models using Huggingface’s endpoint.
The HFEndpointEncoder class is a subclass of BaseEncoder and utilizes a specified Huggingface endpoint to generate embeddings for given documents. It requires the URL of the Huggingface API endpoint and an API key for authentication. The class supports customization of the score threshold for filtering or processing the embeddings.
Example usage:
from semantic_router.encoders.hfendpointencoder import HFEndpointEncoder
- encoder = HFEndpointEncoder(
huggingface_url=”https://api-inference.huggingface.co/models/BAAI/bge-large-en-v1.5”, huggingface_api_key=”your-hugging-face-api-key”
) embeddings = encoder([“document1”, “document2”])
- Classes:
HFEndpointEncoder: A class for generating embeddings using a Huggingface endpoint.
Classes
|
A class to encode documents using a Hugging Face transformer model endpoint. |
|