Skip to content

Thrall embedding#20

Draft
tonytw1 wants to merge 66 commits into
libvips-croppingfrom
thrall-embedding
Draft

Thrall embedding#20
tonytw1 wants to merge 66 commits into
libvips-croppingfrom
thrall-embedding

Conversation

@tonytw1

@tonytw1 tonytw1 commented Jul 10, 2026

Copy link
Copy Markdown
Member

What does this change?

Embedding runs without the embedding lambda using ImageLoader and Thrall.

Tweaks to the general optionally of the embedder so that the absence of an embedding implementation gracefully ignores the embedding related code paths.

Generalises the embedding implementation then
migrates the embedding implementation from Bedrock to Gemini Embedding 2 for running in Google Cloud.

Embedding implementations define an embeddingSourceImageFormat to indicate what format it needs it's input images to be in.

ImageOperations defines a new createEmbeddingSource to produce this image format.

Image Loader calls createEmbeddingSource during the image upload process placing the formatted image in a new embedding sources S3 Bucket.

Image loader continues to publish the SQS embedding messages but Thrall is now the receiver.

Thrall gets a new SQS listener to consume the embedding messages, call the embedding API and publish the currentUpdateEmbedding messages onto the low priority queue for indexing.

Stores calculated embeddings in an S3 bucket so that they can be reused when reindexing.

Nudges More Like this to be more of a boolean filter and enables it for all images which have an embedding.

Requires this mapping patch:

curl -X PUT "https://<ES_HOST>:9200/<INDEX_NAME>/_mapping" \
    -H "Content-Type: application/json" \
    -d '{
      "properties": {
        "embedding": {
          "dynamic": "strict",
          "properties": {
            "geminiEmbedding2": {
              "dynamic": "strict",
              "properties": {
                "image": {
                  "type": "dense_vector",
                  "dims": 768,
                  "index": true,
                  "similarity": "cosine",
                  "index_options": {
                    "type": "int8_hnsw",
                    "m": 16,
                    "ef_construction": 100
                  }
                }
              }
            }
          }
        }
      }
    }'

How should a reviewer test this change?

How can success be measured?

Who should look at this?

Tested? Documented?

  • locally by committer
  • locally by Guardian reviewer
  • on the Guardian's TEST environment
  • relevant documentation added or amended (if needed)

@tonytw1
tonytw1 force-pushed the thrall-embedding branch 2 times, most recently from 3f685af to 4024c56 Compare July 12, 2026 11:43
@tonytw1
tonytw1 force-pushed the libvips-cropping branch 3 times, most recently from 4ba0933 to 80b4976 Compare July 12, 2026 21:36
@tonytw1
tonytw1 force-pushed the thrall-embedding branch 2 times, most recently from 3f9064e to 11cca56 Compare July 12, 2026 22:05
@tonytw1
tonytw1 force-pushed the libvips-cropping branch from 80b4976 to 5a33669 Compare July 13, 2026 21:06
@tonytw1
tonytw1 force-pushed the thrall-embedding branch 8 times, most recently from 711acd9 to 7ce6b8e Compare July 19, 2026 12:07
@tonytw1
tonytw1 force-pushed the libvips-cropping branch from 5a33669 to 79be6a6 Compare July 19, 2026 12:11
@tonytw1
tonytw1 force-pushed the thrall-embedding branch from 7ce6b8e to 962c3b3 Compare July 19, 2026 12:13
@tonytw1
tonytw1 force-pushed the libvips-cropping branch from 79be6a6 to 5184ad9 Compare July 23, 2026 21:08
@tonytw1
tonytw1 force-pushed the thrall-embedding branch 2 times, most recently from 2c6f748 to 78f709f Compare July 24, 2026 21:42
@tonytw1
tonytw1 force-pushed the libvips-cropping branch from 5184ad9 to f393db1 Compare July 25, 2026 20:04
tonytw1 added 26 commits July 26, 2026 12:02
…e frame.

1200 keeps image loader sub second.
0.9 looks like a usable cutoff for visually similar.
…ry. similar is handled with the knn special case.

Fixes no similar results because of:

```
 "filter": {
      "bool": {
        "must": [
          {
            "match": {
              "similar": {
                "query": "f7bfe3925ac6562dbb7428e32b36c9f5e605a434",
                "operator": "AND"
              }
            }
          }
        ],
        ```
…he SQS message; not ideal for billing and size limits.
@tonytw1
tonytw1 force-pushed the thrall-embedding branch from 777fc52 to 9d69d21 Compare July 26, 2026 11:04
@tonytw1
tonytw1 force-pushed the thrall-embedding branch from 5c1b666 to 9ba87a4 Compare July 26, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant