Node Details

  • Name: AWSBedrockEmbeddings
  • Type: AWSBedrockEmbeddings
  • Version: 5.0
  • Category: Embeddings

Base Classes

  • AWSBedrockEmbeddings
  • BedrockEmbeddings (from LangChain)

Parameters

Credential (Optional)

  • Type: AWS API Credential

Inputs

  1. Region

    • Type: Async Options (listRegions)
    • Default: “us-east-1”
    • Description: AWS region for the Bedrock service
  2. Model Name

    • Type: Async Options (listModels)
    • Default: “amazon.titan-embed-text-v1”
    • Description: The embedding model to use
  3. Custom Model Name

    • Type: String
    • Optional: Yes
    • Description: If provided, overrides the selected Model Name
  4. Cohere Input Type

    • Type: Options
    • Optional: Yes
    • Description: Specifies the type of input for Cohere models (v3+)
    • Options:
      • search_document
      • search_query
      • classification
      • clustering
  5. Batch Size

    • Type: Number
    • Optional: Yes
    • Default: 50
    • Description: Document batch size for Titan model API calls
  6. Max AWS API retries

    • Type: Number
    • Optional: Yes
    • Default: 5
    • Description: Maximum number of API call retries for Titan model

Functionality

  1. Model Initialization:

    • Sets up the BedrockEmbeddings model with provided parameters
    • Configures AWS credentials if provided
  2. Embedding Generation:

    • For single queries: Uses embedQuery method
    • For multiple documents: Uses embedDocuments method
    • Handles different processing for Titan and Cohere models
  3. Batch Processing:

    • Implements a batch processing system for Titan models to manage API rate limits
    • Includes retry logic with exponential backoff for handling throttling exceptions
  4. Error Handling:

    • Provides specific error messages for invalid responses or exceeded retry limits

Use Cases

  1. Semantic search in vector databases
  2. Text classification tasks
  3. Document clustering
  4. Enhancing natural language processing pipelines

Notes

  • The node dynamically loads available models and regions
  • It supports both Amazon Titan and Cohere embedding models
  • Special handling is implemented for Cohere models, requiring input type specification
  • Batch processing and retry logic are implemented to handle API rate limits efficiently