Transformers.js documentation
utils/core
Get started
Tutorials
Building a Vanilla JS ApplicationBuilding a React ApplicationBuilding a Next.js ApplicationBuilding a Browser ExtensionBuilding an Electron ApplicationServer-side Inference in Node.jsBuilding a Next.js AI Chatbot with Vercel AI SDK
Developer Guides
Running models on WebGPUUsing quantized models (dtypes)Accessing Private/Gated ModelsServer-side Audio Processing
Integrations
API Reference
You are viewing main version, which requires installation from source. If you'd like
regular npm install, checkout the latest stable version (v3.8.1).
utils/core
Shared types that describe model loading progress.
ProgressInfo and its discriminated-union variants describe the payload
passed to a progress_callback so callers can render download UIs, log
byte counts, and react to the ready event.
Type Definitions
InitiateProgressInfo
Properties
status('initiate') β A file load is about to start.name(string) β The model ID or directory path.file(string) β The name of the file.
DownloadProgressInfo
Properties
status('download') β A file download has started.name(string) β The model ID or directory path.file(string) β The name of the file.
ProgressStatusInfo
Properties
status('progress') β A file download has reported byte progress.name(string) β The model ID or directory path.file(string) β The name of the file.progress(number) β A number between 0 and 100.loaded(number) β The number of bytes loaded.total(number) β The total number of bytes to be loaded.
FileLoadingProgress
Properties
loaded(number) β The number of bytes loaded for this file.total(number) β The total number of bytes for this file.
FilesLoadingMap
A mapping of file names to their loading progress. Each key is a file path and each value contains the loaded and total bytes for that file.
Type: Record<string, FileLoadingProgress>
TotalProgressInfo
Properties
status('progress_total') β Aggregate progress across all files being loaded.name(string) β The model ID or directory path.progress(number) β A number between 0 and 100.loaded(number) β The number of bytes loaded.total(number) β The total number of bytes to be loaded.files(FilesLoadingMap) β A mapping of file names to their loading progress.
DoneProgressInfo
Properties
status('done') β A file has finished loading.name(string) β The model ID or directory path.file(string) β The name of the file.
ReadyProgressInfo
Properties
status('ready') β The requested pipeline is ready to use.task(string) β The loaded task.model(string) β The loaded model.
ProgressInfo
Type: InitiateProgressInfo | DownloadProgressInfo | ProgressStatusInfo | DoneProgressInfo | ReadyProgressInfo | TotalProgressInfo
Callbacks
ProgressCallback
A callback function that is called with progress information.
Parameters
progressInfo(ProgressInfo)
Returns: void