Are you an LLM? You can read better optimized documentation at /api/@nhtio/adk/batteries/embeddings/transformers_js/types/interfaces/TransformersJsEmbeddingsAdapterOptions.md for this page in Markdown format
Interface: TransformersJsEmbeddingsAdapterOptions
Defined in: src/batteries/embeddings/transformers_js/types.ts:96
Constructor options for the transformers.js Embeddings adapter.
Remarks
Extends the shared BaseEmbeddingsAdapterOptions (required model + prefix options) with transformers.js pipeline fields. model accepts any ONNX feature-extraction model id (e.g. onnx-community/all-MiniLM-L6-v2-ONNX) — there is no default.
Extends
Properties
| Property | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|
createPipeline? | CreateTransformersJsEmbeddingsPipeline | Override the pipeline factory. Default: pipeline('feature-extraction', …) via dynamic import. | - | src/batteries/embeddings/transformers_js/types.ts:101 |
device? | | "auto" | "gpu" | "cpu" | "wasm" | "webgpu" | "cuda" | "dml" | "coreml" | "webnn" | "webnn-npu" | "webnn-gpu" | "webnn-cpu" | Inference device forwarded to pipeline(). Default: transformers.js environment default. | - | src/batteries/embeddings/transformers_js/types.ts:103 |
dimensions? | number | Declared output dimensionality, surfaced via adapter.dimensions. Optional metadata for callers that pre-allocate buffers; the battery does not enforce it against responses. | BaseEmbeddingsAdapterOptions.dimensions | src/batteries/embeddings/openai/types.ts:84 |
documentPrefix? | string | Instruction prefix prepended to inputs embedded with kind: 'document'. Unset → no prefix. Most asymmetric models (including Arctic) use no document prefix; exposed for symmetry and the models that do. | BaseEmbeddingsAdapterOptions.documentPrefix | src/batteries/embeddings/openai/types.ts:79 |
dtype? | | "auto" | "fp32" | "fp16" | "q8" | "int8" | "uint8" | "q4" | "bnb4" | "q4f16" | "q2" | "q2f16" | "q1" | "q1f16" | Quantization/precision dtype forwarded to pipeline(). | - | src/batteries/embeddings/transformers_js/types.ts:105 |
isAvailable? | () => boolean | Override the availability probe. Default: true whenever the peer is importable (env-neutral). | - | src/batteries/embeddings/transformers_js/types.ts:125 |
model | string | Model id to embed with. Required, no default. For OpenAI this is e.g. text-embedding-3-small; for WebLLM it is an MLC embedding model id (e.g. snowflake-arctic-embed-m-q0f32-MLC). | BaseEmbeddingsAdapterOptions.model | src/batteries/embeddings/openai/types.ts:67 |
modelSource? | TransformersJsEmbeddingsModelSource | Custom model-source resolver (OPFS / separate source / bundled bytes). When set, model files load through it behind the global-env mutex; otherwise straight from HF (unchanged). See TransformersJsEmbeddingsModelSource. | - | src/batteries/embeddings/transformers_js/types.ts:121 |
normalize? | boolean | L2-normalise the embeddings (default true). | - | src/batteries/embeddings/transformers_js/types.ts:109 |
onCompiling? | BatteryLifecycleCallback | Engine/graph/shader compilation after download, before the first token. A COARSE marker: the on-device runtimes (LiteRT Engine.create, transformers.js from_pretrained) expose the boundary — download done, opaque WebGPU/WASM graph build about to run — but NOT a progress stream, so progress is usually absent. Often the slowest part of a cold start; without this it was invisible. | BatteryLifecycleHooks.onCompiling | src/batteries/llm/chat_common/lifecycle.ts:95 |
onComplete? | BatteryLifecycleCallback | After the turn's output is parsed + persisted, before ack (fires per turn). | BatteryLifecycleHooks.onComplete | src/batteries/llm/chat_common/lifecycle.ts:105 |
onError? | BatteryLifecycleCallback | A load or generation failure (paired with nack). | BatteryLifecycleHooks.onError | src/batteries/llm/chat_common/lifecycle.ts:107 |
onGenerating? | BatteryLifecycleCallback | The generate call is in progress (fires per turn). Fires once immediately before the provider call for most engines; engines that stream per-step generation progress (e.g. a diffusion denoise loop) fire it REPEATEDLY during generation, each carrying a progress in 0..1. | BatteryLifecycleHooks.onGenerating | src/batteries/llm/chat_common/lifecycle.ts:103 |
onInitProgress? | ProgressCallback | Called with model-load progress reports while weights download/compile. | - | src/batteries/embeddings/transformers_js/types.ts:123 |
onLifecycle? | BatteryLifecycleCallback | Fires on EVERY phase transition (the firehose). | BatteryLifecycleHooks.onLifecycle | src/batteries/llm/chat_common/lifecycle.ts:86 |
onLoading? | BatteryLifecycleCallback | Weights/runtime loading — may fire repeatedly with progress as the provider reports it. | BatteryLifecycleHooks.onLoading | src/batteries/llm/chat_common/lifecycle.ts:88 |
onReady? | BatteryLifecycleCallback | Engine/pipeline resolved and cached, before the first generation. | BatteryLifecycleHooks.onReady | src/batteries/llm/chat_common/lifecycle.ts:97 |
pipeline? | FeatureExtractionPipeline | A pre-built pipeline. When provided, the battery uses it directly and skips lazy creation. | - | src/batteries/embeddings/transformers_js/types.ts:99 |
pooling? | TransformersJsPooling | Pooling method (default 'mean'). | - | src/batteries/embeddings/transformers_js/types.ts:107 |
poolingOwner? | TransformersJsPoolingOwner | Who pools + normalizes (default 'engine' — today's behavior, byte-identical). Set 'battery' to pool + L2-normalize in deterministic shared JS for tighter node↔browser parity. See TransformersJsPoolingOwner. | - | src/batteries/embeddings/transformers_js/types.ts:115 |
queryPrefix? | string | Instruction prefix prepended to inputs embedded with kind: 'query'. Unset → no prefix. For Snowflake Arctic Embed, the documented value is 'Represent this sentence for searching relevant passages: '. | BaseEmbeddingsAdapterOptions.queryPrefix | src/batteries/embeddings/openai/types.ts:73 |