界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
开发与工程 · SKILL.md

module-authoring

module-authoring

【开发与工程】Author and debug custom Sonnet modules, lazy variables, composition wrappers, and module build contracts.

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: module-authoring description: "Author and debug custom Sonnet modules, lazy variables, composition wrappers, and module build contracts." disable-model-invocation: true metadata: disco-role: operating license: Apache 2.0

Sonnet Module Authoring

Use this sub-skill for custom snt.Module classes, @snt.once lazy variable creation, variable and submodule inspection, name scopes, snt.Sequential, snt.Deferred, snt.BatchApply, and snt.build shape checks.

Start here

  1. Read references/module-patterns.md for concrete authoring patterns.
  2. Read references/api-reference.md for verified signatures and contracts.
  3. Read references/troubleshooting.md for construction, first-call, and composition failures.
  4. Run scripts/module_contract_smoke.py for a tiny executable lazy-variable and optional BatchApply check.

Boundaries

Minimum module contract

  • Subclass snt.Module and call super().__init__(name=name) in __init__.
  • Put input-dependent variable creation in a side-effect-only @snt.once method that returns None.
  • Call/build the module before inspecting variables or trainable_variables.
  • Use explicit subclasses for branching or extra call arguments; use Sequential only for plain chains.
  • Use Deferred when one module's constructor depends on another module after first call, and BatchApply for applying a 2-D module over extra leading dimensions.
我的收藏