Image embeddings
The GenAI plugin allows you to generate vector embeddings for images. These embeddings can be used for visual similarity search or multi-modal analysis within your Neo4j graph. You can provide images as base64-encoded strings, local file paths, or remote URLs.
Generate a single image embedding
Use the ai.image.embed() function to generate a vector embedding for a single image.
Syntax |
|
||
Description |
Encode a given image as a vector using the named provider. |
||
Inputs |
Name |
Type |
Description |
|
|
The image to transform into an embedding: either base64-encoded image bytes, a local file path ( |
|
|
|
The identifier of the provider: |
|
|
|
Provider specific configuration. Use |
|
Returns |
|
The generated vector embedding for the image. |
|
Generate a batch of image embeddings
Use the ai.image.embedBatch() procedure to generate embeddings for a list of images in a single call.
Syntax |
|
||
Description |
Encode a given batch of images as vectors using the named provider. |
||
Inputs |
Name |
Type |
Description |
|
|
The images to transform into embeddings: base64-encoded image bytes, local file paths ( |
|
|
|
The identifier of the provider: |
|
|
|
Provider specific configuration. |
|
Returns |
Name |
Type |
Description |
|
|
The index of the corresponding element in the input list. |
|
|
|
The resolved resource element (base64 bytes). |
|
|
|
The generated vector embedding for the resource. |
|
Image embedding providers
Use ai.image.embed.providers() to list the available image vector embedding providers and their configuration.
CALL ai.image.embed.providers()
| name | requiredConfigType | optionalConfigType | defaultConfig |
|---|---|---|---|
|
|
|
|
|
|
|
|
Examples
The following examples show how to generate and store image embeddings.
RETURN ai.image.embed(
"https://example.com/image.jpg",
"VertexAI",
{
project: $project,
region: "us-central1",
apiKey: $apiKey
}
) AS vector
MATCH (p:Product)
WHERE p.imagePath IS NOT NULL
WITH collect(p) AS products
CALL ai.image.embedBatch(
[p IN products | "file://" + p.imagePath],
"Bedrock-Titan",
{
region: "us-east-1",
accessKeyId: $accessKey,
secretAccessKey: $secretKey
}
) YIELD index, vector
SET (products[index]).embedding = vector
RETURN count(*) AS count
Provider configuration
For more details on the configuration parameters for each provider, see the following sections:
-
Amazon Bedrock Models (specifically the Bedrock-Titan model)