Skip to main content

Embeddings

Generates embeddings for text content using Google's Gemini API with various task types.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Connection Id - The connection ID obtained from the Connect node.
  • Content - The text content to generate embeddings for.
  • Compare Text - For Semantic Similarity task only - the text to compare against the Content.

Options

  • Title - Title for RETRIEVAL_DOCUMENT task type.
  • TaskType - The type of task for which the embeddings will be used. Options include:
    • Retrieval Query
    • Retrieval Document
    • Semantic Similarity
    • Classification
    • Clustering
    • Question Answering
    • Fact Verification
  • Embedding Model - The model to use for generating embeddings. Default is "text-embedding-004".
  • Output Dimensionality - Reduced dimension count (e.g., 256, 512, 768).
  • Include Statistics - Whether to include token count and truncation information. Default is false.

Output

  • Response - The generated embeddings or similarity score with associated metadata.

How It Works

The Embeddings node generates embeddings for text content using Google's Gemini API. When executed, the node:

  1. Validates the provided connection ID and content
  2. Configures the embedding model (defaults to "text-embedding-004" if not specified)
  3. Sets optional parameters like task type, title, and output dimensionality
  4. For Semantic Similarity task:
    • Generates embeddings for both Content and Compare Text
    • Calculates cosine similarity between the two embeddings
    • Returns the similarity score and optionally the embeddings themselves
  5. For other task types:
    • Generates a single embedding for the Content
    • Returns the embedding values with metadata
  6. Includes statistics if requested and available from the API

Requirements

  • A valid Google Gemini API key
  • Connection ID from a successful Connect node execution
  • Text content to generate embeddings for

Error Handling

The node will return specific errors in the following cases:

  • Empty or invalid Connection ID
  • Empty Content
  • Empty Compare Text (for Semantic Similarity task)
  • Invalid output dimensionality value
  • Title provided for non-RETRIEVAL_DOCUMENT task type
  • API errors from Google's Gemini service

Usage Notes

  • The Title option is only supported for RETRIEVAL_DOCUMENT task type
  • Output dimensionality should be one of the common values: 256, 512, or 768
  • For Semantic Similarity task, both Content and Compare Text are required
  • Statistics include token count and truncation information when available
  • The default embedding model is "text-embedding-004"
  • Cosine similarity is used for Semantic Similarity calculations