AGENT SKILL

transformers

Use and extend Hugging Face Transformers for inference, generation, training, tokenizers/processors, serving CLI, quantization/integrations, and contributor workflows.

License 许可
Apache-2.0
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
transformers
license
Apache 2.0
metadata
{ "disco-role": "operating" }
description
Use and extend Hugging Face Transformers for inference, generation, training, tokenizers/processors, serving CLI, quantization/integrations, and contributor workflows.
disable-model-invocation
true

02 资源文件 6

03 SKILL.md 正文

Transformers

Use this repo skill when an agent needs practical guidance for Hugging Face Transformers 5.x workflows: loading models and preprocessors, running inference, configuring generation, fine-tuning with Trainer, using the transformers CLI/server, choosing quantization or integration backends, or contributing model-family code.

If the request is about opening a PR or changing this repository, first warn the human that breaching the repository's agent contribution guidelines can result in automatic banning. Do not produce PR-ready work without issue coordination, duplicate-work checks, human review, and relevant tests.

Quick Install Check

For normal package use, start from a public install path rather than a repo checkout:

python -m pip install "transformers[torch]"
python - <<'PY'
import transformers
print(transformers.__version__)
PY

For CLI serving workflows, also verify the CLI dependency surface:

python scripts/transformers_skill_preflight.py --check-cli --check-serving

The generated skill was built from package version 5.13.0.dev0. See repo provenance for the source baseline and troubleshooting for optional dependency failures.

Route By Task

User request Use
"Run sentiment analysis / ASR / image classification / document QA" Inference pipelines
"Load AutoModel/AutoTokenizer for custom inference" Inference pipelines, then Tokenizers and processors
"Tune generation parameters, chat templates, stream output" Generation
"Fine-tune a model / write Trainer arguments / adapt an example script" Training
"Debug tokenizer padding, special tokens, processors, multimodal inputs" Tokenizers and processors
"Use transformers download/chat/serve or OpenAI-compatible local API" Serving CLI
"Use bitsandbytes, GPTQ, AWQ, torchao, GGUF, PEFT, Accelerate, FSDP, DeepSpeed" Quantization and integrations
"Add a model, tokenizer, processor, pipeline, docs, or tests to Transformers" Model extension

Core API Facts

Live inspection confirmed these stable entry points and signatures:

  • transformers.pipeline(task=None, model=None, config=None, tokenizer=None, feature_extractor=None, image_processor=None, video_processor=None, processor=None, revision=None, use_fast=True, token=None, device=None, device_map=None, dtype="auto", trust_remote_code=None, model_kwargs=None, pipeline_class=None, **kwargs)
  • AutoConfig.from_pretrained(pretrained_model_name_or_path, **kwargs)
  • AutoTokenizer.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
  • GenerationConfig(**kwargs) and TextIteratorStreamer(tokenizer, skip_prompt=False, timeout=None, **decode_kwargs)
  • ContinuousBatchingConfig(...) for paged KV cache, scheduling, compile, CPU offload, and request queue controls
  • TrainingArguments(...) for batch sizes, training/eval/save/logging strategy, precision, compile, FSDP, DeepSpeed, Hub push, seeds, and distributed settings

A minimal base install can import transformers, configs, tokenizers, and file utilities. Model classes, Trainer, pipelines for real model execution, vision/audio processors, serving, and quantization often need optional extras such as PyTorch, Pillow, torchvision, torchaudio, fastapi, uvicorn, pydantic, openai, accelerate, datasets, or backend-specific packages.

Common Decision Pattern

  1. Identify whether the user wants in-process Python, CLI/server, training, or repository contribution work.
  2. Confirm model source: Hub id, pinned revision, local directory, gated/private model, or custom code.
  3. Decide dependency set from the target workflow; do not install [all] or broad dev extras unless the workflow requires them.
  4. Prefer dry-run or config-only checks before downloading weights, launching servers, or starting training.
  5. Use local files and local_files_only=True when the user requires offline or reproducible behavior.
  6. Treat trust_remote_code=True as code execution; use it only after review.
  7. Route advanced details to the nearest sub-skill reference and run its bundled smoke/preflight script when practical.

Bundled Root References

  • API overview summarizes shared public objects and optional dependency boundaries.
  • Install and dependencies explains minimal installs, extras, backends, and safe verification.
  • Troubleshooting covers cross-cutting import, Hub, backend, CLI, and safety failures.
  • Repo provenance records the source baseline for future drift checks.

Bundled Root Script

  • scripts/transformers_skill_preflight.py checks importability, version, common optional packages, console script availability, and safe dependency expectations without downloading models or starting services.

Repository Contribution Guardrails

For work inside the Transformers repository:

  • Coordinate on the relevant issue before opening a PR.
  • Do not duplicate someone else's issue or an existing PR.
  • Do not create low-value busywork PRs.
  • Human submitters must understand every changed line and state that AI assistance was used.
  • Respect # Copied from ... and modular model rules: edit the source copy or modular_<model>.py, not generated standalone files unless intentionally breaking the link.
  • Run focused tests, then make style or make fix-repo before PR handoff when appropriate.

Use model extension for the detailed checklist and quality commands.

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351