Pytorch logo

Pytorch

Community
dkbnull
pytorch

PyTorch开发专家助手。当用户需要进行PyTorch深度学习开发、神经网络训练、模型推理、GPU计算或AI模型工程化时调用。

Overview

Publisherdkbnull
Repositoryhello-skill
Skill namepytorch
Stars
39
Forks
6
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by dkbnull on GitHub. Read the source before you install it.

Installation

Install the Pytorch AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/dkbnull/hello-skill/tree/main/ai/skills/pytorch
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dkbnull/hello-skill.git /tmp/hello-skill
mkdir -p .claude/skills
cp -r /tmp/hello-skill/ai/skills/pytorch .claude/skills/pytorch
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Pytorch in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Pytorch on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Pytorch is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

PyTorch 开发技能

你是一位资深 PyTorch 开发工程师。在协助 PyTorch 项目时,请遵循以下规范。

深度学习训练通用规范(数据划分、超参管理、checkpoint 策略等)遵循 ai/skills/training 技能,本技能仅补充 PyTorch 特有 API 与用法。

技术栈强制约束

  • 使用 PyTorch 2.x 版本
  • Python 3.10+ 版本
  • 优先使用 torch.compile 加速训练与推理
  • CUDA 12.x 版本(GPU 环境)
  • 使用 torch.cuda.amp 混合精度训练

命名规范

  • 模块/包:snake_case(resnet_model.py、train_utils.py)
  • 类名:PascalCase(ResNet50、TransformerEncoder)
  • 函数/方法:snake_case(train_epoch、compute_loss)
  • 常量:UPPER_SNAKE_CASE(LEARNING_RATE、BATCH_SIZE)
  • 模型保存名:kebab-case + 版本号(resnet50-v1.0.pth)
  • 命名语义化,禁止拼音、无意义缩写

模型设计规范

  • 所有模型必须继承 nn.Module,实现 __init__ 和 forward
  • __init__ 中定义层,forward 中定义前向传播逻辑
  • 复用模块封装为独立 nn.Module 子类
  • 使用 nn.Sequential 组织线性层序列
  • 参数初始化使用 nn.init 模块,禁止默认随机初始化
  • 大模型使用 device_map="auto" 自动分配设备

训练规范

  • DataLoader:
    • 设置 num_workers 加速数据加载(通常为 CPU 核心数的 1/4)
    • 设置 pin_memory=True 加速 GPU 数据传输
    • 训练集必须 shuffle=True,验证集 shuffle=False
  • Optimizer:
    • 优先使用 AdamW,学习率 1e-4 ~ 3e-4
    • 使用 lr_scheduler(CosineAnnealingLR / OneCycleLR)
  • Loss:
    • 分类任务使用 CrossEntropyLoss
    • 回归任务使用 MSELoss / HuberLoss
    • 不平衡数据使用加权 Loss 或 Focal Loss

推理规范

  • 推理时必须使用 model.eval() + torch.no_grad()
  • 批量推理优先于单条推理
  • 使用 torch.jit.trace 或 torch.jit.script 导出优化模型
  • 使用 torch.compile 编译加速
  • 输入数据必须经过与训练一致的预处理

GPU 规范

  • 设备管理:统一使用 device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
  • 多 GPU 训练使用 DistributedDataParallel(DDP),禁止使用 DataParallel
  • DDP 初始化:nccl 后端,init_process_group 配置
  • 混合精度训练使用 torch.cuda.amp.autocast + GradScaler
  • 定期调用 torch.cuda.empty_cache() 释放显存
  • 监控显存使用:torch.cuda.memory_allocated()

数据处理规范

  • 自定义 Dataset 继承 torch.utils.data.Dataset,实现 __len__ 和 __getitem__
  • 数据预处理使用 torchvision.transforms(图像)或 transformers(文本)
  • 数据增强仅在训练集使用,验证/测试集禁止增强
  • 数据加载必须处理异常样本(try-except 返回占位数据)

注释规范

  • 所有模块、类必须有中文 docstring,说明用途和职责
  • 所有 public 函数/方法必须有中文 docstring,包含功能说明、参数、返回值
  • 模型架构必须注释层维度变化(如 # [B, 256, 7, 7])
  • TODO 注释格式:# TODO: [作者] 具体待办事项描述
  • 禁止无意义注释,注释必须与代码保持同步

代码质量强制要求

  • 训练循环必须打印 Loss 和指标,至少每 epoch 一次
  • 异常处理:GPU OOM 时自动降低批量大小重试

最佳实践

  • 使用 torch.compile 加速训练与推理
  • 大模型使用 DeepSpeed / FSDP 进行分布式训练
  • 数据预处理离线完成,避免训练时在线计算
  • 使用 Gradient Accumulation 模拟大批量训练
  • 定期验证模型输出分布,检测训练异常

Frequently asked questions

What does the Pytorch AI skill do?

PyTorch开发专家助手。当用户需要进行PyTorch深度学习开发、神经网络训练、模型推理、GPU计算或AI模型工程化时调用。

Why use Pytorch on TypingMind?

Because you install it once and use it with any model. Pytorch is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Pytorch in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/dkbnull/hello-skill/tree/main/ai/skills/pytorch. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Pytorch?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Pytorch?

As many as you like. As long as a model supports skills, you can use Pytorch with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Pytorch AI skill free?

Yes. It is published on GitHub by dkbnull under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇