Skip to content
2 min read · 375 words

@nhtio/adk/batteries/embeddings/transformers_js/types ​

Option and pipeline types for the transformers.js Embeddings adapter.

Remarks ​

Builds on the shared embeddings option base owned by the OpenAI Embeddings battery (@nhtio/adk/batteries/embeddings/openai/types!BaseEmbeddingsAdapterOptions). Adds the transformers.js feature-extraction knobs. transformers.js is environment-neutral (Node + browser, ONNX Runtime auto-selected) — no WebGPU requirement.

Pipeline/dtype/device shapes are local aliases of @huggingface/transformers types, never direct re-exports of the externalized peer.

Interfaces ​

InterfaceDescription
TransformersJsEmbeddingsAdapterOptionsConstructor options for the transformers.js Embeddings adapter.

Type Aliases ​

| Type Alias | Description | | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------ | ----- | ----- | --- | | CreateTransformersJsEmbeddingsPipeline | Factory for lazily creating a feature-extraction pipeline. Defaults to a dynamic import of @huggingface/transformers + pipeline('feature-extraction', …); override to inject a pre-built pipeline or a test double. | | TransformersJsEmbeddingsDataType | Quantization/precision dtype: 'auto' | 'fp32' | 'fp16' | 'q8' | 'q4' | …. | | TransformersJsEmbeddingsDeviceType | Inference device: 'auto' | 'webgpu' | 'wasm' | 'cpu' | 'gpu' | …. | | TransformersJsEmbeddingsModelSource | Custom model-source resolver — the dual-environment seam for serving model files from OPFS, a different source, or bundled bytes (see the LLM battery's model_source module). Called once per file; return bytes / a path-or-URL string / a Response, or undefined to fall through to HF. | | TransformersJsEmbeddingsPipeline | The transformers.js feature-extraction pipeline this battery drives. | | TransformersJsEmbeddingsProgressCallback | Model-load progress callback. | | TransformersJsPooling | The pooling method applied to the model's per-token hidden states to produce one sentence vector. | | TransformersJsPoolingOwner | Who applies pooling + L2-normalization: - 'engine' (default) — the transformers.js pipeline pools internally (today's exact behavior). Each runtime (node-ONNX vs web-ONNX/WebGPU) pools its own way, contributing to the node↔browser vector gap. - 'battery' — request raw pooling:'none' token states and pool + normalize in deterministic shared JS (one implementation, identical across node + browser), removing post-processing variance and leaving only the irreducible ORT-kernel floor. pooling/normalize then take effect in OUR code. |

References ​

BaseEmbeddingsAdapterOptions ​

Re-exports BaseEmbeddingsAdapterOptions


BatteryLifecycleBattery ​

Re-exports BatteryLifecycleBattery


BatteryLifecycleCallback ​

Re-exports BatteryLifecycleCallback


BatteryLifecycleHooks ​

Re-exports BatteryLifecycleHooks


BatteryLifecyclePhase ​

Re-exports BatteryLifecyclePhase


BatteryLifecycleReport ​

Re-exports BatteryLifecycleReport


EmbeddingKind ​

Re-exports EmbeddingKind


EmbedOptions ​

Re-exports EmbedOptions