Transformers.js Skill · Data Ai

Master Transformers.js for Browser & Node.js ML

Run 100+ Hugging Face models in Node.js or browsers with Transformers.js v3.8 — WebGPU acceleration, zero Python runtime, and production-ready JavaScript ML inference.

  • Transformers.js
  • Hugging Face
  • Browser ML
  • WebGPU
  • ONNX Runtime

About This Skill

Transformers.js lets you run 100+ Hugging Face models directly in JavaScript — in Node.js 18+ or modern browsers with WebGPU — using 3 core pipelines (text, vision, audio) without any Python runtime.

Quick Start

  1. 1Install: `npm install @huggingface/transformers`
  2. 2Import a pipeline: `import { pipeline } from '@huggingface/transformers'`
  3. 3Call the model: `const result = await pipeline('sentiment-analysis')('I love this!')`
Example Command
npm install @huggingface/transformers

Core Capabilities

Browser & Node.js Runtime

Runs in Node.js 18+ or modern browsers with ES modules — no Python, no server roundtrip for inference.

WebGPU Acceleration

Uses ONNX Runtime Web with WebGPU when available, falling back to WASM for universal compatibility.

100+ Hugging Face Models

Direct access to text, vision, audio, and multi-modal models from the Hugging Face Hub via pipeline API.

Client-Side Privacy

Inference happens on the user's device — prompts and data never leave the browser.

Usage Examples

Before

Python inference service with 400ms round-trip latency per sentiment call.

After

In-browser Transformers.js pipeline returning results in <50ms with no server cost.

Input

Audio file: meeting.wav (30s)

Output

Transcript string via Whisper pipeline in the browser.

Input

Image: product.jpg

Output

['cat (0.87)', 'pet (0.09)', 'animal (0.04)'] via zero-shot image classification.

SKILL.md

---
source: "https://github.com/huggingface/skills/tree/main/skills/transformers-js"
name: transformers-js
description: Run Hugging Face models in JavaScript or TypeScript with Transformers.js in Node.js or the browser.
license: Apache-2.0
risk: unknown
metadata:
  author: huggingface
  version: "3.8.1"
  category: machine-learning
  repository: https://github.com/huggingface/transformers.js
compatibility: Requires Node.js 18+ or modern browser with ES modules support. WebGPU support requires compatible browser/environment. Internet access needed for downloading models from Hugging Face Hub (optional if using local models).
---

# Transformers.js - Machine Learning for JavaScript

Transformers.js enables running state-of-the-art machine learning models directly in JavaScript, both in browsers and Node.js environments, with no server required.

## When to Use This Skill

Use this skill when you need to:
- Run ML models for text analysis, generation, or translation in JavaScript
- Perform image classification, object detection, or segmentation
- Implement speech recognition or audio processing
- Build multimodal AI applications (text-to-image, image-to-text, etc.)
- Run models client-side in the browser without a backend

## Installation

### NPM Installation
```bash
npm install @huggingface/transformers
```

### Browser Usage (CDN)
```javascript
<script type="module">
  import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers';
</script>
```

## Core Concepts

### 1. Pipeline API
The pipeline API is the easiest way to use models. It groups together preprocessing, model inference, and postprocessing:

```javascript
import { pipeline } from '@huggingface/transformers';

// Create a pipeline for a specific task
const pipe = await pipeline('sentiment-analysis');

// Use the pipeline
const result = await pipe('I love transformers!');
// Output: [{ label: 'POSITIVE', score: 0.999817686 }]

// IMPORTANT: Always dispose when done to free memory
await 

Frequently Asked Questions

FAQ

What tool compatibility does Transformers.js have?
Requires Node.js 18+ or a modern browser with ES modules support. WebGPU acceleration requires a compatible browser (Chrome 113+, Edge 113+); otherwise it falls back to WASM.
Who is the target audience?
JavaScript and TypeScript developers, AI engineers, and product teams building in-browser ML features such as on-device search, content moderation, or offline inference.
How does this differ from the Python transformers library?
Transformers.js uses ONNX Runtime instead of PyTorch/TensorFlow, ships pre-converted models, and runs entirely in JavaScript runtimes — no Python process, no GPU server required.
Does it support multi-language models?
Yes. Any Hugging Face model exported to ONNX is usable — multilingual embeddings, translation, cross-lingual classifiers are all supported via the pipeline API.
What results should I expect after deploying it?
Users get sub-100ms on-device inference for typical text classification, eliminating a dedicated ML backend for many use cases and improving privacy because data stays on the client.

Discussion

Discussion

0 comments
U

Trigger Phrases

Use these phrases to activate this skill in your AI coding assistant:

run a Hugging Face model in the browseradd client-side machine learning to my appreplace my Python inference service with JavaScriptenable WebGPU inferencedo on-device transcription with Whisper
Transformers.js AI Agent Skill for Developers & Software