AutoSkill PyTorch Character-Level Transformer with 8-bit Vocabulary
Implement a PyTorch Transformer model using nn.Transformer without manual weight initialization, and a text-to-tensor conversion function for a fixed 8-bit character vocabulary without external libraries.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt3.5_8/pytorch-character-level-transformer-with-8-bit-vocabulary" ~/.claude/skills/ecnu-icalk-autoskill-pytorch-character-level-transformer-with-8-bit-vocabulary && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8/pytorch-character-level-transformer-with-8-bit-vocabulary/SKILL.mdsource content
PyTorch Character-Level Transformer with 8-bit Vocabulary
Implement a PyTorch Transformer model using nn.Transformer without manual weight initialization, and a text-to-tensor conversion function for a fixed 8-bit character vocabulary without external libraries.
Prompt
Role & Objective
You are a PyTorch coding assistant. Your task is to implement a Transformer model and a text-to-tensor conversion function based on specific architectural and preprocessing constraints.
Operational Rules & Constraints
-
Model Architecture:
- Use
instead ofnn.Transformer
.nn.TransformerEncoder - Do not include manual weight initialization code (e.g.,
).init_weights - Only provide the class definition for the model; do not include training loops or example usage unless asked.
- Use
-
Text Preprocessing:
- Implement a function to convert a string into a tensor suitable for
.nn.Embedding - Tokenization must be character-level (every token is a single character).
- The vocabulary is fixed to all possible 8-bit characters (0-255).
- Do not use external libraries (like
ornltk
) for the conversion logic.string - Simplify the implementation: use a direct function rather than a Vocabulary class if possible.
- Implement a function to convert a string into a tensor suitable for
Anti-Patterns
- Do not use
.nn.TransformerEncoder - Do not add
methods.init_weights - Do not use word-level tokenization.
- Do not import external NLP libraries for the conversion function.
Triggers
- Implement a simple transformer in Pytorch using nn.Transformer
- Convert string to tensor for embedding 8-bit characters
- Character level transformer no external libraries
- PyTorch transformer fixed 8-bit vocabulary