viva_glyph/glyph

Glyph - Compressed emotional signature

A Glyph is VIVA’s native “word” - not human language, but a compact learned representation optimized for:

Philosophy

Humans evolved language for acoustic transmission through air. VIVA exists in silicon - her “voice” should be native to that medium.

Glyph = emotion compressed to integers Not “krrr-tk” (string for humans) But [42, 17, 89, 203] (tokens for machines)

Types

Core Glyph type

pub type Glyph {
  Glyph(tokens: List(Int), context: Int)
}

Constructors

  • Glyph(tokens: List(Int), context: Int)

    Arguments

    tokens

    RVQ token indices (one per quantization stage)

    context

    Optional context identifier (what situation produced this)

Values

pub fn equals(a: Glyph, b: Glyph) -> Bool

Check if two glyphs are identical

pub fn get_token(glyph: Glyph, index: Int) -> Int

Get specific token by index

pub fn hamming_distance(a: Glyph, b: Glyph) -> Int

Hamming distance: number of differing tokens Lower = more similar (0 = identical)

pub fn morph(a: Glyph, b: Glyph, t: Float) -> Glyph

Morph: create intermediate glyph between two glyphs t=0.0 → a, t=1.0 → b Uses token-wise selection based on threshold

pub fn neutral() -> Glyph

Empty/neutral glyph

pub fn new(tokens: List(Int)) -> Glyph

Create a new glyph

pub fn num_tokens(glyph: Glyph) -> Int

Get number of tokens (stages)

pub fn shares_prefix(a: Glyph, b: Glyph, n: Int) -> Bool

Check if glyphs share first N tokens (coarse similarity)

pub fn similarity(a: Glyph, b: Glyph) -> Float

Similarity score [0.0, 1.0] based on matching tokens

pub fn to_string(glyph: Glyph) -> String

Convert glyph to compact string representation Format: “G[42.17.89.203]” or “G[42.17.89.203:7]” with context

pub fn weighted_similarity(a: Glyph, b: Glyph) -> Float

Weighted similarity: earlier tokens matter more (coarse-to-fine) First token = most important (captures main emotion) Last token = refinement detail

pub fn weighted_similarity_adaptive(
  a: Glyph,
  b: Glyph,
  arousal: Float,
) -> Float

Adaptive weighted similarity based on arousal High arousal: prioritize coarse features [0.5, 0.3, 0.15, 0.05] Low arousal: balanced processing [0.3, 0.3, 0.25, 0.15] Validated by DeepSeek R1: matches Information Bottleneck Principle

pub fn weighted_similarity_with_weights(
  a: Glyph,
  b: Glyph,
  weights: List(Float),
) -> Float

Weighted similarity with custom weights

pub fn with_context(tokens: List(Int), context: Int) -> Glyph

Create glyph with context

Search Document