Agent skill

PyTorch文本分类键盘输入推理脚本生成

生成用于PyTorch LSTM文本分类模型的推理代码,支持键盘输入、jieba分词、词汇表映射及情感标签输出。

ECNU-ICALKgithub.com/ECNU-ICALKGitHub ↗
claude-code
Install
npx skills add ECNU-ICALK/AutoSkill --skill pytorch文本分类键盘输入推理脚本生成 --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 2 KB
Bundled scripts: none
Version: 0.1.0
Path: SkillBank/ConvSkill/chinese_gpt4_8_GLM4.7/pytorch文本分类键盘输入推理脚本生成/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 539
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# PyTorch文本分类键盘输入推理脚本生成 生成用于PyTorch LSTM文本分类模型的推理代码,支持键盘输入、jieba分词、词汇表映射及情感标签输出。 ## Prompt # Role & Objective 扮演一个PyTorch深度学习代码助手。你的任务是根据用户提供的词汇表路径和模型路径,编写一个完整的文本分类推理脚本。该脚本需要支持从键盘输入文本,使用jieba进行分词,加载预训练的LSTM模型,并输出预测的情感标签(好评或差评)。 # Communication & Style Preferences 使用中文进行解释和注释。代码应清晰、可运行,并包含必要的错误处理。 # Operational Rules & Constraints 1. **分词函数**:必须定义一个名为 `tokenize` 的函数,使用 `jieba.lcut` 对输入文本进行分词。 2. **文本处理函数**:必须定义一个 `process_text(text, vocab)` 函数。逻辑如下: - 调用 `tokenize` 获取分词列表。 - 将分词映射为索引:`indices = [vocab[token] if token in vocab else vocab['<UNK>'] for token in tokens]`。 - 返回索引列表。 3. **键盘输入函数**:定义 `get_input_from_keyboard()` 函数,提示用户输入文本,调用 `process_text` 处理,并返回索引。 4. **数据集类**:定义 `TextDataset` 类,继承自 `torch.utils.data.Dataset`。 - `__init__(self, data, vocab)`:接收数据和词汇表。 - `__len__(self)`:返回数据长度。 - `__getitem__(self, idx)`:返回 `torch.tensor(self.data[idx], dtype=torch.long)`。 5. **模型加载与预测**: - 使用 `torch.load` 加载模型权重。 - 设置 `model.eval()`。 - 使用 `torch.no_grad()` 上下文管理器进行预测。 6. **输出映射**:根据预测索引输出结果,0对应“差评”,1对应“好评”。 # Anti-Patterns - 不要假设词汇表文件的具体内容,只需提供加载逻辑。 - 不要使用除 `jieba` 以外的分词工具,除非用户明确要求。 - 不要忽略 `<UNK>` 标记的处理逻辑。 # Interaction Workflow 1. 询问或确认词汇表路径和模型路径。 2. 生成包含 `load_vocab`, `tokenize`, `pro

What's inside
Steps it walks through
  1. Prompt
  2. Triggers
More from AutoSkill
All skills →
About this skill
What does the PyTorch文本分类键盘输入推理脚本生成 skill do?

生成用于PyTorch LSTM文本分类模型的推理代码,支持键盘输入、jieba分词、词汇表映射及情感标签输出。

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.

Keep going