From fa0b67da2fac917158607b683a6cae41114aa5d4 Mon Sep 17 00:00:00 2001 From: Bogdan Abaev Date: Wed, 9 Sep 2026 13:07:14 -0700 Subject: [PATCH] add calibration versioning To be able to trigger reindexing if calibration changes --- chrome/content/zotero/xpcom/embeddings.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/xpcom/embeddings.js b/chrome/content/zotero/xpcom/embeddings.js index da80c4111b..5f85af75ee 100644 --- a/chrome/content/zotero/xpcom/embeddings.js +++ b/chrome/content/zotero/xpcom/embeddings.js @@ -197,16 +197,22 @@ Zotero.Embeddings = new function () { })); }; + // Bump when how a model is calibrated changes (see Zotero.Embeddings + // .Calibration): stored vectors are centered on the measured mean, so a + // new measurement means a reindex of every model + const CALIBRATION_VERSION = 1; + /** - * Identity of the active embedding function: model name plus its revision. - * Any code change that alters the vectors a model produces (dtype, upstream - * weights, prefixes, pooling) must bump that model's `revision`, so that - * stored embeddings are detected as stale and reindexed (see - * Indexing._ensureIndexMatchesModel()). + * Identity of the active embedding function: model name, its revision and + * the calibration version. Any code change that alters the vectors a model + * produces (dtype, upstream weights, prefixes, pooling) must bump that + * model's `revision`, and a change to calibration must bump + * CALIBRATION_VERSION, so that stored embeddings are detected as stale and + * reindexed (see Indexing._ensureIndexMatchesModel()). * @return {String} */ this.getModelVersion = function () { - return this.getModelName() + '/' + _getModel().revision; + return `${this.getModelName()}/${_getModel().revision}/${CALIBRATION_VERSION}`; }; // The active model's entry in MODELS. Throws when no model is selected: