chore(embeddings): upgrade Transformers.js to v4#125
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the CrossEncoderTokenizer interface and its usage in the reranker to align with Hugging Face Transformers tokenizer options, refactors release tests to dynamically use the package version instead of hardcoded strings, and introduces path normalization in contextbench tests to ensure consistent path comparisons. Feedback suggests correcting return_tensor to return_tensors in the tokenizer interface and safely handling an optional options parameter in the test mock to avoid potential runtime errors.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
acb7cba to
e1ba165
Compare
The released branch was loading transformers 3.8.1 correctly, but the reranker was calling the tokenizer in a shape that ignored the passage. Keep the dependency on the released package version and make the recovery test assert the text_pair call so this does not slip back.
The repo is already on 2.3.0, but the release truth test and manual publish fallback were still pinned to 2.2.0. Derive the assertions from package metadata and normalize macOS temp paths so the full suite checks the real contract instead of local path spelling.
e1ba165 to
b51adeb
Compare
Move the local embedding and reranker integrations onto the stable v4 API and ONNX Runtime 1.24.3. This removes the macOS crash dependency while preserving the tokenizer pair fix already covered by this branch.
Remove secret-named variables before Vitest starts and suppress Node loader deprecations in the CLI subprocess contract. This keeps ContextBench fixtures free of operator environment values and preserves meaningful stderr assertions on Node 26.
Summary
@huggingface/transformersfrom^3.8.1to the current stable^4.2.0.onnxruntime-node@1.24.2to the v4 dependency version,1.24.3.FeatureExtractionPipelineandPreTrainedTokenizertypes.text_pair.Closes #72.
Why
Issue #72 was opened while Transformers.js v4 was still prerelease. v4 is now stable on npm, and the current release uses the ONNX Runtime family that contains the macOS mutex-destruction fix tracked by #68.
The package's pipeline/model-loading APIs used here remain behaviorally compatible. The breaking change in this codebase was limited to exported TypeScript type names.
macOS verification
Tested on macOS 26.5.2 (arm64), Node v26.5.0:
active.mutex lock failed: Invalid argumenthard-crash did not reproduce.This is evidence for the tested Apple Silicon environment; it is not a claim that every macOS/Node combination has been exhaustively covered.
Verification
pnpm run type-checkpnpm run buildpnpm run format:checkpnpm test— 602 tests passed