ALGEBRAIC_DECOMPOSITION.md raw

Algebraic Decomposition and Deterministic Compression in LLM Training

A discussion exploring alternatives to gradient-based training using lossless compression schemes, locality-sensitive hashing, and algebraic structures (lattices, type systems, category theory, elliptic curves) that could enable true incremental learning without the "holographic effect."

Part 1: Deterministic Compression vs. Sampling/Quantization

The Problem

Current LLM training suffers from a fundamental mismatch:

Each new parameter affects almost the entire graph, effects are discrete and thus imprecise, and there's a limit to precision based on memory bandwidth. This raises the question: if language is inherently discrete, why use approximation-based methods?

Lossy vs. Lossless Approaches

TypeExamplesCharacteristics
LossyDCT (JPEG, MP3), wavelets (Dirac)Approximation, quantization
LosslessHuffman, arithmetic coding, LZ77/78, RLE, FLAC, PNGExact reconstruction, algebraic

For discrete data like human language or computer code, approximation may be the wrong approach if we want to minimize computation, memory copying, and rounding errors.

Research in Deterministic/Algebraic Directions

1. Minimum Description Length / Kolmogorov Complexity

The most principled connection to compression. Solomonoff induction states: the best model is the shortest program generating the data. This IS deterministic. Work by Rissanen and Grünwald on MDL formalized this. The limitation: computing Kolmogorov complexity is uncomputable in general, so we approximate.

2. Hopfield Networks and Modern Associative Memory

Classical Hopfield networks store patterns via outer products—algebraically exact for capacity up to ~0.14N patterns. Recent work (Ramsauer et al., 2020) connects modern Hopfield networks to transformer attention. These have more algebraic flavor—energy minimization with discrete attractors.

3. Transformers as Weighted Finite Automata

Theoretical work (Merrill, Sabharwal, and others) analyzes what formal languages transformers can represent. If a transformer IS a finite automaton, there might be ways to construct/train it more directly. Related: whether transformers can be represented as tensor networks with exact decompositions.

4. Sparse and Binary Networks

Binary neural networks (Courbariaux et al.), ternary quantization—keeping weights in {-1, 0, +1}. These ARE discrete, but typically still trained via gradient descent with straight-through estimators. Not truly algebraic training.

5. Program Synthesis / Neuro-Symbolic AI

If language models are "compressed programs," why not search program space directly? Work on neural program induction, differentiable interpreters. The DREAMCODER system (Ellis et al.) learns compositional libraries. More algebraic, but doesn't scale to LLM-level complexity yet.

6. Arithmetic Coding Connection

A well-trained language model IS optimal compression via arithmetic coding. If a model assigns probability p(xi | x{<i}), then arithmetic coding achieves entropy rate. Recent work ("Language Models are Compressors," Delétang et al.) formalizes this.

The implication: training a better model = learning better compression. But we still learn the compressor via gradient descent rather than constructing it algebraically.

7. Tensor Decomposition Methods

CP decomposition, Tucker decomposition, tensor-train. These give algebraic factorizations of weight matrices. Mostly used post-training for compression, but some work on training directly in decomposed form.

8. Incremental/Delta Updates

Rather than retraining everything, store differences:

The Lossless Compression Insight

For lossless schemes like FLAC/PNG, the key insight is: exploit predictable structure to encode residuals cheaply. In language:

These are deterministic transformations. An analogous approach for transformers might:

  1. Build a deterministic structure capturing exact relationships (like a suffix trie for context)
  2. Encode "exceptions" or residuals where the structure fails
  3. Update incrementally when new data arrives

Why Gradient Descent Still Dominates

The core issue: generalization. Deterministic/lossless schemes excel at reproducing seen patterns. Language requires:

These seem to require the "soft" interpolation that continuous representations provide. But perhaps there are algebraic structures (lattices, type systems, category theory) that could capture semantic relationships discretely.

Further Reading

  1. "Scaling Laws for Neural Language Models" (Kaplan et al.)
  2. "Language Models as Knowledge Bases?"
  3. "Gzip is All You Need" — compression-based classifiers
  4. "Neural Networks and Kolmogorov Complexity"
  5. Work on mechanistic interpretability

Part 2: Locality-Sensitive Hashing and Collision-Based Structure

The Key Insight

In cryptographic hashes, collision = failure. In locality-sensitive hashing (LSH):

Nilsimsa and Related Schemes

Nilsimsa specifically:

Hash Family Comparison

Hash TypeSimilarity PreservedProperties
NilsimsaEdit distance (text)256-bit, trigram-based
SimHashCosine similarityBit-sampling of projections
MinHashJaccard (set overlap)Permutation-based
GeoHashSpatial proximityHierarchical, prefix-comparable
TLSHByte distributionLocality-sensitive, diff-friendly

Connection to Neural Attention

Transformer attention as "find similar keys for this query" can be compared to LSH:

Neural attention:  softmax(QK^T / √d) → learned similarity
LSH attention:     hash(q) collides with hash(k) → designed similarity

The Reformer paper (Kitaev et al., 2020) exploited exactly this—using LSH to reduce attention from O(n²) to O(n log n). But they still learned the embeddings; LSH just accelerated the lookup.

A More Radical Proposal

Replace learned embeddings entirely with deterministic similarity hashes:

  1. Hash each token/context with Nilsimsa or SimHash
  2. Similar contexts → similar hashes (no learning needed)
  3. Store associations in a hash-addressed memory
  4. Retrieval via Hamming distance lookup
  5. Incremental updates: just add new hashes, no retraining

This resembles older approaches:

Collision-as-Structure

If collisions encode similarity, then:

This is essentially product quantization or vector quantization, but deterministic rather than learned.

Building a Generative Model

For retrieval/classification, hash-based approaches work. "Gzip is All You Need" showed compression-distance classifiers are surprisingly competitive.

For generation:

  1. Given context hash, retrieve associated continuations
  2. Combine/blend when multiple buckets are relevant
  3. Handle novel combinations (generalization)

The challenge: LSH captures surface similarity (n-grams, character patterns). Semantic similarity ("happy" ≈ "joyful") requires either:

Hybrid Architectures

1. Hash-addressed memory + minimal learned integration

context → LSH hash → retrieve candidates → small learned model → output

RETRO, REALM, RAG do variants of this, but with learned retrievers.

2. Hierarchical hashing

3. Collision-based training signal Instead of gradient descent, update based on whether the right things collide:

A Concrete Experiment

To test this approach:

  1. Build a Nilsimsa-indexed store of (contexthash → nexttoken) pairs
  2. At inference: hash context, retrieve from all buckets within Hamming distance k
  3. Vote/blend retrieved continuations (weighted by inverse Hamming distance?)
  4. Measure perplexity vs. n-gram baseline vs. small transformer

The "blend" step is where something learned might still be needed, or might admit an algebraic solution.

Part 3: The Holographic Problem and Locality of Updates

What Is the Holographic Effect?

In current neural networks, representations are distributed:

This is analogous to a hologram: every piece contains information about the whole, and you cannot modify one region without affecting the global image.

Why This Is Catastrophic for Long-Term Memory

The practical consequences are immediately visible when using LLMs:

  1. Context window as "working memory": Once information scrolls out of context, it's gone
  2. No persistent associations: The model cannot learn that ~/.ssh/id_ed25519 goes with git.mleku.dev
  3. Repeated mistakes: Forgetting which remotes use which keys, which repos have which conventions
  4. Retraining is global: To add one fact, you must touch the entire parameter space

This is not a minor inconvenience—it's a fundamental architectural limitation. A useful assistant needs:

The Goal: Eliminate Holographic Entanglement

We want a representation where:

update(knowledge_base, new_fact)
  = knowledge_base ∪ {new_fact}  # Set union, not gradient descent

Not:

update(knowledge_base, new_fact)
  = retrain(knowledge_base, corpus + new_fact)  # Global perturbation

Part 4: Lattices as Knowledge Structures

Formal Concept Analysis (FCA)

A concept lattice is a mathematical structure from Formal Concept Analysis (Ganter & Wille) that represents objects, attributes, and their relationships:

Example lattice for git configuration:

                    ⊤ (all repos)
                   / \
    (uses GitHub)     (uses gitea)
         |                 |
    (public repos)    (mleku's repos)
         |                 |
    plebeian-market   git.mleku.dev/mleku/*
         |                 |
         ⊥ (specific repo instances)

Why Lattices Solve the Locality Problem

  1. Incremental construction: Adding a new object/attribute pair extends the lattice locally
  2. No retraining: The lattice structure is computed, not learned
  3. Inheritance is automatic: If "mleku's repos use id_ed25519", this propagates down
  4. Queries are algebraic: Meet and join operations, not vector similarity

Lattice Operations for Knowledge

OperationMeaningExample
Meet (∧)Most specific common generalizationrepo ∧ uses_gitea = mleku's gitea repos
Join (∨)Most general common specializationGitHub ∨ gitea = all hosted repos
ComplementWhat doesn't have attributerepos without SSH key configured
ImplicationIf A then Bif mleku's repo → use id_ed25519

From Lattices to Language

The challenge: language is not just object-attribute relations. It requires:

But lattices can be extended:

Research Directions

  1. Lattice-based knowledge graphs: Neo4j + FCA for structured retrieval
  2. Concept lattices for word sense disambiguation: Each sense = different concept
  3. Incremental lattice construction: Algorithms that update without full recomputation
  4. Lattice embeddings: Mapping lattice structure to vector space (preserving order)

Part 5: Type Systems as Semantic Structure

The Curry-Howard Correspondence

A deep connection between logic and computation:

LogicType TheoryProgramming
PropositionTypeSpecification
ProofTermImplementation
Implication (A → B)Function typeFunction
Conjunction (A ∧ B)Product typeStruct/tuple
Disjunction (A ∨ B)Sum typeEnum/union

If we represent knowledge as types, then:

Dependent Types for Rich Relationships

Dependent types allow types to depend on values:

-- A repository parameterized by its host
Repository : Host → Type

-- An SSH key valid for a specific host
SSHKey : (h : Host) → Repository h → Type

-- The relationship is encoded in the type
git_mleku_dev : Repository Gitea
id_ed25519 : SSHKey Gitea git_mleku_dev

This makes invalid states unrepresentable. You cannot use the wrong key for the wrong remote—it's a type error.

Why Types Solve the Holographic Problem

  1. Locality: Adding a new type/term doesn't change existing types
  2. Compositionality: Types compose via well-defined rules
  3. Inference is decidable: Type checking is algorithmic (for many systems)
  4. No training: The type structure is defined, not learned

Type-Theoretic Semantics for Language

Montague semantics and its successors treat natural language as a typed lambda calculus:

Composition is function application. "Every cat sleeps" is:

every : (e → t) → (e → t) → t
cat : e → t
sleeps : e → t
every(cat)(sleeps) : t

This is fully algebraic—no gradients, no approximation.

Challenges and Extensions

  1. Lexical ambiguity: Multiple types per word (requires disambiguation)
  2. Context-dependence: Types may depend on discourse context
  3. Graded truth: Not everything is true/false (fuzzy types?)
  4. Scale: Can this handle the complexity of real language?

Research connecting types to neural models:

Part 6: Category Theory as Compositional Glue

Why Category Theory?

Category theory is the "mathematics of composition." It provides:

For our purposes: category theory can describe how semantic structures compose without reference to gradients or continuous optimization.

Key Categorical Structures

Objects and Morphisms

Functors: Structure-Preserving Maps

A functor F : C → D maps:

Application: A functor from "syntax" to "semantics" that preserves compositional structure.

Natural Transformations: Systematic Translation

A natural transformation α : F ⇒ G relates two functors:

Application: Systematic translation between representations (e.g., surface form to meaning).

Monads: Structured Computation

A monad packages:

Application: Context-dependent semantics, where T represents "in context C."

DisCoCat: Categorical Compositional Distributional Semantics

The DisCoCat framework (Coecke, Sadrzadeh, Clark) combines:

The key insight: grammatical types form a pregroup (a kind of category), and meaning composition follows the categorical structure.

Sentence: "dogs chase cats"

Grammatical types:
  dogs : n          (noun)
  chase : n^r · s · n^l   (transitive verb: consumes noun on right and left)
  cats : n          (noun)

Composition (pregroup reduction):
  n · (n^r · s · n^l) · n → s   (sentence type)

Semantic composition:
  meaning(dogs) ⊗ meaning(chase) ⊗ meaning(cats)
    → contracted via grammatical structure
    → meaning(sentence)

Why This Matters for Incremental Learning

  1. Composition is algebraic: Tensor products and contractions, not gradient descent
  2. Structure is separate from content: Grammar (categorical structure) vs. lexicon (vectors)
  3. Lexicon can be updated locally: Change meaning("dog") without affecting grammar
  4. Novel combinations are handled: Composition rules apply to unseen sentences

Limitations and Open Problems

  1. Lexical acquisition: Where do word meanings come from initially?
  2. Ambiguity: Multiple parses → multiple meanings
  3. Scalability: Can this handle real text complexity?
  4. Grounding: Connection to perception, action, world knowledge

Part 7: Elliptic Curves as an Algebraic Substrate

Why Elliptic Curves?

Elliptic curves (EC) provide a rich algebraic structure:

The hypothesis: EC groups could serve as an algebraic substrate for semantic representations, replacing continuous vector spaces.

EC Group Structure

An elliptic curve over a finite field F_p:

E: y² = x³ + ax + b (mod p)

Points on this curve, plus a "point at infinity" O, form an abelian group:

All operations are exact—no floating point, no rounding.

Potential Representation Scheme

Embedding tokens/concepts as EC points:

  1. Assign each token a deterministic point on the curve (via hash-to-curve)
  2. Semantic relationships encoded as group operations
  3. Composition via point addition or scalar multiplication
  4. Similarity via pairing-based metrics

Example structure:

Let E be a curve with generator G of order n.

Token embedding:
  embed(token) = H(token) * G   # Hash to scalar, multiply generator

Relationship encoding:
  related(A, B) iff embed(A) + embed(B) = embed(C) for some meaningful C

Composition:
  compose(context, query) = pairing(embed(context), embed(query))

Pairings for Bilinear Attention

A pairing is a bilinear map e : G₁ × G₂ → G_T where:

This is structurally similar to attention:

Attention:   softmax(Q · K^T) · V     # Bilinear in Q, K
EC Pairing:  e(Q, K) → scalar → select V

But the EC version is:

Advantages for Incremental Learning

  1. Discrete, exact operations: No accumulating rounding errors
  2. Local updates: Adding a new point doesn't change existing points
  3. Algebraic relationships: Group structure encodes semantic relationships
  4. Memory efficiency: Points are small (256-512 bits typically)
  5. Parallelizable: EC operations are highly optimized (cryptographic libraries)

Research Questions

  1. Hash-to-curve for semantics: Can we design H such that semantically similar tokens map to "nearby" points?
  2. Group structure as semantic structure: What linguistic relationships correspond to group operations?
  3. Pairing-based composition: Can pairings replace attention effectively?
  4. Incremental vocabulary: How to add new tokens without changing existing embeddings?
  5. Grounding: How to connect EC representations to perceptual input?

Potential Architecture

┌─────────────────────────────────────────────────────┐
│                EC-Based Language Model              │
├─────────────────────────────────────────────────────┤
│                                                     │
│  Input: token sequence [t₁, t₂, ..., tₙ]           │
│                                                     │
│  1. Embed: Pᵢ = H(tᵢ) * G  (hash-to-curve)         │
│                                                     │
│  2. Context: C = Σᵢ wᵢ * Pᵢ  (weighted sum in EC)  │
│             or C = P₁ + P₂ + ... + Pₙ              │
│                                                     │
│  3. Attend: For each position j,                    │
│             aⱼ = e(C, Pⱼ)  (pairing)                │
│             → discrete "attention scores"          │
│                                                     │
│  4. Retrieve: Use aⱼ to index into stored          │
│               associations (hash table lookup)      │
│                                                     │
│  5. Output: Retrieved token or composition          │
│                                                     │
└─────────────────────────────────────────────────────┘

Connection to Other Algebraic Structures

EC points can be related to:

This suggests a unified algebraic framework where EC provides the computational substrate, lattices provide knowledge organization, and types/categories provide compositional structure.

Part 8: Synthesis—Toward Non-Holographic Machine Intelligence

The Core Insight

The holographic effect in neural networks stems from:

  1. Distributed representations: Every parameter encodes everything
  2. Continuous optimization: Gradient descent couples all parameters
  3. Global loss functions: Error signal propagates everywhere

To eliminate this, we need:

  1. Localized representations: Each fact stored in a specific location
  2. Algebraic construction: Build structure, don't optimize it
  3. Compositional semantics: Meaning emerges from structure, not statistics

A Proposed Architecture

Combining the algebraic structures discussed:

┌─────────────────────────────────────────────────────────────────┐
│              ALGEBRAIC COMPOSITIONAL MEMORY (ACM)               │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  LAYER 1: ELLIPTIC CURVE SUBSTRATE                              │
│  ─────────────────────────────────────────────────────────────  │
│  • Tokens → EC points via hash-to-curve                         │
│  • Exact, discrete, parallelizable operations                   │
│  • Pairings for bilinear composition                            │
│                                                                 │
│  LAYER 2: LATTICE-STRUCTURED KNOWLEDGE                          │
│  ─────────────────────────────────────────────────────────────  │
│  • Concept lattice organizing entities and attributes           │
│  • Incremental updates via lattice insertion                    │
│  • Inheritance and implication automatic                        │
│                                                                 │
│  LAYER 3: TYPE-THEORETIC COMPOSITION                            │
│  ─────────────────────────────────────────────────────────────  │
│  • Grammatical structure as types                               │
│  • Semantic composition as type-directed evaluation             │
│  • Invalid combinations rejected at type level                  │
│                                                                 │
│  LAYER 4: CATEGORICAL INTEGRATION                               │
│  ─────────────────────────────────────────────────────────────  │
│  • Functors between layers preserve structure                   │
│  • Natural transformations for systematic translation           │
│  • Monadic context handling                                     │
│                                                                 │
│  MEMORY INTERFACE                                                │
│  ─────────────────────────────────────────────────────────────  │
│  • LSH for fast approximate retrieval                           │
│  • Exact lookup for known associations                          │
│  • Incremental insertion without retraining                     │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Properties of This Architecture

PropertyCurrent LLMsProposed ACM
Update localityGlobal (all params)Local (affected region only)
PrecisionFloat16/32, lossyExact (finite field/integer)
Memory modelImplicit in weightsExplicit, addressable
CompositionLearned (attention)Algebraic (type-directed)
GeneralizationStatistical interpolationStructural composition
InterpretabilityOpaqueTransparent (lattice/type structure)

The Long-Term Memory Problem

Current LLMs fail at persistent memory:

Failure mode: "Use id_ed25519 for git.mleku.dev"
              → scrolls out of context
              → model forgets
              → repeatedly uses wrong key

ACM solution:

1. Parse: SSH key assignment statement
2. Type: key_for(git.mleku.dev) : SSHKey
3. Lattice: Insert (git.mleku.dev, uses_key, id_ed25519)
4. Store: EC point for this fact in hash-addressed memory
5. Retrieve: On any git operation, query lattice for key association
6. Persist: Fact remains until explicitly removed

This is not context-dependent—it's a structural modification to the knowledge base.

Incremental Learning Protocol

function learn(fact):
    # 1. Parse to typed representation
    typed_fact = parse(fact) : FactType

    # 2. Compute EC embedding
    point = embed_to_curve(typed_fact)

    # 3. Insert into lattice
    lattice.insert(typed_fact.objects, typed_fact.attributes)

    # 4. Store in hash-addressed memory
    memory[hash(point)] = typed_fact

    # No gradient descent
    # No global parameter update
    # No risk of forgetting unrelated facts

What Remains to Be Solved

  1. Lexical grounding: Where do initial meanings come from?

- Possibility: Bootstrap from small neural model, then freeze - Possibility: Learn from multimodal alignment (vision, action)

  1. Ambiguity resolution: Multiple valid parses/interpretations

- Possibility: Maintain multiple lattice branches - Possibility: Type-theoretic disambiguation

  1. Soft similarity: "Happy" ≈ "joyful" isn't exact

- Possibility: Fuzzy lattice membership - Possibility: LSH buckets for approximate retrieval

  1. Scale: Can this handle billions of facts?

- Possibility: Hierarchical lattice structure - Possibility: EC curves with large group order

  1. Generation: How to produce novel text?

- Possibility: Type-directed synthesis - Possibility: Compositional template filling

Part 9: Research Roadmap

Phase 1: Foundations

Goal: Establish theoretical framework and minimal viable prototype

  1. Formalize EC-based embeddings

- Define hash-to-curve function with semantic locality property - Prove properties of composition via group operations - Implement efficient EC arithmetic (use existing crypto libraries)

  1. Build minimal concept lattice system

- Implement Formal Concept Analysis algorithms - Design incremental update procedures - Connect to simple NL understanding tasks

  1. Prototype type-theoretic composition

- Implement pregroup or CCG parser - Connect grammatical types to semantic operations - Test on compositional generalization benchmarks

Phase 2: Integration

Goal: Combine layers into working system

  1. EC + Lattice integration

- Map lattice concepts to EC points - Use pairings for lattice queries - Benchmark retrieval speed and accuracy

  1. Type-directed EC composition

- Grammatical structure guides EC operations - Composition produces EC points for phrases/sentences - Test on semantic similarity tasks

  1. Memory system

- LSH-based indexing of EC points - Exact retrieval for known associations - Incremental insertion benchmarks

Phase 3: Evaluation

Goal: Compare to neural baselines

  1. Long-term memory tasks

- Design benchmarks requiring persistent memory - Compare ACM vs. RAG vs. fine-tuning vs. in-context learning - Measure memory capacity, retrieval accuracy, update cost

  1. Compositional generalization

- SCAN, COGS, CFQ benchmarks - Compare structural composition vs. neural interpolation - Analyze failure modes

  1. Efficiency metrics

- Memory footprint per fact - Compute per update vs. gradient step - Inference latency comparison

Phase 4: Scaling

Goal: Demonstrate viability at useful scale

  1. Hierarchical structure

- Multi-level lattices for large knowledge bases - Distributed EC computation - Caching and indexing strategies

  1. Real-world knowledge

- Ingest structured knowledge bases (Wikidata, etc.) - Handle natural language variation - Connect to retrieval systems

  1. Hybrid architectures

- ACM for long-term memory + small neural model for generation - Determine minimal neural component needed - Compare hybrid vs. pure approaches

Conclusion

The holographic effect in neural networks—where every parameter encodes everything and updates propagate globally—is not a law of nature. It's an artifact of the specific architecture (distributed representations) and training method (gradient descent) we've chosen.

Algebraic alternatives exist:

The synthesis of these approaches could yield machine intelligence that is:

This is not merely an optimization—it's a different paradigm. Rather than learning a compressed statistical summary of training data, we would construct an algebraic structure that represents knowledge explicitly and composes it systematically.

The path forward requires collaboration across:

The prize: machine intelligence that actually remembers what you told it.

References and Further Reading

Compression and Information Theory

Lattices and Formal Concept Analysis

Type Theory and Semantics

Category Theory and Compositional Semantics

Elliptic Curves

Neural-Symbolic Integration

Locality-Sensitive Hashing

Hopfield Networks and Associative Memory