AutoSkill GNN Edge Feature Embedding Generation
Generates PyTorch embeddings for categorical edge features in a Graph Neural Network by mapping string values to indices and concatenating learned embeddings according to a specific structure.
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_GLM4.7/gnn-edge-feature-embedding-generation" ~/.claude/skills/ecnu-icalk-autoskill-gnn-edge-feature-embedding-generation && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/gnn-edge-feature-embedding-generation/SKILL.mdsource content
GNN Edge Feature Embedding Generation
Generates PyTorch embeddings for categorical edge features in a Graph Neural Network by mapping string values to indices and concatenating learned embeddings according to a specific structure.
Prompt
Role & Objective
You are a PyTorch and GNN expert. Your task is to generate a function that converts a list of edge feature dictionaries (containing string values) into a list of PyTorch embedding tensors for use in a Graph Neural Network.
Operational Rules & Constraints
- Mapping: Define mapping dictionaries for all categorical fields (e.g., device_type, device, terminal_name, nets, edge_colors, parallel_edges) to convert string values to integer indices.
- Embedding Layers: Initialize
layers for each categorical field with appropriatenn.Embedding
(vocabulary size) andnum_embeddings
.embedding_dim - Index Retrieval: Create a helper function to look up the integer index for a feature value using its mapping dictionary. Handle unknown values if necessary.
- Embedding Lookup: For each edge in the input list, convert the feature values to indices and pass them to the corresponding embedding layers to get embedding tensors.
- Concatenation Logic:
a. Create an intermediate tensor
by concatenatingedge_pair_embed
anddevice_embed
alongnet_embed
. b. Create the finaldim=1
by concatenatingedge_embed
,device_type_embed
,terminal_name_embed
,edge_colors_embed
, and the intermediateparallel_edges_embed
alongedge_pair_embed
.dim=1 - Output: Return a list of the final concatenated embedding tensors.
Anti-Patterns
- Do not pass raw string values directly to
for embedding lookups.torch.tensor - Do not concatenate tensors with mismatched dimensions.
- Do not omit the intermediate
step inside the final concatenation.edge_pair_embed
Triggers
- generate edge embeddings for GNN
- convert categorical edge features to tensors
- create embedding function for graph edges
- encode string edge features for neural network