CLIP
The CLIP embedding processor leverages OpenAI CLIP models to create vector embeddings for image documents. It deploys the required infrastructure to create embeddings on an AWS account such that all the processing remains on customers AWS environment.
đˇ Embedding Images
To use this middleware, you import it in your CDK stack and specify a VPC in which the image processing cluster will be deployed.
âšī¸ The below example shows how to deploy the CLIP processor in a VPC.
Specifying a Model
The ClipImageProcessor
API makes it possible to specify a select CLIP model to use for creating embeddings.
âšī¸ The default model is
ViT-B/32
, and this middleware supports theViT-B/32
,ViT-B/16
, andViT-L/14
models.
Auto-Scaling
The cluster of containers deployed by this middleware will auto-scale based on the number of images that need to be processed. The cluster scales up to a maximum of 5 instances by default, and scales down to zero when there are no images to process.
âšī¸ You can configure the maximum amount of instances that the cluster can auto-scale to by using the
withMaxInstances
method.
đ Output
The CLIP image processor middleware does not modify or alter source documents in any way. It instead enriches the metadata of the image documents with a pointer to the vector embedding that were created for the document.
đ Click to expand example
đī¸ Architecture
The CLIP image processor requires GPU-enabled instances (g4dn.xlarge) to run the embedding models. To orchestrate deployments, it deploys an ECS auto-scaled cluster of containers that consume documents from the middleware input queue. The cluster is deployed in the private subnet of the given VPC, and caches the models on an EFS storage to optimize cold-starts.
âšī¸ The average cold-start for the CLIP containers is around 3 minutes when no instances are running.
đˇī¸ Properties
Supported Inputs
Mime Type | Description |
---|---|
image/bmp | Bitmap image. |
image/gif | GIF image. |
image/jpeg | JPEG image. |
image/png | PNG image. |
image/tiff | TIFF image. |
image/webp | WebP image. |
image/x-pcx | PCX image. |
Supported Outputs
This middleware supports as outputs the same types as the supported inputs.
Supported Compute Types
Type | Description |
---|---|
GPU | This middleware only supports GPU compute. |
đ Examples
- Clip Embedding Pipeline - An example showcasing how to create embeddings for images using CLIP.