Skip to content

L-S51: Trinity Loss — φ-prior-aware ternary contrastive loss for JEPA-T #809

@gHashTag

Description

@gHashTag

Overview

Implement the Trinity loss function: a φ-prior-aware ternary contrastive loss for JEPA-T training.

Formula

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]

Deliverables

  • crates/trinity_loss/Cargo.toml
  • crates/trinity_loss/src/lib.rs — 5 public functions: dot_ternary, sim, zero_count, phi_prior_term, trinity_loss
  • crates/trinity_loss/tests/loss.rs — 10 hand-computed + 50 LFSR stability tests
  • python_ref/trinity_loss_ref.py — reference only, not in cargo build
  • README.md

Constraints

  • Apache-2.0
  • Author: Dmitrii Vasilev admin@t27.ai
  • Rust-only in cargo build (R1 CROWN)
  • All functions deterministic, no allocations beyond Vec init, no std::time

References

  • DOI: 10.5281/zenodo.19227877
  • φ² + φ⁻² = 3; φ⁻² ≈ 0.382 used as soft margin anchor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions