Skip to content

seq2seq (RDDLGN)

Defined in: griffith_logic.models.rddlgn.RDDLGN (class)

class RDDLGN(config: RDDLGNConfig, device: str = 'cpu')

Recurrent Deep Differentiable Logic Gate Network.

A seq2seq encoder-decoder model. Fully-connected layers are replaced by differentiable logic gates (LUTs).

Examples using this API

Defined in: griffith_logic.models.rddlgn.RDDLGNConfig (class)

class RDDLGNConfig(
vocab_size: int = 16000,
d_emb: int = 1024,
seq_len: int = 16,
n_layer_sizes: list = (lambda: [12000, 12000])(),
k_layer_sizes: list = (lambda: [54000, 32000])(),
l_layer_sizes: list = (lambda: [12000, 12000])(),
p_layer_sizes: list = (lambda: [64000, 48000])(),
m_layer_sizes: list = (lambda: [400000, 400000, 480000])(),
n_inputs: int = 2,
parameterization: str = 'softmax',
connections: str = 'random',
grad_factor: float = 1.0,
selection: str = 'soft',
tau: float = 2.0,
tau_warp: float = 1.0,
gumbel: bool = True,
init_mode: str = 'zero',
init_scale: float = 0.5,
shared_vocab: bool = True,
)

All hyperparameters of the RDDLGN model.

Examples using this API

Defined in: griffith_logic.models.rddlgn.RDDLGNEncoder (class)

class RDDLGNEncoder(config: RDDLGNConfig, device: str = 'cpu')

RDDLGN encoder.

N-layers: feed-forward representation learning (all timesteps batched) K-layers: recurrent processing along time (loops over timesteps)

Defined in: griffith_logic.models.rddlgn.RDDLGNDecoder (class)

class RDDLGNDecoder(config: RDDLGNConfig, device: str = 'cpu')

RDDLGN decoder.

L-layers: feed-forward target processing (batched) P-layers: autoregressive recurrence (loops over timesteps) M-layers: output generation → GroupSum → logits

Defined in: griffith_logic.models.rddlgn.RDDLGNClassifier (class)

class RDDLGNClassifier(
config: RDDLGNConfig,
n_classes: int,
head_sizes: list[int] | None = None,
device: str = 'cpu',
)

RDDLGN encoder + classification head (text-classification distillation such as SST-2, ROADMAP-v5 Track D7).

Structure: LogicEmbedding → RDDLGNEncoder (folds the sequence recurrently into a context vector) → LutStack (classification head) → GroupSum(k=n_classes). The difference from RDDLGN proper is that the seq2seq decoder (RDDLGNDecoder) is not used — only the encoder’s context output is.

Defined in: griffith_logic.models.rddlgn.LogicEmbedding (class)

class LogicEmbedding(vocab_size: int, d_emb: int)

Token embedding + sigmoid activation.

Training: Embedding → sigmoid (continuous [0,1]) Inference: Embedding → Heaviside (discrete {0,1})

Defined in: griffith_logic.models.rddlgn.LutStack (class)

class LutStack(
in_dim: int,
layer_sizes: list[int],
n_inputs: int = 2,
device: str = 'cpu',
grad_factor: float = 1.0,
parameterization: str = 'softmax',
connections: str = 'random',
tau_warp: float = 1.0,
gumbel: bool = True,
selection: str = 'soft',
wiring: str = 'fixed',
lm_tau: float = 0.001,
)

A chain of LutLayers. Used to build the N/K/L/P/M layer groups.

in_dim → layer_sizes[0] → layer_sizes[1] → … → layer_sizes[-1]