Embeddings
AWS Bedrock Embeddings
The AWS Bedrock Embeddings node is a component that integrates AWS Bedrock’s embedding models into a larger system, allowing for the generation of embeddings for given text inputs. This node is particularly useful for tasks such as semantic search, text classification, and clustering.
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
-
Region
- Type: Async Options (listRegions)
- Default: “us-east-1”
- Description: AWS region for the Bedrock service
-
Model Name
- Type: Async Options (listModels)
- Default: “amazon.titan-embed-text-v1”
- Description: The embedding model to use
-
Custom Model Name
- Type: String
- Optional: Yes
- Description: If provided, overrides the selected Model Name
-
Cohere Input Type
- Type: Options
- Optional: Yes
- Description: Specifies the type of input for Cohere models (v3+)
- Options:
- search_document
- search_query
- classification
- clustering
-
Batch Size
- Type: Number
- Optional: Yes
- Default: 50
- Description: Document batch size for Titan model API calls
-
Max AWS API retries
- Type: Number
- Optional: Yes
- Default: 5
- Description: Maximum number of API call retries for Titan model
Functionality
-
Model Initialization:
- Sets up the BedrockEmbeddings model with provided parameters
- Configures AWS credentials if provided
-
Embedding Generation:
- For single queries: Uses
embedQuery
method - For multiple documents: Uses
embedDocuments
method - Handles different processing for Titan and Cohere models
- For single queries: Uses
-
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
-
Error Handling:
- Provides specific error messages for invalid responses or exceeded retry limits
Use Cases
- Semantic search in vector databases
- Text classification tasks
- Document clustering
- 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