langchain_community.embeddings.aleph_alpha
.AlephAlphaSymmetricSemanticEmbedding¶
- class langchain_community.embeddings.aleph_alpha.AlephAlphaSymmetricSemanticEmbedding[source]¶
Bases:
AlephAlphaAsymmetricSemanticEmbedding
Aleph Alpha的语义嵌入的对称版本。
主要区别在于,这里文档和查询都是使用SemanticRepresentation.Symmetric进行嵌入。 示例: .. code-block:: python
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: Optional[str] = None¶
Aleph Alpha API 的 API 密钥。
- param compress_to_size: Optional[int] = None¶
返回的嵌入向量应该是原始的5120维向量,还是应该压缩为128维。
- param contextual_control_threshold: Optional[int] = None¶
注意控制参数仅适用于在请求中明确设置的令牌。
- param control_log_additive: bool = True¶
通过将log(control_factor)添加到注意力分数中,对提示项目应用控件。
- param host: str = 'https://api.aleph-alpha.com'¶
API主机的主机名。 默认值为”https://api.aleph-alpha.com
- param hosting: Optional[str] = None¶
确定请求可以在哪些数据中心处理。 您可以将参数设置为”aleph-alpha”,也可以省略(默认为None)。 不设置此值,或将其设置为None,可以在我们自己的数据中心和其他提供商托管的服务器上最大限度地灵活处理您的请求。 选择此选项以获得最大的可用性。 将其设置为”aleph-alpha”允许我们仅在自己的数据中心处理请求。 选择此选项以获得最大的数据隐私。
- param model: str = 'luminous-base'¶
要使用的模型名称。
- param nice: bool = False¶
将此设置为True,将向API表明您打算对其他用户友好,通过将您的请求优先级降低到并发请求之下。
- param normalize: bool = False¶
返回的嵌入是否应该被归一化
- param request_timeout_seconds: int = 305¶
HTTP请求中`requests`库API调用的客户端超时时间设置。 服务器将在300秒后关闭所有请求,并返回内部服务器错误。
- param total_retries: int = 8¶
在请求失败时重试的次数,具有可重试状态码。如果最后一次重试失败,则会引发相应的异常。请注意,在重试之间会应用指数退避,从第一次重试后的0.5秒开始,并且每次重试都会加倍。因此,默认设置为8次重试,总等待时间为63.5秒,其中包括重试之间的等待时间。
- async aembed_documents(texts: List[str]) List[List[float]] ¶
Asynchronous 嵌入搜索文档。
- Parameters
texts (List[str]) –
- Return type
List[List[float]]
- async aembed_query(text: str) List[float] ¶
Asynchronous 嵌入查询文本。
- Parameters
text (str) –
- Return type
List[float]
- 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
- Parameters
_fields_set (Optional[SetStr]) –
values (Any) –
- Return type
Model
- 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 (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include
update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data
deep (bool) – set to True to make a deep copy of the model
self (Model) –
- Returns
new model instance
- Return type
Model
- dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny ¶
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
by_alias (bool) –
skip_defaults (Optional[bool]) –
exclude_unset (bool) –
exclude_defaults (bool) –
exclude_none (bool) –
- Return type
DictStrAny
- embed_documents(texts: List[str]) List[List[float]] [source]¶
调用Aleph Alpha的文档端点。
- 参数:
texts:要嵌入的文本列表。
- 返回:
每个文本的嵌入列表。
- Parameters
texts (List[str]) –
- Return type
List[List[float]]
- embed_query(text: str) List[float] [source]¶
调用Aleph Alpha的非对称查询嵌入端点 参数:
text:要嵌入的文本。
- 返回:
文本的嵌入。
- Parameters
text (str) –
- Return type
List[float]
- classmethod from_orm(obj: Any) Model ¶
- Parameters
obj (Any) –
- Return type
Model
- json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode ¶
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().
- Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
by_alias (bool) –
skip_defaults (Optional[bool]) –
exclude_unset (bool) –
exclude_defaults (bool) –
exclude_none (bool) –
encoder (Optional[Callable[[Any], Any]]) –
models_as_dict (bool) –
dumps_kwargs (Any) –
- Return type
unicode
- classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) Model ¶
- Parameters
path (Union[str, Path]) –
content_type (unicode) –
encoding (unicode) –
proto (Protocol) –
allow_pickle (bool) –
- Return type
Model
- classmethod parse_obj(obj: Any) Model ¶
- Parameters
obj (Any) –
- Return type
Model
- classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) Model ¶
- Parameters
b (Union[str, bytes]) –
content_type (unicode) –
encoding (unicode) –
proto (Protocol) –
allow_pickle (bool) –
- Return type
Model
- classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') DictStrAny ¶
- Parameters
by_alias (bool) –
ref_template (unicode) –
- Return type
DictStrAny
- classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) unicode ¶
- Parameters
by_alias (bool) –
ref_template (unicode) –
dumps_kwargs (Any) –
- Return type
unicode
- classmethod update_forward_refs(**localns: Any) None ¶
Try to update ForwardRefs on fields based on this Model, globalns and localns.
- Parameters
localns (Any) –
- Return type
None
- classmethod validate(value: Any) Model ¶
- Parameters
value (Any) –
- Return type
Model