viva_glyph/glyph
Glyph - Compressed emotional signature
A Glyph is VIVA’s native “word” - not human language, but a compact learned representation optimized for:
- Machine-to-machine communication
- Efficient comparison (token matching vs float math)
- Finite vocabulary (deterministic, enumerable)
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 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 shares_prefix(a: Glyph, b: Glyph, n: Int) -> Bool
Check if glyphs share first N tokens (coarse similarity)
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