AlephAlphaAsymmetricSemanticEmbedding#
- class langchain_community.embeddings.aleph_alpha.AlephAlphaAsymmetricSemanticEmbedding[source]#
Bases:
BaseModel
,Embeddings
Aleph Alpha’s asymmetric semantic embedding.
AA provides you with an endpoint to embed a document and a query. The models were optimized to make the embeddings of documents and the query for a document as similar as possible. To learn more, check out: https://docs.aleph-alpha.com/docs/tasks/semantic_embed/
Example
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- 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 AlephAlphaAsymmetricSemanticEmbedding