Papers
Topics
Authors
Recent
2000 character limit reached

Neural Ternary Semiring: Triadic Reasoning

Updated 25 November 2025
  • Neural Ternary Semiring (NTS) is a differentiable framework that replaces binary operations with a native ternary operator to directly model subject-predicate-object interactions.
  • It introduces two neural parameterizations—tensor-based fusion and attention-based aggregation—to effectively capture multi-entity dependencies and enable end-to-end learning.
  • Algebraic regularizers enforcing distributivity and associativity improve model consistency and yield superior performance on knowledge graph completion and logical inference tasks.

The Neural Ternary Semiring (NTS) is a learnable, differentiable algebraic architecture for symbolic reasoning, underpinned by the mathematical formalism of ternary Gamma-semirings. Unlike classical semiring frameworks that support only binary composition, NTS allows direct representation of triadic (three-argument) interactions, thus aligning more naturally with tasks involving subject-predicate-object structures, logical rules with multiple premises, and other forms of multi-entity dependency. The core innovation is the replacement of binary products with a native neural ternary operator, learned and regularized so as to enforce approximate distributivity and associativity consistent with ternary semiring theory. This endows neural architectures with a principled mechanism for expressing and manipulating higher-arity relationships, providing a bridge between structured symbolic semantics and gradient-based learning (Gokavarapu et al., 21 Nov 2025).

1. Formal Definition of the Ternary Gamma-Semiring

A ternary Gamma-semiring (S,+,0,[,,])(S, +, 0, [\cdot,\cdot,\cdot]_{-}) is defined as follows. SS is a set with a commutative monoid structure (S,+,0)(S, +, 0), where ++ is associative, commutative, and admits the neutral element $0$. For each γΓ\gamma \in \Gamma—the set of context or relation-type indices—there is a ternary product [,,]γ:S×S×SS[\cdot,\cdot,\cdot]_{\gamma}: S \times S \times S \rightarrow S. The operations satisfy, for all x,x1,x2,y,y1,y2,z,z1,z2,u,v,wSx, x_1, x_2, y, y_1, y_2, z, z_1, z_2, u, v, w \in S and γ,δΓ\gamma, \delta \in \Gamma:

  • Distributivity in Each Slot:

(i) [x1+x2,y,z]γ=[x1,y,z]γ+[x2,y,z]γ[x_1 + x_2, y, z]_{\gamma} = [x_1, y, z]_{\gamma} + [x_2, y, z]_{\gamma} (ii) [x,y1+y2,z]γ=[x,y1,z]γ+[x,y2,z]γ[x, y_1 + y_2, z]_{\gamma} = [x, y_1, z]_{\gamma} + [x, y_2, z]_{\gamma} (iii) [x,y,z1+z2]γ=[x,y,z1]γ+[x,y,z2]γ[x, y, z_1 + z_2]_{\gamma} = [x, y, z_1]_{\gamma} + [x, y, z_2]_{\gamma}

  • Ternary Associativity (Left-nested Form):

[x,y,[u,v,w]γ]δ=[[x,y,u]γ,v,w]δ[x, y, [u, v, w]_{\gamma}]_{\delta} = [[x, y, u]_{\gamma}, v, w]_{\delta}

These axioms, together with the commutativity and zero laws of the underlying monoid, constitute the formal requirements for the ternary Γ\Gamma-semiring structure. The left-nested associativity suffices for well-posed multi-step composition, though further identities are possible (Gokavarapu et al., 21 Nov 2025).

2. Neural Parameterization of the Ternary Operator

Each SS element is embedded as x,y,zRdx, y, z \in \mathbb{R}^d, and each context index γ\gamma is associated with a learnable embedding gγRdg_\gamma \in \mathbb{R}^d. Two neural parameterizations are introduced for [,,]γ[\cdot,\cdot,\cdot]_\gamma:

  • Tensor-based Ternary Fusion:

Compute a tensor outer product xyzRd3x \otimes y \otimes z \in \mathbb{R}^{d^3}, then perform the ternary operation via

[x,y,z]γ=σ(W(1)(xyz)+W(2)([x;gγ])+W(3)z+bγ)[x, y, z]_\gamma = \sigma \left( W^{(1)}(x \otimes y \otimes z) + W^{(2)}([x; g_\gamma]) + W^{(3)} z + b_\gamma \right)

where W(1):Rd3 ⁣ ⁣RdW^{(1)}: \mathbb{R}^{d^3} \!\to\! \mathbb{R}^d, W(2):R2d ⁣ ⁣RdW^{(2)}: \mathbb{R}^{2d}\!\to\!\mathbb{R}^d, W(3):Rd ⁣ ⁣RdW^{(3)}: \mathbb{R}^d\!\to\!\mathbb{R}^d, and σ\sigma is a pointwise nonlinearity such as ReLU or tanh\tanh.

  • Attention-based Ternary Aggregation:

Assign each γ\gamma a vector uγRdu_\gamma \in \mathbb{R}^d. Define attention logits i=uγvi\ell_i = u_\gamma^\top v_i, for [v1,v2,v3]=[x,y,z][v_1, v_2, v_3] = [x, y, z], and compute

(α1,α2,α3)=softmax(1,2,3)(\alpha_1, \alpha_2, \alpha_3) = \mathrm{softmax}(\ell_1, \ell_2, \ell_3)

Then aggregate [x,y,z]γ=α1x+α2y+α3z[x, y, z]_\gamma = \alpha_1 x + \alpha_2 y + \alpha_3 z.

Both parameterizations are fully differentiable and enable end-to-end learning (Gokavarapu et al., 21 Nov 2025).

3. Algebraic Regularization and Optimization

To encourage the learned ternary operator toward genuine ternary Γ\Gamma-semiring behavior, auxiliary regularization losses are applied:

  • Associativity Regularizer:

Lassoc=Ex,y,u,v,wD,γ,δΓ[x,y,[u,v,w]γ]δ[[x,y,u]γ,v,w]δ22\mathcal{L}_{\mathrm{assoc}} = \mathbb{E}_{x,y,u,v,w\sim\mathcal{D},\,\gamma, \delta \sim \Gamma} \Big\| [x, y, [u, v, w]_{\gamma}]_{\delta} - [[x, y, u]_{\gamma}, v, w]_{\delta} \Big\|_2^2

  • Distributivity Regularizer (enforced in each argument):

Ldist=Ex,x,u,vD,γΓ[x+x,u,v]γ[x,u,v]γ[x,u,v]γ22\mathcal{L}_{\mathrm{dist}} = \mathbb{E}_{x, x', u, v \sim \mathcal{D},\,\gamma \sim \Gamma} \Big\| [x + x', u, v]_{\gamma} - [x, u, v]_{\gamma} - [x', u, v]_{\gamma} \Big\|_2^2

The overall loss for training combines the task-specific objective with these regularizers: L(θ)=Ltask(θ)+λassocLassoc(θ)+λdistLdist(θ)\mathcal{L}(\theta) = \mathcal{L}_{\rm task}(\theta) + \lambda_{\rm assoc} \mathcal{L}_{\rm assoc}(\theta) + \lambda_{\rm dist} \mathcal{L}_{\rm dist}(\theta)

A soundness theorem establishes that, if the associativity and distributivity terms converge to zero, the learned operator exactly satisfies the ternary semiring axioms. This is shown by noting that the regularizers are squared residuals of the defining polynomial identities; their vanishing under a continuous parameterization yields pointwise satisfaction of the axioms (Gokavarapu et al., 21 Nov 2025).

4. Training Procedure and Hyperparameterization

NTS training proceeds as follows. All entity and relation-type embeddings are initialized randomly (uniform or Gaussian). For knowledge-graph triples (h,r,t)(h, r, t), the composite embedding is obtained via zh,r,t=[xh,xr,xt]γrz_{h,r,t} = [x_h, x_r, x_t]_{\gamma_r} with scoring sθ(h,r,t)=zh,r,t2s_\theta(h,r,t) = -\|z_{h,r,t}\|_2. Two standard losses are supported:

Ltask=(h,r,t)Dlogexp(sθ(h,r,t))texp(sθ(h,r,t))\mathcal{L}_{\rm task} = -\sum_{(h,r,t)\in\mathcal{D}} \log \frac{\exp(s_\theta(h,r,t))}{\sum_{t'} \exp(s_\theta(h,r,t'))}

  • Margin ranking loss using negative sampling.

Hyperparameters are typically selected as λassoc,λdist{103,102,101}\lambda_{\rm assoc}, \lambda_{\rm dist} \in \{10^{-3}, 10^{-2}, 10^{-1}\}, learning rate 10410^{-4} to 10310^{-3}, batch size $128$–$1024$, and early stopping on validation MRR with patience 10\sim10 epochs. The Adam optimizer is used. At each iteration, a mixed mini-batch is drawn for task and regularization tuples, and the total loss is back-propagated (Gokavarapu et al., 21 Nov 2025).

5. Evaluation Protocols and Metrics

NTS is evaluated on triadic reasoning tasks including:

  • Knowledge-graph completion (standard splits: FB15K-237, WN18RR),
  • Curated logical rule templates ("if A and B then C"),
  • Synthetic triadic constraint datasets with non-decomposable ground truth.

Metrics comprise mean reciprocal rank (MRR), Hits@kk (kk = 1, 3, 10), and Rule Satisfaction Rate for logical inference. Baseline comparisons are made with:

  • Binary semiring models using sequential binary compositions,
  • Translational and bilinear knowledge graph embeddings (TransE, DistMult, ComplEx),
  • Neural Tensor Networks and trilinear models without algebraic regularization.

Ablation studies assess the effect of disabling associativity (λassoc=0\lambda_{\rm assoc}=0) or distributivity (λdist=0\lambda_{\rm dist}=0) losses (Gokavarapu et al., 21 Nov 2025).

6. Quantitative Outcomes and Empirical Patterns

Reported validation results indicate that NTS attains substantial improvements across datasets:

Model FB15K-237 MRR Hits@10 Rule Satisfaction Rate Triadic Constraint Recovery
TransE 0.68 0.80 ~0.70 60–70%
ComplEx 0.80
Unreg. Neural-Tensor 0.73
NTS 0.78 0.85 ~0.88 >95%
  • On FB15K‐237, NTS achieves an MRR of ~0.78 (cf. 0.68 for TransE, 0.73 for unregularized neural-tensor).
  • Hits@10 rises to ~0.85 for NTS (vs. 0.76 for DistMult, 0.80 for ComplEx).
  • On logical rule datasets, NTS attains Rule Satisfaction Rate ~0.88 (baselines plateau near 0.70).
  • For synthetic, non-decomposable triadic constraints, NTS recovers >95% valid triples (binary models stagnate at 60–70%).
  • Ablation results: setting λassoc=0\lambda_{\rm assoc}=0 reduces MRR by 0.05–0.07; λdist=0\lambda_{\rm dist}=0 reduces MRR by 0.03–0.06. Both regularizers are thus critical to the model’s performance and algebraic consistency.

This collectively suggests that native ternary composition enables more faithful modeling of irreducible, three-way relationships compared to cascaded binary products. Algebraic regularization improves generalization, particularly in sparse or rules-driven regimes (Gokavarapu et al., 21 Nov 2025).

7. Context and Significance

NTS addresses the inherent mismatch between binary algebraic tools and triadic phenomena pervasive in symbolic AI, such as knowledge graph reasoning and multi-premise logical inference. By supplying a learnable, regularized ternary operation, NTS supports direct encoding and manipulation of triadic dependencies, leading to superior performance on relevant benchmarks and stronger logical consistency. The algebraic regularization framework provides theoretical guarantees regarding the emergence of genuine ternary semiring structure in the learned operator. A plausible implication is that this framework could extend naturally to higher-arity algebraic settings and structured decision models, with the flexibility to encode complex, interpretable symbolic relationships within neural architectures (Gokavarapu et al., 21 Nov 2025).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Whiteboard

Follow Topic

Get notified by email when new papers are published related to Neural Ternary Semiring (NTS).