Files
proofs/lean/AI/Embedding.lean
zeekayandHanzo Dev 638fba4c90 Publish under the org, not a person
Bylines, paper authorship, correspondence addresses and the founder blurb under
each post named an individual. They name the organisation that published the
work instead: the brand on posts and pages, the research byline on papers, and
research@ in place of a personal address. Both are what these repositories
already used elsewhere — nothing new was coined.

Co-authors are untouched. Where a paper named someone else alongside, they stay
named; only the one byline changed. Bibliography entries, running heads,
PDF metadata and affiliations move with it, so a citation still resolves to
whoever the cited paper names.

Sample and fixture data uses the placeholder name these tests already use
elsewhere, so no assertion changed meaning.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-01 08:58:14 -07:00

70 lines
2.1 KiB
Lean4

/-
Authors: Antje Worring, Zoo Labs Foundation Research
Embedding Correctness (7680-dimensional)
Vector embeddings for semantic search and RAG.
Zoo uses 7680-dimensional embeddings for maximum resolution.
Maps to:
- zoo/papers/embedding-7680.tex: embedding specification
- hanzo/engine: embedding inference
- zoo/node: embedding storage
Properties:
- Dimensionality: 7680 dimensions (highest resolution)
- Normalization: unit-length vectors for cosine similarity
- Determinism: same input → same embedding
- Batching: batch embeddings preserve individual results
Author: Zoo Labs Foundation Research
-/
import Mathlib.Data.Nat.Defs
import Mathlib.Data.List.Basic
import Mathlib.Tactic
namespace AI.Embedding
def standardDim : Nat := 7680
structure EmbeddingVector where
dim : Nat
hash : Nat -- content hash of the vector
normalized : Bool -- unit length for cosine sim
axiom embed : Nat → EmbeddingVector
axiom embed_deterministic : ∀ (input : Nat), embed input = embed input
/-- DIMENSIONALITY: Standard embedding is 7680-dim -/
axiom embed_dim : ∀ (input : Nat), (embed input).dim = standardDim
theorem dim_is_7680 : standardDim = 7680 := rfl
/-- NORMALIZATION: Embeddings are unit-length -/
axiom embed_normalized : ∀ (input : Nat), (embed input).normalized = true
/-- DETERMINISM: Same input always produces same vector -/
theorem deterministic (input : Nat) :
embed input = embed input := rfl
/-- BATCH: Batch embedding = individual embeddings -/
noncomputable def batchEmbed (inputs : List Nat) : List EmbeddingVector :=
inputs.map embed
theorem batch_length (inputs : List Nat) :
(batchEmbed inputs).length = inputs.length := by
simp [batchEmbed]
theorem batch_preserves (inputs : List Nat) (i : Fin inputs.length) :
(batchEmbed inputs)[i]'(by simp [batchEmbed, i.isLt]) = embed inputs[i] := by
simp [batchEmbed, List.getElem_map]
/-- 7680 > 1536 (OpenAI ada-002) -/
theorem higher_resolution : standardDim > 1536 := by simp [standardDim]
/-- 7680 > 3072 (OpenAI text-embedding-3-large) -/
theorem higher_than_openai : standardDim > 3072 := by simp [standardDim]
end AI.Embedding