transformers-js

Run Hugging Face models in JavaScript with Transformers.js across browser, Node.js, Bun, and Deno.

507|40|Updated Apr 26, 2026
One-click install
npx skills add https://github.com/waybarrios/opencode-power-pack --skill transformers-js-waybarrios
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: transformers-js
Source: https://github.com/waybarrios/opencode-power-pack/tree/main/skills/transformers-js
Command: npx skills add https://github.com/waybarrios/opencode-power-pack --skill transformers-js-waybarrios

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @huggingface/transformers, @huggingface/tokenizers, and includes references (resource) components.

What problem does it solve? Running machine learning inference in JavaScript typically requires a separate Python backend or hosted API. This Skill provides guidance for executing Hugging Face models directly in JavaScript runtimes using Transformers.js, with WebGPU or WASM acceleration and no Python server. ## Core Features & Use Cases - Pipeline API for 30+ tasks: Run NLP, vision, audio, and multimodal tasks like sentiment analysis, object detection, speech recognition, and embeddings with a single pipeline call. - Runtime and performance control: Configure WebGPU or WASM devices, quantization dtypes (fp32/fp16/q8/q4), caching strategies, and progress callbacks for large model downloads. - Production patterns: Use ModelRegistry for preflight cache checks, offline-first loading with local_files_only, streaming text generation, and proper memory cleanup with dispose(). - Use Case: Build a browser-based semantic search feature by loading a quantized embedding model with feature-extraction, showing download progress to users, and caching the model for offline reuse. ## Quick Start Use the transformers-js skill to add client-side sentiment analysis to my web app with a quantized model and a download progress indicator.

Frequently Asked Questions about transformers-js

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run Hugging Face models in JavaScript without Python?▼

Install @huggingface/transformers via npm and call the pipeline function with a task name and model ID. Models run through ONNX Runtime with WASM or WebGPU backends directly in browsers, Node.js, Bun, or Deno.

How do I speed up Transformers.js inference in the browser?▼

Use the WebGPU device option for GPU acceleration where supported, and apply quantization with dtype q8 or q4 to reduce model size and latency. WASM with quantized models is the portable fallback.

Does Transformers.js support streaming text generation?▼

Yes, pass a TextStreamer instance to the generation call with a callback function that receives tokens as they are produced. It works in Node.js, browsers, and React, and supports chat-format message arrays.

Can I use Transformers.js offline or with local models only?▼

Yes, set env.allowRemoteModels to false, enable allowLocalModels with a localModelPath, and pass local_files_only true to pipeline. Use ModelRegistry.is_pipeline_cached to verify assets are cached before going offline.

Why does Transformers.js run out of memory with large models?▼

Models hold 100MB to several GB of memory or GPU resources. Use a smaller or quantized model with dtype q4, reduce batch size, limit max_length, and always call pipe.dispose() when finished to free resources.

How do I show model download progress in Transformers.js?▼

Pass a progress_callback option to pipeline, which receives status events including progress_total for end-to-end percentage and per-file progress events. This works for browser UIs, React state, and CLI output.