decoder-only 因果Transformer
LogicGPT
Section titled “LogicGPT”実体: griffith_logic.models.logic_gpt.LogicGPT(クラス)
class LogicGPT( config: LogicGPTConfig, dfa_targets: list[str] | None = None, dfa_mode: str = 'micro', dfa_lr: float | None = None,)decoder-only 因果Transformerの論理ゲート版。forward(tokens[B,S])→(logits, emb_reg)。
因果性: logits[:, i] は tokens[:, :i+1] のみに依存する。
- LogicEmbedding/位置符号/ヘッド/GroupSum はすべて位置独立
- LogicTransformerBlockは causal=True(未来位置を参照しない)
- LogicLayerNormは特徴軸(d_model)正規化で系列軸を跨がない
このAPIを使っている例
- 論理ゲートGPTでシェイクスピアを書く —
examples/07_logic_gpt.py
LogicGPTConfig
Section titled “LogicGPTConfig”実体: griffith_logic.models.logic_gpt.LogicGPTConfig(クラス)
class LogicGPTConfig( vocab_size: int = 67, d_model: int = 128, n_layers: int = 2, n_heads: int = 1, block_size: int = 64, mlp_ratio: int = 2, pos_width: int = 8, pos_code: str = 'binary', head_group_factor: int = 8, tau: float = 1.0, n_inputs: int = 2, parameterization: str = 'softmax', selection: str = 'soft', connections: str = 'random', merge: str = 'xor', norm: str = 'layernorm',)LogicGPTのハイパーパラメータ。
このAPIを使っている例
- 論理ゲートGPTでシェイクスピアを書く —
examples/07_logic_gpt.py