AlephAlphaSymmetricSemanticEmbedding#
- class langchain_community.embeddings.aleph_alpha.AlephAlphaSymmetricSemanticEmbedding[source]#
Bases:
AlephAlphaAsymmetricSemanticEmbedding
Symmetric version of the Aleph Alpha’s semantic embeddings.
The main difference is that here, both the documents and queries are embedded with a SemanticRepresentation.Symmetric .. rubric:: Example
from aleph_alpha import AlephAlphaSymmetricSemanticEmbedding embeddings = AlephAlphaAsymmetricSemanticEmbedding( normalize=True, compress_to_size=128 ) text = "This is a test text" doc_result = embeddings.embed_documents([text]) query_result = embeddings.embed_query(text)
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 aleph_alpha_api_key: str | None = None#
API key for Aleph Alpha API.
- param compress_to_size: int | None = None#
Should the returned embeddings come back as an original 5120-dim vector, or should it be compressed to 128-dim.
- param contextual_control_threshold: int | None = None#
Attention control parameters only apply to those tokens that have explicitly been set in the request.
- param control_log_additive: bool = True#
Apply controls on prompt items by adding the log(control_factor) to attention scores.
- param host: str = 'https://api.aleph-alpha.com'#
The hostname of the API host. The default one is “https://api.aleph-alpha.com”)
- param hosting: str | None = None#
Determines in which datacenters the request may be processed. You can either set the parameter to “aleph-alpha” or omit it (defaulting to None). Not setting this value, or setting it to None, gives us maximal flexibility in processing your request in our own datacenters and on servers hosted with other providers. Choose this option for maximal availability. Setting it to “aleph-alpha” allows us to only process the request in our own datacenters. Choose this option for maximal data privacy.
- param model: str = 'luminous-base'#
Model name to use.
- param nice: bool = False#
Setting this to True, will signal to the API that you intend to be nice to other users by de-prioritizing your request below concurrent ones.
- param normalize: bool = False#
Should returned embeddings be normalized
- param request_timeout_seconds: int = 305#
Client timeout that will be set for HTTP requests in the requests library’s API calls. Server will close all requests after 300 seconds with an internal server error.
- param total_retries: int = 8#
The number of retries made in case requests fail with certain retryable status codes. If the last retry fails a corresponding exception is raised. Note, that between retries an exponential backoff is applied, starting with 0.5 s after the first retry and doubling for each retry made. So with the default setting of 8 retries a total wait time of 63.5 s is added between the retries.
- async aembed_documents(texts: List[str]) List[List[float]] #
Asynchronous Embed search docs.
- Parameters:
texts (List[str]) – List of text to embed.
- Returns:
List of embeddings.
- Return type:
List[List[float]]
- async aembed_query(text: str) List[float] #
Asynchronous Embed query text.
- Parameters:
text (str) – Text to embed.
- Returns:
Embedding.
- Return type:
List[float]
Examples using AlephAlphaSymmetricSemanticEmbedding