Transformers.js documentation

transformers

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).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

transformers

Public API of @huggingface/transformers. Everything re-exported from this file is considered stable — other imports are internal and may change.

Start here

Model loading

  • Pipelines — task-specific pipeline classes (TextGenerationPipeline, etc.).
  • ModelsAutoModel* classes (one per task).
  • TokenizersAutoTokenizer, chat templates, Message.
  • ProcessorsAutoProcessor, AutoImageProcessor, AutoFeatureExtractor.
  • ConfigsAutoConfig / PretrainedConfig.

Generation

Data types and I/O

  • TensorsTensor, shape ops, math, I/O.
  • ImagesRawImage, load_image().
  • AudioRawAudio, load_audio().
  • VideoRawVideo, RawVideoFrame, load_video() (experimental).

Utilities

  • Hub options — shared from_pretrained() option shapes.
  • Mathssoftmax, cos_sim, typed-array helpers.
  • Model registry — inspect or clear the model cache.
  • Random — seedable MT19937 PRNG matching Python’s random.

Type Definitions

DeviceType

Type: keyof typeof DEVICE_TYPES

DataType

Type: keyof typeof DATA_TYPES

Update on GitHub