CommunityBildgithub.com

huggingface/transformers-js

Nutzen Sie Transformers.js, um modernste Machine-Learning-Modelle direkt in JavaScript/TypeScript auszuführen. Unterstützt NLP (Textklassifikation, Übersetzung, Zusammenfassung), Computer Vision (Bildklassifikation, Objekterkennung), Audio (Spracherkennung, Audioklassifikation) und multimodale Aufgaben. Läuft in Browsern und serverseitigen Laufzeitumgebungen (Node.js, Bun, Deno) mit WebGPU/WASM unter Verwendung vortrainierter Modelle vom Hugging Face Hub.

Was ist transformers-js?

Der Skill huggingface/transformers-js ermöglicht Entwicklern den direkten Einsatz modernster Machine-Learning-Modelle in JavaScript- oder TypeScript-Anwendungen, ohne auf externe APIs oder Backend-Dienste angewiesen zu sein. Er unterstützt eine breite Palette von Aufgaben, darunter NLP wie Textklassifikation und Übersetzung, Computer Vision wie Bildklassifikation und Objekterkennung, sowie Audioverarbeitung wie Spracherkennung. Dank WebGPU und WASM läuft der Skill effizient im Browser, aber auch in serverseitigen Umgebungen wie Node.js, Bun und Deno. Die Modelle werden über die Hugging Face Hub-Integration bereitgestellt, sodass Entwickler auf eine riesige Bibliothek vortrainierter Modelle zugreifen können. Dies vereinfacht die Integration von KI-Funktionen erheblich und ermöglicht datenschutzfreundliche, latenzarme Anwendungen direkt im Frontend.

Funktioniert mit~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/huggingface/skills/tree/main/skills/transformers-js

Installed? Explore more Bild skills: steipete/songsee, affaan-m/frontend-design, mattpocock/improve-codebase-architecture · View all 6 →

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Was macht transformers-js?

Nutzen Sie Transformers.js, um modernste Machine-Learning-Modelle direkt in JavaScript/TypeScript auszuführen. Unterstützt NLP (Textklassifikation, Übersetzung, Zusammenfassung), Computer Vision (Bildklassifikation, Objekterkennung), Audio (Spracherkennung, Audioklassifikation) und multimodale Aufgaben. Läuft in Browsern und serverseitigen Laufzeitumgebungen (Node.js, Bun, Deno) mit WebGPU/WASM unter Verwendung vortrainierter Modelle vom Hugging Face Hub.

Installation

npm install @huggingface/transformers

Oder für Deno:

deno add npm:@huggingface/transformers

Grundlegende Verwendung

Textklassifikation (Browser/Node.js)

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

// Erstellen einer Textklassifikations-Pipeline
const classifier = await pipeline('sentiment-analysis');

const result = await classifier('Ich liebe Transformers.js!');
console.log(result);
// [{ label: 'POSITIVE', score: 0.999876 }]

Bildklassifikation

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

const classifier = await pipeline('image-classification');

const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/tiger.jpg';
const result = await classifier(url);
console.log(result);
// [{ label: 'tiger', score: 0.892 }]

Unterstützte Aufgaben

AufgabePipeline-NameBeispiele
Textklassifikationsentiment-analysisStimmungsanalyse
ÜbersetzungtranslationÜbersetzung zwischen Sprachen
ZusammenfassungsummarizationTextzusammenfassung
Bildklassifikationimage-classificationObjekterkennung
Objekterkennungobject-detectionEchtzeit-Objekterkennung
Spracherkennungautomatic-speech-recognitionTranskription
Audioklassifikationaudio-classificationAudio-Labeling
Textgenerierungtext-generationTextvervollständigung

Konfiguration (WebGPU/WASM)

Standardmäßig wählt Transformers.js automatisch den besten verfügbaren Backend aus (webgpu oder wasm). Sie können den Backend manuell festlegen:

import { env } from '@huggingface/transformers';

// WebGPU erzwingen (bevorzugt für GPU-Beschleunigung)
env.backends.onnx.backend = 'webgpu';

// Oder WASM erzwingen (fallback)
env.backends.onnx.backend = 'wasm';

Modelle vom Hugging Face Hub verwenden

Sie können jedes kompatible Modell vom Hugging Face Hub mit seiner ID referenzieren:

const classifier = await pipeline('sentiment-analysis', {
  model: 'Xenova/distilbert-base-uncased-finetuned-sst-2-english'
});

Fehlerbehandlung

try {
  const result = await classifier('Beispieltext');
} catch (error) {
  console.error('Fehler bei der Ausführung des Machine-Learning-Modells:', error);
}

Unterstützte Laufzeitumgebungen

  • Browser: Modern browsers with WebGPU/WASM support (Chrome, Edge, Firefox, Safari 15+)
  • Node.js: Node.js 18+ mit --experimental-wasm-threads Flag
  • Bun: Bun 1.0+
  • Deno: Deno 1.30+

Ressourcen

Individual skills in this repo

This repo contains 5 individual skills — each has its own dedicated page.

huggingface/hf-cli

Hugging Face Hub CLI (`hf`) for downloading, uploading, and managing models, datasets, spaces, buckets, repos, papers, jobs, and more on the Hugging Face Hub. Use when: handling authentication; managing local cache; managing Hugging Face Buckets; running or scheduling jobs on Hugging Face infrastructure; managing Hugging Face repos; discussions and pull requests; browsing models, datasets and spaces; reading, searching, or browsing academic papers; managing collections; querying datasets; configuring spaces; setting up webhooks; or deploying and managing HF Inference Endpoints. Make sure to use this skill whenever the user mentions 'hf', 'huggingface', 'Hugging Face', 'huggingface-cli', or 'hugging face cli', or wants to do anything related to the Hugging Face ecosystem and to AI and ML in general. Also use for cloud storage needs like training checkpoints, data pipelines, or agent traces. Use even if the user doesn't explicitly ask for a CLI command. Replaces the deprecated `huggingface-cli`.

huggingface/huggingface-datasets

Use this skill for Hugging Face Dataset Viewer API workflows that fetch subset/split metadata, paginate rows, search text, apply filters, download parquet URLs, and read size or statistics.

huggingface/huggingface-gradio

Build Gradio web UIs and demos in Python. Use when creating or editing Gradio apps, components, event listeners, layouts, or chatbots.

huggingface/huggingface-llm-trainer

Train or fine-tune language and vision models using TRL (Transformer Reinforcement Learning) or Unsloth with Hugging Face Jobs infrastructure. Covers SFT, DPO, GRPO and reward modeling training methods, plus GGUF conversion for local deployment. Includes guidance on the TRL Jobs package, UV scripts with PEP 723 format, dataset preparation and validation, hardware selection, cost estimation, Trackio monitoring, Hub authentication, model selection/leaderboards and model persistence. Use for tasks involving cloud GPU training, GGUF conversion, or when users mention training on Hugging Face Jobs without local GPU setup.

huggingface/huggingface-papers

Look up and read Hugging Face paper pages in markdown, and use the papers API for structured metadata such as authors, linked models/datasets/spaces, Github repo and project page. Use when the user shares a Hugging Face paper page URL, an arXiv URL or ID, or asks to summarize, explain, or analyze an AI research paper.

Verwandte Skills