Skip to content

watsonx.ai

WatsonxEmbedding #

Bases: BaseEmbedding

IBM watsonx embedding models.

Note

One of these parameters is required: project_id or space_id. Not both.

See https://cloud.ibm.com/apidocs/watsonx-ai#endpoint-url for the watsonx.ai API endpoints.

Attributes:

Name Type Description
model_name str

IBM watsonx.ai model to be used. Defaults to ibm/slate-30m-english-rtrvr.

api_key str

watsonx API key.

url str

watsonx instance url.

truncate_input_tokens str

Maximum number of input tokens accepted. Defaults to 512

project_id str

watsonx project_id.

space_id str

watsonx space_id.

Example
from beekeeper.embeddings.watsonx import WatsonxEmbedding

watsonx_embedding = WatsonxEmbedding(
    api_key="your_api_key",
    url="your_instance_url",
    project_id="your_project_id",
)

embed_documents #

embed_documents(documents: list[Document]) -> list[Document]

Embed a list of documents and assign the computed embeddings to the 'embedding' attribute.

Parameters:

Name Type Description Default
documents list[Document]

List of documents to compute embeddings.

required

embed_text #

embed_text(input: str | list[str]) -> list[Embedding]

Embed one or more text strings.

Parameters:

Name Type Description Default
input str | list[str]

Input for which to compute embeddings.

required