Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Visualization

The visualization pipeline generates procedural card images using LuxCore path tracing. Each card’s image is deterministic — seeded by the card ID and parameterized by features extracted from the embedding space’s geometry and topology.

Pipeline

Nomic Embeddings (768-dim)
    |
    ├──> GeometryComputer (Ollivier-Ricci curvature, gradient fields)
    └──> TDAComputer (persistent homology via ripser)
            |
            v
        CardVizData (normalized feature vector per card)
            |
            v
        Grammar Engine (CFDG-inspired recursive expansion)
            |
            v
        MeshGen (pure numpy mesh generators)
            |
            v
        LuxCore Renderer (PATHOCL GPU / PATHCPU fallback)
            |
            v
        R2 Storage (viz.gaius.zndx.org)

Mathematical Grounding

Visualization parameters are computed from the embedding space’s intrinsic geometry:

  • Ollivier-Ricci curvature: Computed on the k-NN graph (k=15, cosine metric, alpha=0.5, OTD method) via GraphRicciCurvature. For adjacent nodes x, y: kappa(x,y) = 1 - W1(mu_x, mu_y) / d(x,y), where W1 is the 1-Wasserstein distance between neighborhood distributions. Per-node curvature is the mean over incident edges. Controls glass color temperature (warm at positive kappa, cool at negative) and petal count.
  • Persistent homology: Vietoris-Rips filtration via ripser over cosine distances (max_dim=2, coefficients in Z/2). Total persistence (sum of interval lengths, normalized via tanh) controls recursion depth. Persistent Betti numbers b1 (rank of H1 at the median filtration value) generate toroidal rings (0-3). b2 generates void chambers (0-2). Individual persistence intervals spawn filament structures whose scale encodes interval lifetime.
  • Gradient fields: The curvature gradient (nabla kappa) is approximated by finite differences on the k-NN graph, projected to 2D via PCA. Positions the key light source. Divergence (nabla dot nabla kappa) controls glass boundary emission.
  • Complexity: Mean cosine distance to k-nearest neighbors, normalized across the collection. Controls surface subdivision and branching probability — isolated cards produce finer geometry.

Grammar Engine

grammar.py implements a CFDG-inspired recursive expansion system (Horigan, 2004; Context Free Design Grammars). The core mechanism: at each expansion step, the grammar chooses among alternative productions with probabilities derived from the card’s feature vector. Transforms compose multiplicatively, producing self-similar structures at decreasing scales.

Deterministic seeding: sha256(card_id) seeds the RNG, so the same card always produces the same visualization regardless of when or where it is rendered.

Termination: Expansion stops when accumulated scale drops below MIN_SCALE (0.08) or the shape budget (MAX_SHAPES = 35) is exhausted.

Feature-to-weight mappings:

FeatureGrammar Effect
curvaturePetal count, recurse-vs-stop weight, dome factor
persistenceMax depth (3–7), shell nesting weight, spiral count
complexityBranch-vs-grow weight, surface segments
boundaryEmission strength, volume density, core radius
b1Number of toroidal rings (0–3)
b2Number of void chambers (0–2)
diagramFilament count, scale, and z-position from persistence intervals
card_indexPhase offset for rotational variety within a collection

Three root arrangement modes (cluster, spiral, branches) combine with six shape primitives (petal, shell, torus, void, filament, core).

Mesh Generators

meshgen.py provides pure numpy mesh generators — each is a function (parameters) → (vertices, faces, normals):

GeneratorGeometryParameters
ico_sphereSubdivided icosahedronradius, subdivisions
petal_diskRadially-modulated diskradius, petal_count, amplitude
torusStandard torusmajor_radius, minor_radius, segments
cylinderOpen cylinderradius, height, segments

All generators produce vertex normals for smooth shading. Euler rotation and uniform scaling are applied per-shape by the grammar’s accumulated transform.

Render Backend

LuxCore’s unbiased path tracer via the pyluxcore Python API. The from-source build (thirdparty/installed/LuxCore/pyluxcore/) provides CUDA support; the PyPI wheel (CPU-only) serves as fallback.

  • PATHOCL — GPU-accelerated path tracing on CUDA devices. Hybrid mode automatically uses both GPU intersection and 64 CPU native threads. Single-GPU targeting via gpu_id for orchestrator-managed eviction of vLLM endpoints.
  • PATHCPU — 64-thread CPU rendering when no CUDA devices are available. ~10x slower than single-GPU PATHOCL.
  • Materials — Spectral glass with homogeneous volume absorption. LuxCore’s spectral rendering produces physically accurate caustics and internal reflections. This was the motivation for switching from Blender Cycles, which rendered recursive glass nesting as opaque white blobs.
  • Halt conditions — Production: 60s / 512 samples per pixel. Curation pipeline: 20s / 128 spp for throughput.

Render Variants

VariantDimensionsPurpose
display1400x300Card header image on site
og1200x630OpenGraph social sharing

gRPC Integration

Rendering is triggered via the /render CLI command, which invokes the RenderCards streaming RPC. The render workload sets allow_baseline_eviction=True to temporarily free a GPU from vLLM inference. After rendering completes, clear_embeddings() releases the Nomic model (~3GB) from GPU memory.

Components

ModulePurpose
data.pyFeature extraction from embedding geometry
grammar.pyGrammar Engine — recursive shape expansion
meshgen.pyPure numpy mesh generators (ico_sphere, petal, torus)
luxcore_renderer.pyLuxCore Renderer — scene assembly and rendering
renderer.pyAsync wrappers, variant management, thread pool
storage.pyR2 upload, DB updates, KV sync