langchain.embeddings.aleph_alpha.AlephAlphaSymmetricSemanticEmbedding¶

class langchain.embeddings.aleph_alpha.AlephAlphaSymmetricSemanticEmbedding(*, client: Any = None, model: Optional[str] = 'luminous-base', hosting: Optional[str] = 'https://api.aleph-alpha.com', normalize: Optional[bool] = True, compress_to_size: Optional[int] = 128, contextual_control_threshold: Optional[int] = None, control_log_additive: Optional[bool] = True, aleph_alpha_api_key: Optional[str] = None)[source]¶

Bases: AlephAlphaAsymmetricSemanticEmbedding

The 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()
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: Optional[str] = None¶

API key for Aleph Alpha API.

param client: Any = None¶

Aleph Alpha client.

param compress_to_size: Optional[int] = 128¶

Should the returned embeddings come back as an original 5120-dim vector, or should it be compressed to 128-dim.

param contextual_control_threshold: Optional[int] = None¶

Attention control parameters only apply to those tokens that have explicitly been set in the request.

param control_log_additive: Optional[bool] = True¶

Apply controls on prompt items by adding the log(control_factor) to attention scores.

param hosting: Optional[str] = 'https://api.aleph-alpha.com'¶

Optional parameter that specifies which datacenters may process the request.

param model: Optional[str] = 'luminous-base'¶

Model name to use.

param normalize: Optional[bool] = True¶

Should returned embeddings be normalized

embed_documents(texts: List[str]) List[List[float]][source]¶

Call out to Aleph Alpha’s Document endpoint.

Parameters

texts – The list of texts to embed.

Returns

List of embeddings, one for each text.

embed_query(text: str) List[float][source]¶

Call out to Aleph Alpha’s asymmetric, query embedding endpoint :param text: The text to embed.

Returns

Embeddings for the text.

validator validate_environment  »  all fields¶

Validate that api key and python package exists in environment.

Examples using AlephAlphaSymmetricSemanticEmbedding¶