# /transformers-js: Run Hugging Face models in JavaScript with Transformers.js

Source: https://trendhub.net/skills/huggingface-skills/transformers-js
Skill folder: https://github.com/huggingface/skills/tree/main/skills/transformers-js
Pack: Hugging Face Skills (https://trendhub.net/skills/huggingface-skills)
Works with: Claude Code, Gemini CLI

The transformers-js skill teaches the agent to use Hugging Face's JavaScript library to run models in the browser or in Node, Bun and Deno without a Python server. It covers the pipeline API across text, vision, audio and multimodal tasks, picking compatible models, WebGPU versus WASM, quantised dtypes, caching, progress callbacks and freeing memory.

## When to use it

- You want sentiment, translation or speech recognition running client-side in a web app.
- You need text embeddings in a Node service without a separate ML backend.
- You are choosing between WebGPU and WASM and between fp32 and quantised weights.

## How it works

1. **Install and create a pipeline**: The agent installs the package or imports it from a CDN and builds a task pipeline, optionally with a specific model ID.
2. **Choose a model**: It filters Hub models by the transformers.js library and task, checks for ONNX files and pins a revision for production.
3. **Set device and precision**: It uses WebGPU where supported with WASM as the fallback, and q8 or q4 dtypes to shrink downloads.
4. **Handle loading and errors**: It wires a progress callback for large downloads and wraps pipeline calls in error handling.
5. **Clean up**: It disposes pipelines when they are no longer needed so model memory is released.

## What it steers the agent away from

- Memory leaks from pipelines that are never disposed.
- Picking Hub models that lack ONNX weights.
- Recreating a pipeline for every request instead of reusing it.

## What it can touch

It edits JavaScript or TypeScript code and package dependencies, and the code it writes downloads model files from the Hub at runtime.

## Pairs well with

- `/huggingface-spaces`

## Questions

### Which runtimes does it target?

Modern browsers with ES modules, plus Node.js 18 or later and compatible Bun or Deno runtimes.

### Can models be loaded without internet access?

Yes. The environment settings can disable remote models and point to a local model directory instead.
