🚀 Try Zilliz Cloud, the fully managed Milvus, for free—experience 10x faster performance! Try Now>>

Milvus
Zilliz
< Docs
  • Python
    • EmbeddingModels
      • GeminiEmbeddingFunction

GeminiEmbeddingFunction

Model2VecEmbeddingFunction is a class in pymilvus that handles encoding text into embeddings using the GeminiEmbeddingFunction module to support embedding retrieval in Milvus.

pymilvus.model.dense.GeminiEmbeddingFunction

Constructor

Constructs an GeminiEmbeddingFunction for common use cases.

GeminiEmbeddingFunction(
    model_name: str = "gemini-embedding-exp-03-07",
    api_key: Optional[str] = None,
    config: Optional['types.EmbedContentConfig']=None,
    **kwargs,
)

PARAMETERS:

  • model_name (string) -

    The name of the Gemini model to use for encoding. Valid options are gemini-embedding-exp-03-07(default), models/embedding-001, and models/text-embedding-004.

  • api_key (string)-**

The API key for accessing the Gemini API.

  • config (types.EmbedContentConfig) -**

    Optional configuration for the embedding model.

    • The output_dimensionality can be specified to the number of resulting output embeddings.

      Model Name

      Dimensions

      emini-embedding-exp-03-07

      3072(default),1536,768

      models/embedding-001

      768

      models/text-embedding-004

      768

    • The task_type can be specified to generate optimized embeddings for specific tasks, saving you time and cost and improving performance. Only supported in the gemini-embedding-exp-03-07 model.

      Task Type

      Description

      SEMANTIC_SIMILARITY

      Used to generate embeddings that are optimized to assess text similarity.

      CLASSIFICATION

      Used to generate embeddings that are optimized to classify texts according to preset labels.

      CLUSTERING

      Used to generate embeddings that are optimized to cluster texts based on their similarities.

      RETRIEVAL_DOCUMENT, RETRIEVAL_QUERY, QUESTION_ANSWERING, and FACT_VERIFICATION

      Used to generate embeddings that are optimized for document search or information retrieval.

      CODE_RETRIEVAL_QUERY

      Used to retrieve a code block based on a natural language query, such as sort an array or reverse a linked list. Embeddings of the code blocks are computed using RETRIEVAL_DOCUMENT.

Examples

from pymilvus import model

gemini_ef = model.dense.GeminiEmbeddingFunction(
    model_name="gemini-embedding-exp-03-07",
    api_key="YOUR_API_KEY",
)

Try Managed Milvus for Free

Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.

Get Started
Feedback

Was this page helpful?