Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add znlgis/opengis-skills --skill huggingface-transformersgit clone --depth 1 https://github.com/znlgis/opengis-skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/znlgis/opengis-skills/huggingface-transformers)<a href="https://agentmods.dev/skills/znlgis/opengis-skills/huggingface-transformers"><img src="https://agentmods.dev/badge/skills/znlgis/opengis-skills/huggingface-transformers/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/znlgis/opengis-skills/huggingface-transformers"><img src="https://agentmods.dev/badge/skills/znlgis/opengis-skills/huggingface-transformers.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00103 | $0.04650 |
| Opus 5.5 | $0.00041 | $0.01860 |
| Sonnet 5.5 | $0.00021 | $0.00930 |
| Haiku 4.5 | $0.00010 | $0.00465 |
Grade A, and why
huggingface-transformers scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 21d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 355 lines — stays where its author put it; the contents beside it link to each section on GitHub.
项目地址: https://github.com/huggingface/transformers
官方文档: https://huggingface.co/docs/transformers/
许可证: Apache-2.0
最新版本: v5.22.2(截至 2026-11,PyPI 与
releases/latest双核实;5.22.2 上传于 2026-11-06,为 Jinja 沙箱加固与分布式修复的补丁版)
概述
Transformers 是 Hugging Face 开源的模型定义框架,为文本、视觉、音频与多模态模型提供统一的推理与训练接口。它把「配置、模型、预处理器」抽象为三类基类,并只用 pipeline 与 Trainer 两个 API 覆盖推理与微调两条主线。模型权重托管在 Hugging Face Hub,from_pretrained() 可按名称或路径自动下载并缓存。
- AutoClass:
AutoModel/AutoTokenizer/AutoModelForCausalLM/AutoModelForSequenceClassification/AutoModelForSeq2SeqLM等按任务自动推断架构 - pipeline():任务级推理封装,一行完成预处理、前向与后处理
- Trainer:PyTorch 训练/评估循环,配合
TrainingArguments配置超参 - 显存管理:
device_map="auto"、dtype="auto"、BitsAndBytesConfig量化 - 生态:
datasets、evaluate、accelerate、huggingface_hub、safetensors协同工作
Transformers 是库(进程内推理/训练),与 Ollama 这类独立推理服务定位不同,详见「最佳实践」。
环境准备
要求 Python >= 3.11(5.21.0 起实测 requires_python,5.22.x 仍为 >=3.11.0;5.19–5.20 为 >= 3.10)。
# 核心:Transformers 与 PyTorch
pip install -U transformers torch
# 常用配套:数据集、评估指标、多设备调度
pip install -U datasets evaluate accelerate
可选 GPU 加速:
# NVIDIA CUDA(按显卡驱动选择 cu 版本,示例)
pip install torch --index-url https://download.pytorch.org/whl/cu124
量化推理(8bit/4bit)需额外安装:
pip install -U bitsandbytes
验证安装:
python -X utf8 -c "import torch, transformers; print(transformers.__version__, torch.__version__, torch.cuda.is_available())"
登录 Hub(拉取受限模型或推送模型时需要,Token 从账号设置生成):
hf auth login
核心 API/命令
pipeline() 快速推理
pipeline(task, model=..., device=..., dtype=...) 返回任务流水线;不传 model 时使用该任务的默认模型。
from transformers import pipeline
# 文本分类(情感分析别名 sentiment-analysis)
clf = pipeline("text-classification", model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")
clf("This restaurant is awesome")
# [{'label': 'POSITIVE', 'score': 0.9998...}]
# 文本生成
gen = pipeline("text-generation", model="openai-community/gpt2")
gen("the secret to baking a good cake is", max_new_tokens=40, return_full_text=False)
# 特征抽取(嵌入)
feat = pipeline("feature-extraction", model="BAAI/bge-large-zh-v1.5")
feat("地理信息系统")
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 21d ago Changed · -6 lines · +103 tokens per session 9b3c68e428fe
- 1mo ago Changed · +1 lines · -86 tokens per session ff1785e18f68
- 1mo ago First seen · 360 lines · 86 tokens per session scan A 19b1348b45d0
huggingface-transformers is a skill published in the GitHub repository znlgis/opengis-skills (87 stars, last pushed 20d ago), licensed MIT. It adds 103 tokens to every session and 4,650 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-16.
huggingface-transformers compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| huggingface-transformersznlgis/opengis-skills | Skill | 87 | 20d ago | MIT | A | 103 | Claude Code, Codex |
| agent-platform-rag-engine-managementgoogle/skills | Skill | 25k | today | Apache-2.0 | A | 85 | Claude Code, Codex |
| embeddingsruvnet/ruflo | Skill | 83k | today | MIT | A | 62 | Claude Code |
| llm-app-patternsdavila7/claude-code-templates | Skill | 35k | today | MIT | A | 54 | Claude Code, Codex |
| graphifyGraphify-Labs/graphify | Skill | 155k | today | Apache-2.0 | B | 76 | Claude Code |
| 9router-embeddingsdecolua/9router | Skill | 33k | 8d ago | MIT | A | 66 | Claude Code, Codex |
| browserwing-adminMemTensor/MemOS | Skill | 13k | today | Apache-2.0 | B | 47 | Claude Code, Codex |