Migrate @xenova/transformers → @huggingface/transformers#18
Merged
Conversation
@xenova/transformers is frozen at 2.17.2 and pins onnxruntime-web@1.14, which drags in onnx-proto and protobufjs@6.11.x — the last critical (prototype pollution / arbitrary code execution) plus several highs. Those advisories have no fix on the 6.x line, and the vulnerable code sits in the browser ONNX backend this Node CLI never runs, so overrides couldn't help. transformers.js moved to the official @huggingface/transformers package, whose current release builds on onnxruntime-web with protobufjs@^7.2.4 (fixed) and sharp@^0.34 (fixed). - Swap the dependency to @huggingface/transformers@^4.2.0. - embeddings.ts: use the canonical "feature-extraction" task (the v2 "embeddings" alias) and the v3+ `dtype: "fp32"` option in place of the removed `quantized: false` (both mean full-precision weights). npm audit: 7 -> 3, and 0 critical / 0 high / 0 moderate in production dependencies. The remaining 3 are dev/build-tool moderates (esbuild / tsup / tsx). Verified: npm run build, tsc --noEmit, npm test (23 pass), npm run lint, npm run format:check all green, plus an end-to-end embedding run (init + embed of a sample string) producing a 384-dimensional, L2-normalized vector (norm = 1.0000) — matching the Pinecone index's `dimension: 384`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause #2 of 3
@xenova/transformersis frozen at 2.17.2 and pinsonnxruntime-web@1.14, which drags inonnx-protoandprotobufjs@6.11.x— the last critical (prototype pollution / arbitrary code execution) plus several highs. Those advisories have no fix on the 6.x line, and the vulnerable code lives in the browser ONNX backend this Node CLI never executes, so overrides were useless. transformers.js has moved to the official@huggingface/transformerspackage, whose current release builds ononnxruntime-webwithprotobufjs@^7.2.4(fixed) andsharp@^0.34(fixed).Changes
@huggingface/transformers@^4.2.0.embeddings.ts: use the canonical"feature-extraction"task (what v2's"embeddings"aliased to) and the v3+dtype: "fp32"option in place of the removedquantized: false— both request full-precision weights, so behavior is unchanged.That's the whole code change; the model ID
"Xenova/all-MiniLM-L6-v2"is a Hugging Face Hub model (not the npm package) and works unchanged.Impact
npm audit: 7 → 3, with 0 critical / 0 high / 0 moderate in production dependencies. The remaining 3 are dev/build-tool moderates (esbuild/tsup/tsx).Verification
npm run build,tsc --noEmit,npm test(23 pass),npm run lint,npm run format:check— all green.embedder.init("Xenova/all-MiniLM-L6-v2")+embed(...)downloads the model and returns a 384-dimensional, L2-normalized vector (norm = 1.0000) — matching the index'sdimension: 384.Where this leaves the repo
From ~69 Dependabot alerts / 46
npm auditfindings down to 3 moderate, all in dev/build tooling (esbuild/tsup/tsx), with zero critical/high/moderate in shipped dependencies — achieved entirely by removing/upgrading root deps, no version overrides.🤖 Generated with Claude Code