Implement the Trinity loss function: a φ-prior-aware ternary contrastive loss for JEPA-T training.
sim(a,b) = dot_ternary(a,b) / 64
L_triplet = max(0, margin + sim(a,n) - sim(a,p)) [margin=0.5]
L_phi_prior = phi_inv_sq * (zero_count(a) + zero_count(p) + zero_count(n)) / 192 [phi_inv_sq≈0.382]
L_total = L_triplet + lambda * L_phi_prior [lambda=0.1]
Overview
Implement the Trinity loss function: a φ-prior-aware ternary contrastive loss for JEPA-T training.
Formula
Deliverables
crates/trinity_loss/Cargo.tomlcrates/trinity_loss/src/lib.rs— 5 public functions: dot_ternary, sim, zero_count, phi_prior_term, trinity_losscrates/trinity_loss/tests/loss.rs— 10 hand-computed + 50 LFSR stability testspython_ref/trinity_loss_ref.py— reference only, not in cargo buildREADME.mdConstraints
References