chore(deps): bump @huggingface/transformers from 3.8.1 to 4.3.1
Bumps @huggingface/transformers from 3.8.1 to 4.3.1.
Release notes
Sourced from @huggingface/transformers's releases.
4.3.1
What's new?
This release adds support for EmbeddingGemma 2. EmbeddingGemma 2 is an open multimodal embedding model built by Google DeepMind which maps text (incl. code), images, video, and audio inputs—and combinations thereof—into a single, unified 768-dimensional vector space. The model has 740M total parameters, combining a 270M parameter text model with modular vision (170M) and audio (300M) encoders.
Text search
The
feature-extractionpipeline returns normalized embeddings, so the dot product of two embeddings is their cosine similarity:import { pipeline, matmul } from "@huggingface/transformers";const extractor = await pipeline("feature-extraction", "onnx-community/embeddinggemma-2-ONNX", { device: "webgpu", // or "wasm" (browser) / "cpu" (Node.js) dtype: "q4", // see "Choosing a dtype" below });
const query = "task: search result | query: Which planet is known as the Red Planet?"; const documents = [ "title: none | text: Venus is often called Earth's twin because of its similar size and proximity.", "title: none | text: Mars, known for its reddish appearance, is often referred to as the Red Planet.", "title: none | text: Jupiter, the largest planet in our solar system, has a prominent red spot.", "title: none | text: Saturn, famous for its rings, is sometimes mistaken for the Red Planet.", ];
const embeddings = await extractor([query, ...documents], { pooling: "mean", normalize: true }); const query_embedding = embeddings.slice([0, 1]); const document_embeddings = embeddings.slice([1, null]);
const scores = (await matmul(query_embedding, document_embeddings.transpose(1, 0))).tolist()[0]; const ranking = scores.map((score, i) => ({ score, document: documents[i] })).sort((a, b) => b.score - a.score); console.log(ranking); // [ // { score: 0.854, document: "title: none | text: Mars, known for its reddish appearance, ..." }, // { score: 0.783, document: "title: none | text: Saturn, famous for its rings, ..." }, // { score: 0.752, document: "title: none | text: Jupiter, the largest planet in our solar system, ..." }, // { score: 0.684, document: "title: none | text: Venus is often called Earth's twin, ..." }, // ]Images, audio and video
For other modalities, use the processor and the model directly. Every input maps into the same embedding space, so any embedding can be compared with any other: here, text queries against an image, an audio clip and a video.
import { AutoModel, AutoProcessor, load_image, load_audio, load_video, cat, matmul } from "@huggingface/transformers";
const model_id = "onnx-community/embeddinggemma-2-ONNX"; const processor = await AutoProcessor.from_pretrained(model_id); </tr></table>
... (truncated)
Commits
511bb61[version] Update to 4.3.1e822439new model (#1788)40d3304Bump doc-builder workflow pin (#1787)836b9cbScope GITHUB_TOKEN permissions per job (#1777)c5f2b97Bump the actions group across 1 directory with 6 updates (#1703)a1728dd[version] Update to 4.3.0f9dec42Bump dependencies (#1766)dce094eMassive documentation overhaul (#1665)37fddf9Fix RawAudio.toBlob() ignoring TypedArray byteOffset/length (#1712)eb5d05eSkip browser cache writes for non-http(s) resources (#1723)- Additional commits viewable in compare view
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebasewill rebase this PR@dependabot recreatewill recreate this PR, overwriting any edits that have been made to it@dependabot show <dependency name> ignore conditionswill show all of the ignore conditions of the specified dependency@dependabot ignore this major versionwill close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor versionwill close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependencywill close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Summary by cubic
Bumps the @huggingface/transformers devDependency from 3.8.1 to 4.3.1 and adds a packageExtensions entry so the new version's Node bundle can resolve onnxruntime-common, which it imports but doesn't declare.
- Brings
onnxruntime-nodeup to 1.30.0 and adds new transitive dependencies (@huggingface/tokenizers,adm-zip). - Upgrades
sharpto 0.35.5, which raises the minimum Node version to >=20.9.0.