transformers-js
Was er macht
Dieser Skill lässt die KI Machine-Learning-Funktionen in eine JavaScript- oder TypeScript-App einbauen, ohne Python-Server. Er ist für Web- und App-Entwickler gedacht, die Modelle im Browser oder auf Node.js laufen lassen wollen.
Wann du ihn nutzt
- ✓Wenn Textanalyse, Übersetzung oder Zusammenfassung in einer JavaScript-App laufen sollen.
- ✓Wenn du Bildklassifikation oder Objekterkennung im Browser brauchst.
- ✓Wenn du Spracherkennung oder Audioklassifikation ohne Backend willst.
Link zum Skill
https://github.com/huggingface/skills/blob/main/skills/transformers-js/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Füge meiner React-App eine Stimmungsanalyse hinzu, die das Modell im Browser ausführt, ohne Server.”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Die KI nutzt die Bibliothek Transformers.js, die vortrainierte Modelle über eine Pipeline-API ausführt. Sie übernimmt die Vor- und Nachbearbeitung für die gewählte Aufgabe und läuft auf WebGPU oder WebAssembly, wo verfügbar.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von GitHub.
Transformers.js - Machine Learning for JavaScript
Transformers.js enables running state-of-the-art machine learning models directly in JavaScript across browsers and server-side runtimes (Node.js, Bun, Deno), with no Python 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
npm install @huggingface/transformers
Browser Usage (CDN)
<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:
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 pipe.dispose();
⚠️ Memory Management: All pipelines must be disposed with pipe.dispose() when finished to prevent memory leaks. See examples in Code Examples for cleanup patterns across different environments.
2. Model Selection
You can specify a custom model as the second argument:
const pipe = await pipeline(
'sentiment-analysis',
'Xenova/bert-base-multilingual-uncased-sentiment'
);
Finding Models:
Browse available Transformers.js models on Hugging Face Hub:
- All models: https://huggingface.co/models?library=transformers.js&sort=trending
- By task: Add
pipeline_tagparameter- Text generation: https://huggingface.co/models?pipeline_tag=text-generation&library=transformers.js&sort=trending
- Image classification: https://huggingface.co/models?pipeline_tag=image-classification&library=transformers.js&sort=trending
- Speech recognition: https://huggingface.co/models?pipeline_tag=automatic-speech-recognition&library=transformers.js&sort=trending
Tip: Filter by task type, sort by trending/downloads, and check model cards for performance metrics and usage examples.
3. Device Selection
Choose where to run the model:
// Run on CPU (default for WASM)
const pipe = await pipeline('sentiment-analysis', 'model-id');
// Run on GPU (WebGPU)
const pipe = await pipeline('sentiment-analysis', 'model-id', {
device: 'webgpu',
});
4. Quantization Options
Control model precision vs. performance:
// Use quantized model (faster, smaller)
const pipe = await pipeline('sentiment-analysis', 'model-id', {
dtype: 'q4', // Options: 'fp32', 'fp16', 'q8', 'q4'
});
Supported Tasks
Note: All examples below show basic usage.
Natural Language Processing
Text Classification
const classifier = await pipeline('text-classification');
const result = await classifier('This movie was amazing!');
Named Entity Recognition (NER)
const ner = await pipeline('token-classification');
const entities = await ner('My name is John and I live in New York.');
Question Answering
const qa = await pipeline('question-answering');
const answer = await qa({
question: 'What is the capital of France?',
context: 'Paris is the capital and largest city of France.'
});
Text Generation
const generator = await pipeline('text-generation', 'onnx-community/gemma-3-270m-it-ONNX');
const text = await generator('Once upon a time', {
max_new_tokens: 100,
temperature: 0.7
});
For streaming and chat: See Text Generation Guide for:
- Streaming token-by-token output with
TextStreamer - Chat/conversation format with system/user/assistant roles
- Generation parameters (temperature, top_k, top_p)
- Browser and Node.js examples
- React components and API endpoints
Translation
const translator = await pipeline('translation', 'Xenova/nllb-200-distilled-600M');
const output = await translator('Hello, how are you?'
Häufige Fragen
Braucht er einen Backend-Server?
Nein. Modelle können direkt im Browser oder in Server-Laufzeitumgebungen wie Node.js, Bun oder Deno laufen.
Was ist die Pipeline-API?
Ein einfacher Weg, ein Modell für eine Aufgabe zu laden, der die Schritte vor und nach dem Modelllauf übernimmt.
Wie wird es installiert?
Mit npm oder über ein CDN auf einer Browserseite.
Details
Originalbeschreibung des Autors
Use Transformers.js to run state-of-the-art machine learning models directly in JavaScript/TypeScript. Supports NLP (text classification, translation, summarization), computer vision (image classification, object detection), audio (speech recognition, audio classification), and multimodal tasks. Works in browsers and server-side runtimes (Node.js, Bun, Deno) with WebGPU/WASM using pre-trained models from Hugging Face Hub.
repo: huggingface/skills
Beliebtheit
- GitHub-Sterne
- 11k
- Platz im Ranking
- #11782
- Lizenz
- Apache-2.0
- Aktualisiert
- 30.10.2026
Kommentare
- …
Weitere Skills aus diesem Repository
hf-cli
11kHilft deinem Agenten, das Hugging-Face-Kommandozeilenwerkzeug hf zu nutzen, um Modelle, Datensätze, Spaces und Repositorys herunterzuladen, hochzuladen und den lokalen Cache zu verwalten.
hf-cloud-aws-context-discovery
11kHilft deinem Agenten, dein AWS-Profil, deine Region und Kontodaten zu finden, bevor Cloud-Arbeiten beginnen, damit er nicht rät, welches Konto er nutzen soll.
hf-cloud-python-env-setup
11kHilft deinem Agenten, eine saubere Python-Umgebung mit passender Python-Version und aktuellen Bibliotheken einzurichten, bevor SageMaker- oder AWS-Automatisierung läuft.
hf-cloud-sagemaker-deployment-planner
11kHilft deinem Agenten, die Bereitstellung eines Modells auf Amazon SageMaker zu planen und zwischen Echtzeit-, serverlosem, asynchronem und Batch-Hosting mit sinnvollen Standards zu wählen.
Ähnliche Skills
angular-developer
280kHilft deinem Agenten bei Angular-Code und gibt Tipps zur Projektstruktur. Nützlich für neue Projekte, einzelne Code-Teile sowie Performance und Barrierefreiheit.
frontend-a11y
280kHilft deinem Agenten, Weboberflächen für alle zugänglich zu machen. Sorgt dafür, dass Websites und Apps gut mit Screenreadern und Tastaturnavigation funktionieren.
frontend-patterns
280kLässt deinen Agenten moderne Muster in der Frontend-Entwicklung anwenden. Optimiert Performance, verwaltet State und folgt Best Practices für React und Next.js.