IBM watsonx.ai¶
pip install beekeeper-embeddings-watsonx
- class WatsonxEmbedding¶
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.
- Parameters:
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, optional) – watsonx project_id.
space_id (str, optional) – 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", )
- get_documents_embedding(documents)¶
Compute embeddings for a list of documents.
- Parameters:
documents (List[Document]) – List of documents to compute embeddings.
- get_text_embedding(query)¶
Compute embedding for a single input text.
- Parameters:
query (str) – Input query string to compute the embedding for.
- Returns:
The embedding vector corresponding to the input query.
- Return type:
List[float]
Example
embedded_query = watsonx_embedding.get_text_embedding( "Beekeeper is a data framework to load any data in one line of code and connect with AI applications." )
- get_texts_embedding(texts)¶
Compute embeddings for a list of texts.
- Parameters:
texts (List[str]) – A list of input strings for which to compute embeddings.