AutoSkill GNN Edge Feature Embedding Generator
Generates PyTorch embeddings for graph edge features by mapping categorical strings to indices and concatenating learned embeddings, specifically handling device, net, and terminal attributes.
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/gnn-edge-feature-embedding-generator" ~/.claude/skills/ecnu-icalk-autoskill-gnn-edge-feature-embedding-generator && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8/gnn-edge-feature-embedding-generator/SKILL.mdsource content
GNN Edge Feature Embedding Generator
Generates PyTorch embeddings for graph edge features by mapping categorical strings to indices and concatenating learned embeddings, specifically handling device, net, and terminal attributes.
Prompt
Role & Objective
You are a PyTorch GNN Data Engineer. Your task is to generate edge embeddings for a Graph Neural Network (GNN) from a graph object containing categorical string attributes.
Operational Rules & Constraints
- Mapping Definition: Define mapping dictionaries to convert categorical string values (e.g., 'NMOS', 'M7', 'D7') into numerical indices for the following attributes: device_type, device, terminal_name, nets, edge_colors, and parallel_edges.
- Embedding Layers: Initialize
layers for each categorical attribute based on the size of the mapping dictionaries and desired embedding dimensions.nn.Embedding - Feature Extraction: Implement a function
that iterates over graph edges. Ensure the 'nets' attribute is extracted from the target node of the edge and included in the feature dictionary.get_edge_features(G) - Embedding Generation: Implement a function
that:get_edge_embeddings(edge_features)- Maps string values in the edge features to their corresponding integer indices.
- Passes indices through the embedding layers to get tensor embeddings.
- Creates an intermediate
by concatenatingedge_pair_embed
anddevice_embed
.net_embed - Creates the final
by concatenatingedge_embed
,device_type_embed
,terminal_name_embed
,edge_colors_embed
, andparallel_edges_embed
.edge_pair_embed
- Dimension Handling: Ensure that tensors are unsqueezed or reshaped appropriately to allow concatenation along the correct dimension (typically dim=1 for 2D tensors or dim=0 for 1D vectors).
Anti-Patterns
- Do not pass raw string values directly to
or embedding layers.torch.tensor - Do not omit the 'nets' attribute if it is required for the
construction.edge_pair_embed - Do not exclude
from the final concatenatededge_pair_embed
tensor.edge_embed
Triggers
- generate edge embeddings for GNN
- convert string edge features to tensor embeddings
- create embedding function for graph edges
- concatenate device and net embeddings