Skip to content
1 min read · 154 words

@nhtio/adk/batteries/embeddings/transformers_js/adapter

transformers.js (ONNX, dual-environment) Embeddings adapter battery.

Remarks

Embeddings battery backed by transformers.js's feature-extraction pipeline. Environment-neutral — runs in Node (via onnxruntime-node) and the browser (via onnxruntime-web / WebGPU), auto- selected by the package; there is no WebGPU requirement, so this battery is surfaced from the environment-neutral @nhtio/adk/batteries/embeddings barrel alongside the OpenAI one.

Same user-facing surface as the OpenAI / WebLLM embeddings batteries (isAvailable / dimensions / preload / reset / embed / embedMany), same number[] return shape, same query/document prefix handling (the shared applyEmbeddingPrefix).

@huggingface/transformers is an optional peer dependency, imported lazily.

Cross-runtime vector caveat: embeddings produced here are not guaranteed bit-identical to those from a different runtime (WebLLM/MLC, or even node-ONNX vs web-ONNX for the same model). A vector corpus must be embedded AND queried by one backend.

Classes

ClassDescription
TransformersJsEmbeddingsAdapterEmbeddings adapter for transformers.js's feature-extraction pipeline.