协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
model-architecture【开发与工程】Instantiate and debug the attention-is-all-you-need-pytorch Transformer architecture, masks, attention layers, feed-forward blocks, weight sharing, tensor shapes, and scheduled optimizer.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when you need to construct, inspect, or debug the repository's Transformer model classes rather than preprocess data, run training CLIs, or perform checkpoint translation.
Transformer, Encoder, Decoder, EncoderLayer, DecoderLayer,
MultiHeadAttention, PositionwiseFeedForward, ScaledDotProductAttention,
PositionalEncoding, or ScheduledOptim instances.d_model == d_word_vec.Translator, beam search, and decoding workflows belong
to the translation sub-skill; this sub-skill only covers class-level model
shapes that those workflows rely on.Run the bundled architecture check from any current directory by pointing it at an explicit repository checkout:
python scripts/architecture_smoke_check.py --repo-root /path/to/attention-is-all-you-need-pytorch
Useful variants:
python scripts/architecture_smoke_check.py --repo-root /path/to/repo --device cpu
python scripts/architecture_smoke_check.py --repo-root /path/to/repo --device cuda
python scripts/architecture_smoke_check.py --repo-root /path/to/repo --skip-negative-checks
The script constructs a tiny deterministic Transformer with sharing disabled,
checks pad and causal masks, verifies multi-head attention broadcasting, probes
ScheduledOptim warmup/decay behavior, and optionally confirms that known-bad
architecture settings fail for the expected reasons.
d_model equal to d_word_vec; the model asserts this after parameter
initialization because residual connections require a common hidden width.emb_src_trg_weight_sharing=False. For tiny tests with
different vocab sizes, also set trg_emb_prj_weight_sharing=False unless you
specifically need target embedding/projection sharing.scale_emb_or_prj only as one of emb, prj, or none; scaling is
applied only when target embedding/projection sharing is enabled.True means a key position is visible and
False means it is masked before softmax.Transformer.forward(src_seq, trg_seq) returns flattened
logits with shape [batch * target_length, n_trg_vocab], not
[batch, target_length, n_trg_vocab].