Skip to content
1 min read · 133 words

Type Alias: CreateTransformersJsPipeline ​

ts
type CreateTransformersJsPipeline = (input: {
  device?: TransformersJsDevice;
  dtype?: TransformersJsDtype;
  model: string;
  onInitProgress?: TransformersJsProgressCallback;
  sessionOptions?: TransformersJsSessionOptions;
}) => Promise<TransformersJsPipeline>;

Defined in: src/batteries/llm/transformers_js/types.ts:123

Factory that loads a text-generation pipeline and resolves it ready to use.

Parameters ​

ParameterTypeDescription
input{ device?: TransformersJsDevice; dtype?: TransformersJsDtype; model: string; onInitProgress?: TransformersJsProgressCallback; sessionOptions?: TransformersJsSessionOptions; }-
input.device?TransformersJsDevice-
input.dtype?TransformersJsDtype-
input.modelstring-
input.onInitProgress?TransformersJsProgressCallback-
input.sessionOptions?TransformersJsSessionOptionsONNX Runtime session options forwarded verbatim to pipeline(...) as session_options.

Returns ​

Promise<TransformersJsPipeline>

Remarks ​

The default factory dynamically imports @huggingface/transformers and calls pipeline('text-generation', model, { device, dtype, … }). Supply a custom factory to control loading, inject a pre-warmed pipeline, or mock it in tests.