nemoguardrails.embeddings.providers.google
Module Contents
Classes
API
Bases: EmbeddingModel
Embedding model using Gemini API.
This class is a wrapper for using embedding models powered by Gemini API.
To use, you must have either:
- The
GOOGLE_API_KEYenvironment variable set with your API key, or - Pass your API key using the api_key kwarg to the genai.Client().
Parameters:
embedding_model
The name of the embedding model to be used.
**kwargs
Additional keyword arguments. Supports:
- output_dimensionality (int, optional): Desired output dimensions (128-3072 for gemini-embedding-001). Recommended values: 768, 1536, or 3072. If not specified, API defaults to 3072.
- api_key (str, optional): API key for authentication (or use GOOGLE_API_KEY env var).
- Other arguments passed to genai.Client() constructor.
_embedding_size
client
embedding_size
engine_name
output_dimensionality
Encode a list of documents into their corresponding sentence embeddings.
Parameters:
documents
The list of documents to be encoded.
Returns: List[List[float]]
List[List[float]]: The list of sentence embeddings, where each embedding is a list of floats.
Raises:
RuntimeError: If the embedding request fails.
async
Encode a list of documents into their corresponding sentence embeddings.
Parameters:
documents
The list of documents to be encoded.
Returns: List[List[float]]
List[List[float]]: The list of sentence embeddings, where each embedding is a list of floats.