SambaStudioEmbeddings#

class langchain_community.embeddings.sambanova.SambaStudioEmbeddings[source]#

Bases: BaseModel, Embeddings

SambaNova embedding models.

To use, you should have the environment variables SAMBASTUDIO_EMBEDDINGS_BASE_URL, SAMBASTUDIO_EMBEDDINGS_BASE_URI SAMBASTUDIO_EMBEDDINGS_PROJECT_ID, SAMBASTUDIO_EMBEDDINGS_ENDPOINT_ID, SAMBASTUDIO_EMBEDDINGS_API_KEY set with your personal sambastudio variable or pass it as a named parameter to the constructor.

Example

from langchain_community.embeddings import SambaStudioEmbeddings

embeddings = SambaStudioEmbeddings(sambastudio_embeddings_base_url=base_url,
                              sambastudio_embeddings_base_uri=base_uri,
                              sambastudio_embeddings_project_id=project_id,
                              sambastudio_embeddings_endpoint_id=endpoint_id,
                              sambastudio_embeddings_api_key=api_key,
                              batch_size=32)
(or)

embeddings = SambaStudioEmbeddings(batch_size=32)

(or)

# CoE example
embeddings = SambaStudioEmbeddings(
    batch_size=1,
    model_kwargs={
        'select_expert':'e5-mistral-7b-instruct'
    }
)

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 batch_size: int = 32#

Batch size for the embedding models

param model_kwargs: dict = {}#

Key word arguments to pass to the model.

param sambastudio_embeddings_api_key: str = ''#

sambastudio api key

param sambastudio_embeddings_base_uri: str = ''#

endpoint base uri

param sambastudio_embeddings_base_url: str = ''#

Base url to use

param sambastudio_embeddings_endpoint_id: str = ''#

endpoint id on sambastudio for model

param sambastudio_embeddings_project_id: str = ''#

Project id on sambastudio for model

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]

embed_documents(texts: List[str], batch_size: int | None = None) List[List[float]][source]#

Returns a list of embeddings for the given sentences. :param texts: List of texts to encode :type texts: List[str] :param batch_size: Batch size for the encoding :type batch_size: int

Returns:

List of embeddings for the given sentences

Return type:

List[np.ndarray] or List[tensor]

Parameters:
  • texts (List[str]) –

  • batch_size (int | None) –

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

Returns a list of embeddings for the given sentences. :param sentences: List of sentences to encode :type sentences: List[str]

Returns:

List of embeddings for the given sentences

Return type:

List[np.ndarray] or List[tensor]

Parameters:

text (str) –

Examples using SambaStudioEmbeddings