Skip to content
Docs

Command palette

Jump to a page or view, or find a todo by name.

Changelog

Workers AI EmbeddingGemma for the link vault

The repository's architectural decision, rationale and consequences.

Markdown

Date: 2026-10-16. Status: accepted.

Decision

Use Cloudflare Workers AI @cf/google/embeddinggemma-300m through the Worker AI binding. There is no extra provider key. Store vector(768) on link_embedding with the model id and a model version on every row.

FieldValue
ProviderWorkers AI binding (env.AI)
Model id@cf/google/embeddinggemma-300m (EMBEDDING_MODEL)
Version300m (EMBEDDING_MODEL_VERSION)
Dimensions768 (code constant; matches the column)
Input limit512 tokens
Token estimate2 Unicode code points per token (conservative)
Document prefixtitle: {title} | text: {content}
Query prefixtask: search result | query: {q}

A later swap to EmbeddingGemma 2 (google/embeddinggemma-2, not on Workers AI yet) is a config change. The resumable job selects rows whose stored model or version is not the configured pair and re-embeds them.

Consequences

  • Node, Vite, and tests have no AI binding. The adapter is unavailable there; hybrid search returns labeled keyword-only results. Tests inject a deterministic mock.
  • Incompatible vectors are never compared: semantic retrieval filters on the configured model and version.
  • Exact <=> scans only. No ANN index and no pg_vectorsearch.
  • Changing dimensions requires a journaled column migration; do not put N in env.
Edit on GitHubDocumentation is in English.