Skip to main content

Crate ternlang_ml

Crate ternlang_ml 

Source

Modules§

coherence
spectra_compat

Structs§

BenchmarkResult
Summary statistics for a benchmark run.
CoalitionMember
One agent’s vote in a coalition.
CoalitionResult
Coalition voting statistics.
DeliberationEngine
Multi-round evidence accumulation engine.
DeliberationResult
Result of a full deliberation run.
DeliberationRound
One round of a deliberation trace.
GateDimension
One dimension in an action gate check.
GateResult
Result of an action gate evaluation.
HallucinationScore
Measures internal consistency of evidence signals about a claim.
ScalarTemperature
Maps a ternary decision to a recommended LLM sampling temperature.
TernaryMLP
A 2-layer ternary multi-layer perceptron.
TimedResult
Wall-clock timed benchmark result for one matrix size.
TritBlock
A single Transformer block (Attention + FeedForward).
TritEvidenceVec
A named, weighted multi-dimensional evidence vector.
TritMatrix
A flat row-major ternary matrix (rows × cols).
TritScalar
A continuous ternary confidence scalar, clamped to [-1.0, +1.0].
TritTransformer
The full TritTransformer model.
TritTransformerConfig

Enums§

GateVerdict
The outcome of an action gate evaluation.

Constants§

TEND_BOUNDARY
Zone boundary: 1/3 of the full scale.

Functions§

action_gate
Evaluate an action through a multi-dimension policy gate.
benchmark
bitnet_matrix
Generate a TritMatrix with exactly target_sparsity fraction of zero entries.
bitnet_threshold
Compute the BitNet-style threshold: 0.5 × mean(|weights|)
coalition_vote
Aggregate a coalition of agent votes into a single ternary decision.
dense_matmul
Dense ternary matrix multiply: C = A × B No skipping — every element is computed regardless of zero state. Use this as the baseline for benchmark comparisons.
evaluate
Evaluate MLP accuracy on a dataset. Returns (correct, total, accuracy).
hallucination_score
linear
BitNet-style ternary linear layer: output = sparse_matmul(input, W)
majority
Majority vote across a row of trits — reduces a vector to one trit. Returns the sign of the sum: positive majority → +1, negative → -1, tie → 0.
parity_dataset
3-bit parity dataset: 8 inputs → label 0 (even parity) or 1 (odd parity)
print_benchmark_table
Print a formatted benchmark table to stdout.
quantize
Quantize a slice of f32 weights to balanced ternary using threshold tau.
scalar_temperature
sparse_matmul
Sparse ternary matrix multiply: C = A × B, skipping zero-weight elements.
timed_benchmark
Run timed dense vs sparse matmul across multiple square matrix sizes.
timed_benchmark_at_sparsity
Benchmark at an arbitrary target sparsity (0.0 = dense, 1.0 = all zeros).
timed_benchmark_bitnet
Benchmark at a given sparsity level.
trit_activation
Ternary threshold activation: maps accumulator trit to output trit. sign(x): +1 → +1, 0 → 0, -1 → -1. Identity on Trit — but useful as a named function to clarify intent in MLP forward passes.
trit_from_f32_approx
trit_to_f32
xor_dataset
All 4 XOR inputs as ternary rows: {-1,+1} × {-1,+1} → {-1,+1} Input encoding: -1 = False, +1 = True