🛠️ Transformers
文章や画像を理解したり生成したりするAIモデル「
📺 まず動画で見る(YouTube)
▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗
※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。
📜 元の英語説明(参考)
This skill should be used when working with pre-trained transformer models for natural language processing, computer vision, audio, or multimodal tasks. Use for text generation, classification, question answering, translation, summarization, image classification, object detection, speech recognition, and fine-tuning models on custom datasets.
🇯🇵 日本人クリエイター向け解説
文章や画像を理解したり生成したりするAIモデル「
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o transformers.zip https://jpskill.com/download/4253.zip && unzip -o transformers.zip && rm transformers.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/4253.zip -OutFile "$d\transformers.zip"; Expand-Archive "$d\transformers.zip" -DestinationPath $d -Force; ri "$d\transformers.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
transformers.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
transformersフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-18
- 同梱ファイル
- 6
💬 こう話しかけるだけ — サンプルプロンプト
- › Transformers を使って、最小構成のサンプルコードを示して
- › Transformers の主な使い方と注意点を教えて
- › Transformers を既存プロジェクトに組み込む方法を教えて
これをClaude Code に貼るだけで、このSkillが自動発動します。
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Transformers
概要
Hugging Face Transformersライブラリは、NLP、コンピュータービジョン、オーディオ、マルチモーダルドメインにわたるタスクのために、何千もの事前学習済みモデルへのアクセスを提供します。このスキルを使用して、モデルのロード、推論の実行、カスタムデータでのファインチューニングを行います。
インストール
transformersとコア依存関係をインストールします。
uv pip install torch transformers datasets evaluate accelerate
ビジョンタスクには、以下を追加します。
uv pip install timm pillow
オーディオタスクには、以下を追加します。
uv pip install librosa soundfile
認証
Hugging Face Hub上の多くのモデルは認証を必要とします。アクセスを設定してください。
from huggingface_hub import login
login() # プロンプトに従ってトークンを入力してください
または環境変数を設定します。
export HUGGINGFACE_TOKEN="your_token_here"
トークンは https://huggingface.co/settings/tokens で取得できます。
クイックスタート
手動での設定なしに高速な推論を行うには、Pipeline APIを使用します。
from transformers import pipeline
# テキスト生成
generator = pipeline("text-generation", model="gpt2")
result = generator("The future of AI is", max_length=50)
# テキスト分類
classifier = pipeline("text-classification")
result = classifier("This movie was excellent!")
# 質問応答
qa = pipeline("question-answering")
result = qa(question="What is AI?", context="AI is artificial intelligence...")
コア機能
1. 高速推論のためのパイプライン
多くのタスクでシンプルかつ最適化された推論に使用します。テキスト生成、分類、NER、質問応答、要約、翻訳、画像分類、物体検出、音声分類などをサポートしています。
使用する場面: 迅速なプロトタイピング、シンプルな推論タスク、カスタムの前処理が不要な場合。
包括的なタスクのカバー範囲と最適化については、references/pipelines.md を参照してください。
2. モデルのロードと管理
設定、デバイス配置、精度を細かく制御して、事前学習済みモデルをロードします。
使用する場面: カスタムモデルの初期化、高度なデバイス管理、モデルの検査。
ロードパターンとベストプラクティスについては、references/models.md を参照してください。
3. テキスト生成
様々なデコーディング戦略(greedy、ビームサーチ、サンプリング)と制御パラメータ(temperature、top-k、top-p)を使用して、LLMでテキストを生成します。
使用する場面: 創造的なテキスト生成、コード生成、会話型AI、テキスト補完。
生成戦略とパラメータについては、references/generation.md を参照してください。
4. トレーニングとファインチューニング
自動混合精度、分散トレーニング、ロギングを備えたTrainer APIを使用して、カスタムデータセットで事前学習済みモデルをファインチューニングします。
使用する場面: タスク固有のモデル適応、ドメイン適応、モデル性能の向上。
トレーニングワークフローとベストプラクティスについては、references/training.md を参照してください。
5. トークン化
パディング、切り捨て、特殊トークン処理を行い、テキストをモデル入力用のトークンおよびトークンIDに変換します。
使用する場面: カスタム前処理パイプライン、モデル入力の理解、バッチ処理。
トークン化の詳細については、references/tokenizers.md を参照してください。
一般的なパターン
パターン1: シンプルな推論
簡単なタスクには、パイプラインを使用します。
pipe = pipeline("task-name", model="model-id")
output = pipe(input_data)
パターン2: カスタムモデルの使用
高度な制御には、モデルとトークナイザーを個別にロードします。
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("model-id")
model = AutoModelForCausalLM.from_pretrained("model-id", device_map="auto")
inputs = tokenizer("text", return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=100)
result = tokenizer.decode(outputs[0])
パターン3: ファインチューニング
タスク適応には、Trainerを使用します。
from transformers import Trainer, TrainingArguments
training_args = TrainingArguments(
output_dir="./results",
num_train_epochs=3,
per_device_train_batch_size=8,
)
trainer = Trainer(
model=model,
args=training_args,
train_dataset=train_dataset,
)
trainer.train()
リファレンスドキュメント
特定のコンポーネントに関する詳細情報については、以下を参照してください。
- Pipelines:
references/pipelines.md- サポートされているすべてのタスクと最適化 - Models:
references/models.md- ロード、保存、および設定 - Generation:
references/generation.md- テキスト生成戦略とパラメータ - Training:
references/training.md- Trainer APIによるファインチューニング - Tokenizers:
references/tokenizers.md- トークン化と前処理
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Transformers
Overview
The Hugging Face Transformers library provides access to thousands of pre-trained models for tasks across NLP, computer vision, audio, and multimodal domains. Use this skill to load models, perform inference, and fine-tune on custom data.
Installation
Install transformers and core dependencies:
uv pip install torch transformers datasets evaluate accelerate
For vision tasks, add:
uv pip install timm pillow
For audio tasks, add:
uv pip install librosa soundfile
Authentication
Many models on the Hugging Face Hub require authentication. Set up access:
from huggingface_hub import login
login() # Follow prompts to enter token
Or set environment variable:
export HUGGINGFACE_TOKEN="your_token_here"
Get tokens at: https://huggingface.co/settings/tokens
Quick Start
Use the Pipeline API for fast inference without manual configuration:
from transformers import pipeline
# Text generation
generator = pipeline("text-generation", model="gpt2")
result = generator("The future of AI is", max_length=50)
# Text classification
classifier = pipeline("text-classification")
result = classifier("This movie was excellent!")
# Question answering
qa = pipeline("question-answering")
result = qa(question="What is AI?", context="AI is artificial intelligence...")
Core Capabilities
1. Pipelines for Quick Inference
Use for simple, optimized inference across many tasks. Supports text generation, classification, NER, question answering, summarization, translation, image classification, object detection, audio classification, and more.
When to use: Quick prototyping, simple inference tasks, no custom preprocessing needed.
See references/pipelines.md for comprehensive task coverage and optimization.
2. Model Loading and Management
Load pre-trained models with fine-grained control over configuration, device placement, and precision.
When to use: Custom model initialization, advanced device management, model inspection.
See references/models.md for loading patterns and best practices.
3. Text Generation
Generate text with LLMs using various decoding strategies (greedy, beam search, sampling) and control parameters (temperature, top-k, top-p).
When to use: Creative text generation, code generation, conversational AI, text completion.
See references/generation.md for generation strategies and parameters.
4. Training and Fine-Tuning
Fine-tune pre-trained models on custom datasets using the Trainer API with automatic mixed precision, distributed training, and logging.
When to use: Task-specific model adaptation, domain adaptation, improving model performance.
See references/training.md for training workflows and best practices.
5. Tokenization
Convert text to tokens and token IDs for model input, with padding, truncation, and special token handling.
When to use: Custom preprocessing pipelines, understanding model inputs, batch processing.
See references/tokenizers.md for tokenization details.
Common Patterns
Pattern 1: Simple Inference
For straightforward tasks, use pipelines:
pipe = pipeline("task-name", model="model-id")
output = pipe(input_data)
Pattern 2: Custom Model Usage
For advanced control, load model and tokenizer separately:
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("model-id")
model = AutoModelForCausalLM.from_pretrained("model-id", device_map="auto")
inputs = tokenizer("text", return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=100)
result = tokenizer.decode(outputs[0])
Pattern 3: Fine-Tuning
For task adaptation, use Trainer:
from transformers import Trainer, TrainingArguments
training_args = TrainingArguments(
output_dir="./results",
num_train_epochs=3,
per_device_train_batch_size=8,
)
trainer = Trainer(
model=model,
args=training_args,
train_dataset=train_dataset,
)
trainer.train()
Reference Documentation
For detailed information on specific components:
- Pipelines:
references/pipelines.md- All supported tasks and optimization - Models:
references/models.md- Loading, saving, and configuration - Generation:
references/generation.md- Text generation strategies and parameters - Training:
references/training.md- Fine-tuning with Trainer API - Tokenizers:
references/tokenizers.md- Tokenization and preprocessing
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (5,084 bytes)
- 📎 references/generation.md (9,340 bytes)
- 📎 references/models.md (8,648 bytes)
- 📎 references/pipelines.md (8,940 bytes)
- 📎 references/tokenizers.md (9,904 bytes)
- 📎 references/training.md (10,365 bytes)