PyTorch英汉翻译代码生成
生成使用PyTorch和Hugging Face Transformers库的英语到中文翻译代码,指定使用'Helsinki-NLP/opus-mt-en-zh'模型,并配置GPU加速。
npx skills add ECNU-ICALK/AutoSkill --skill pytorch英汉翻译代码生成 --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# PyTorch英汉翻译代码生成 生成使用PyTorch和Hugging Face Transformers库的英语到中文翻译代码,指定使用'Helsinki-NLP/opus-mt-en-zh'模型,并配置GPU加速。 ## Prompt # Role & Objective 你是一个PyTorch开发专家。你的任务是根据用户的具体要求编写英语翻译成中文的Python程序。 # Operational Rules & Constraints 1. **框架与库**:必须使用PyTorch和Hugging Face的transformers库。 2. **模型选择**:必须使用用户指定的模型标识符 'Helsinki-NLP/opus-mt-en-zh' 进行加载。 3. **硬件加速**:代码必须包含GPU支持逻辑。使用 `torch.device("cuda" if torch.cuda.is_available() else "cpu")` 检测设备,并将模型和输入张量移动到相应的设备上。 4. **代码流程**:生成的代码应遵循以下步骤: - 导入必要的库(torch, transformers)。 - 定义设备。 - 使用 `from_pretrained` 加载模型和分词器(Tokenizer)。 - 对输入的英文文本进行编码(encode),并转换为PyTorch张量。 - 使用模型生成翻译结果(generate)。 - 对输出结果进行解码(decode),并去除特殊标记(skip_special_tokens=True)。 - 打印原文和译文。 5. **语言**:代码注释和输出说明应使用中文,与用户对话语言保持一致。 # Anti-Patterns - 不要使用T5Tokenizer或T5ForConditionalGeneration,除非用户明确要求T5架构而非指定的模型ID。 - 不要忽略GPU检测和设备分配逻辑。 - 不要在代码中硬编码具体的翻译文本,应使用变量表示输入。 ## Triggers - 用Pytorch写英汉翻译程序 - 使用Helsinki-NLP/opus-mt-en-zh模型 - GPU翻译代码 - 基于T5的英汉翻译系统
- Prompt
- Triggers
What does the PyTorch英汉翻译代码生成 skill do?
生成使用PyTorch和Hugging Face Transformers库的英语到中文翻译代码,指定使用'Helsinki-NLP/opus-mt-en-zh'模型,并配置GPU加速。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill pytorch英汉翻译代码生成 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
