mirror of
https://github.com/lancedb/lancedb.git
synced 2026-12-03 07:45:17 +00:00
## Summary Use Transformers.js mean pooling with the tokenizer's attention mask so padding positions do not contribute to source and query embeddings. ## Validation - A deterministic model and tokenizer fixture uses actual Transformers.js Tensor objects and compares the same short text embedded alone and in a padded batch. On main its vector changes from `[1, 5]` to `[50.5, 102.5]`. With the fix it stays `[1, 5]` and the longer text's expected vector remains `[4, 8]`. - Existing Transformers and embedding Jest suites on Node 24: 20 passed, 1 skipped (OpenAI key required). TypeScript build and Biome checks passed. - Used Transformers.js 4.3.2 with the ONNX Web tensor runtime for fixture-only tests. Model downloads and inference were disabled. Fixes https://github.com/lancedb/lancedb/issues/5281 --------- Co-authored-by: Divyam Talwar <DivyamTalwar@users.noreply.github.com>