NVIDIAEmbeddings#

class langchain_nvidia_ai_endpoints.embeddings.NVIDIAEmbeddings[source]#

Bases: BaseModel, Embeddings

Client to NVIDIA embeddings models.

Fields: - model: str, the name of the model to use - truncate: “NONE”, “START”, “END”, truncate input text if it exceeds the model’s

maximum token length. Default is “NONE”, which raises an error if an input is too long.

Create a new NVIDIAEmbeddings embedder.

This class provides access to a NVIDIA NIM for embedding. By default, it connects to a hosted NIM, but can be configured to connect to a local NIM using the base_url parameter. An API key is required to connect to the hosted NIM.

Parameters:
  • model (str) – The model to use for embedding.

  • nvidia_api_key (str) – The API key to use for connecting to the hosted NIM.

  • api_key (str) – Alternative to nvidia_api_key.

  • base_url (str) – The base URL of the NIM to connect to. Format for base URL is http://host:port

  • trucate (str) – “NONE”, “START”, “END”, truncate input text if it exceeds the model’s context length. Default is “NONE”, which raises an error if an input is too long.

API Key: - The recommended way to provide the API key is through the NVIDIA_API_KEY

environment variable.

Base URL: - Connect to a self-hosted model with NVIDIA NIM using the base_url arg to

link to the local host at localhost:8000: embedder = NVIDIAEmbeddings(base_url=”http://localhost:8080/v1”)

param base_url: str | None = None#

Base url for model listing an invocation

param max_batch_size: int = 50#
param model: str | None = None#

Name of the model to invoke

param truncate: Literal['NONE', 'START', 'END'] = 'NONE'#

Truncate input text if it exceeds the model’s maximum token length. Default is ‘NONE’, which raises an error if an input is too long.

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]) List[List[float]][source]#

Input pathway for document embeddings.

Parameters:

texts (List[str])

Return type:

List[List[float]]

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

Input pathway for query embeddings.

Parameters:

text (str)

Return type:

List[float]

classmethod get_available_models(**kwargs: Any) List[Model][source]#

Get a list of available models that work with NVIDIAEmbeddings.

Parameters:

kwargs (Any)

Return type:

List[Model]

property available_models: List[Model]#

Get a list of available models that work with NVIDIAEmbeddings.