Skip to content
Back to skills

Model Architecture

ASecurity

"Instantiate and debug the attention-is-all-you-need-pytorch

  • 247 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 8, 2026
code-qualitypythonbashdebugginggitapi

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill model-architecture --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Model Architecture?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Model Architecture
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-model-architecture/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-model-architecture)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: model-architecture
description: "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."
disable-model-invocation: true
metadata:
  disco-role: operating
license: MIT
---

# Model Architecture

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.

## Use This For

- Building `Transformer`, `Encoder`, `Decoder`, `EncoderLayer`, `DecoderLayer`,
  `MultiHeadAttention`, `PositionwiseFeedForward`, `ScaledDotProductAttention`,
  `PositionalEncoding`, or `ScheduledOptim` instances.
- Checking source/target mask shapes, boolean semantics, causal target masks,
  device placement, attention tensor shapes, and flattened model logits.
- Choosing safe tiny-model settings for unit tests, especially weight-sharing
  flags and `d_model == d_word_vec`.
- Debugging architecture assertions, projection/embedding scaling, incompatible
  shared vocabularies, and Noam-style warmup scheduling.

## Route Elsewhere

- Dataset fields, vocab building, BPE, spaCy, or pickle schemas belong to the
  data-preparation sub-skill.
- Training command-line options, logging, checkpoints, label smoothing, and loss
  handling belong to the training sub-skill.
- Checkpoint loading, `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.

## Primary References

- Start with [references/api-reference.md](references/api-reference.md) for
  constructor signatures, forward contracts, return shapes, and optimizer API.
- Use [references/architecture-notes.md](references/architecture-notes.md) for
  end-to-end tensor flow, mask broadcasting, tiny-model recipes, and weight
  sharing rules.
- Use [references/troubleshooting.md](references/troubleshooting.md) for common
  assertion, mask, CUDA/device, flattened-output, sharing, and scheduler
  failures.

## Smoke Check

Run the bundled architecture check from any current directory by pointing it at
an explicit repository checkout:

```bash
python scripts/architecture_smoke_check.py --repo-root /path/to/attention-is-all-you-need-pytorch
```

Useful variants:

```bash
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.

## Fast Operating Pattern

1. Keep `d_model` equal to `d_word_vec`; the model asserts this after parameter
   initialization because residual connections require a common hidden width.
2. If source and target vocabularies are not the same shared vocabulary with the
   same token ids, set `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.
3. Use `scale_emb_or_prj` only as one of `emb`, `prj`, or `none`; scaling is
   applied only when target embedding/projection sharing is enabled.
4. Treat masks as boolean keep-masks: `True` means a key position is visible and
   `False` means it is masked before softmax.
5. Remember that `Transformer.forward(src_seq, trg_seq)` returns flattened
   logits with shape `[batch * target_length, n_trg_vocab]`, not
   `[batch, target_length, n_trg_vocab]`.

Files in this skill

  • SKILL.md3.8 KB
  • references/api-reference.md8.8 KB
  • references/architecture-notes.md8 KB
  • references/troubleshooting.md8.7 KB
  • scripts/architecture_smoke_check.py11.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.