transformers-js
O que ela faz
Esta skill permite que a IA adicione recursos de machine learning a um app em JavaScript ou TypeScript sem um servidor em Python. É para desenvolvedores web e de apps que querem que os modelos rodem no navegador ou no Node.js.
Quando usar
- ✓Quando você quer análise de texto, tradução ou resumo rodando dentro de um app em JavaScript.
- ✓Quando você precisa de classificação de imagens ou detecção de objetos no navegador.
- ✓Quando você quer reconhecimento de fala ou classificação de áudio sem um backend.
Link da skill
https://github.com/huggingface/skills/blob/main/skills/transformers-js/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Adicione uma verificação de sentimento ao meu app em React que rode o modelo no navegador, sem precisar de servidor.”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
A IA usa a biblioteca Transformers.js, que roda modelos pré-treinados por meio de uma API de pipeline. Ela cuida do pré-processamento e da saída para a tarefa que você escolher e roda em WebGPU ou WebAssembly quando disponíveis.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do 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?'
Perguntas frequentes
Precisa de um servidor de backend?
Não. Os modelos podem rodar diretamente no navegador ou em runtimes de servidor, como Node.js, Bun ou Deno.
O que é a API de pipeline?
É uma forma simples de carregar um modelo para uma tarefa, cuidando das etapas antes e depois da execução do modelo.
Como se instala?
Ela é instalada com npm ou carregada de uma CDN em uma página do navegador.
Detalhes
Descrição original do autor
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
Popularidade
- Estrelas no GitHub
- 11 mil
- Posição no ranking
- #11782
- Licença
- Apache-2.0
- Atualizada em
- 30/10/2026
Comentários
- …
Mais skills deste repositório
hf-cli
11 milAjuda seu agente a usar a ferramenta de linha de comando da Hugging Face para baixar, enviar e gerenciar modelos, datasets, Spaces, repositórios e o cache local.
hf-cloud-aws-context-discovery
11 milAjuda seu agente a encontrar seu perfil, região e dados da conta AWS antes de qualquer trabalho na nuvem, para que ele não adivinhe qual conta usar.
hf-cloud-python-env-setup
11 milAjuda seu agente a montar um ambiente Python limpo, com uma versão adequada e bibliotecas atuais, antes de executar automações do SageMaker ou da AWS.
hf-cloud-sagemaker-deployment-planner
11 milAjuda seu agente a planejar a implantação de um modelo no Amazon SageMaker, escolhendo hospedagem em tempo real, sem servidor, assíncrona ou em lote, com padrões sensatos.
Skills parecidas
angular-developer
280 milAjuda seu agente a criar código Angular e a dar conselhos sobre a estrutura do projeto. É útil para iniciar novos projetos, criar partes do código ou melhorar a performance e acessibilidade.
frontend-a11y
280 milAjuda seu agente a tornar interfaces web acessíveis para todos. Ele garante que sites e apps funcionem bem com leitores de tela e navegação por teclado.
frontend-patterns
280 milFaz seu agente aplicar padrões modernos no desenvolvimento frontend. Ele otimiza performance, gerencia estado e segue boas práticas em React e Next.js.