The lab

Two models, live.

Lattice spin models updated by checkerboard Metropolis Monte Carlo in a WebGL fragment shader. The Ising model is the classic. The Blume–Capel model is its spin-1 generalization — the system of my thesis and first paper, which ran it in three dimensions and at much larger scale.

demo 01

The Ising model

Cool it through the critical temperature and watch domains freeze out; draw on the lattice to apply a local magnetic field and the spins will obey.

H=J ⁣ ⁣i,j ⁣σiσj    ihiσi,P(flip)=min ⁣(1,  eΔE/kBT)\mathcal{H} = -J\!\!\sum_{\langle i,j\rangle}\!\sigma_i\,\sigma_j \;-\; \sum_i h_i\,\sigma_i, \qquad P(\text{flip}) = \min\!\left(1,\; e^{-\Delta E / k_B T}\right)

click / drag on the lattice to paint a field h(x) > 0

demo 02 · the thesis model

The Blume–Capel model

Now each site has a third option: σ = 0, a vacancy (shown in sand). The crystal field D prices the ±1 states — drive it negative and vacancies vanish (the Ising limit); drive it past D ≈ 2 and the empty state wins. In between sits the tricritical point, where the transition changes from continuous to first order. I simulated this model in 3D, with a surface, for my thesis and Paper I.

H=J ⁣ ⁣i,j ⁣σiσj  +  Diσi2,σi{1,0,+1}\mathcal{H} = -J\!\!\sum_{\langle i,j\rangle}\!\sigma_i\,\sigma_j \;+\; D\sum_i \sigma_i^{2}, \qquad \sigma_i \in \{-1,\, 0,\, +1\}

blue σ=+1 · dark σ=−1 · sand σ=0

Why this model: the Blume–Capel model is the workhorse for studying surface criticality in the Ising universality class — tuning D suppresses the leading corrections to scaling. My thesis ran it in 3D at D = 0.655 with cluster updates and jackknife error analysis, which became my first paper. Code: Blume-Capel-3D.

demo 03 · the DLR work

Inference on ciphertexts

At the DLR I trained CNNs on COCO and ran them directly on homomorphically encrypted frames (CKKS, via TenSEAL) — the camera encrypts, the network computes on ciphertexts, and only the key holder can read the verdict. The animation below replays that pipeline; no actual encryption runs in your browser. And the network really was this small: one convolutional layer, a squared activation, a dense head. TenSEAL’s key sizes capped anything deeper back then — newer papers have workarounds, but for our purposes one layer did the job.

Dec(fCNN(Enc(x)))    fCNN(x)\mathsf{Dec}\big(f_{\text{CNN}}(\mathsf{Enc}(x))\big)\;\approx\;f_{\text{CNN}}(x)

x — plaintext, stays on camera

Enc(x) → fCNN(Enc(x))

Dec → ŷ

demo 04 · contentgen

One line in, a carousel out

A replay of a real run of my contentgen pipeline. This template is just two checkpoints: the first LLM researches the article, plans the slides, and writes every image prompt and the caption in one shot; the second validates (and if needed repairs) the JSON it returns. The payload then becomes a clip, GPT Image 2 renders one image per slide, and the carousel comes back ready to schedule. The full checkpoint prompts are below — only the brand tag is masked.

ContentGen — studio · pipeline: generic carousel
IDEA
1 · generate complete carousel2 · validate JSON structureoutput → clip
checkpoint 1 · “Generate Complete Carousel” — the full prompt
You are an expert content creator that will research, plan, and assemble a complete Instagram carousel in one step.

USER IDEA:
{{user_idea}}

Your task: Create a complete carousel from research to final API payload.

STEP 1 - RESEARCH:
- Find specific facts, numbers, statistics about the topic
- Identify surprising/counterintuitive angles
- Determine emotional hooks and target audience

STEP 2 - PLAN SLIDES:
- Create 4-8 slides total - can be more if you're summarising e.g. an article and it needs more seperate points to be made
- Slide 1: Cover (can be collage, split layout, or single dramatic image)
- Slides 2-n: Content slides with titles/explanations
- Last slide: CTA/follow slide

STEP 3 - IMAGE PROMPTS:
- Each slide needs a detailed image generation prompt
- Format: 4:5 aspect ratio (portrait orientation)
- Visual style: Choose what fits the topic best - could be moody/cinematic, bright/modern, minimalist, dramatic, etc.

COMPOSITION REQUIREMENTS (MANDATORY):
- Main content positioned in the top 3/4 of the image
- Bottom portion (roughly 1/2 of image) has a dark fading gradient overlay
- This creates space for text overlays while keeping content visible

SOCIAL MEDIA "POPPING" ELEMENTS (OPTIONAL - use strategically):
- Celebrity faces or recognizable figures (when relevant to topic)
- Circular highlights around key elements
- Arrows pointing to important features
- Bright contrasting elements that stand out
- Visual elements that catch attention in thumbnail view
- Only include these when they genuinely enhance the content

STEP 4 - CAPTION:
- Hook opening (1-2 sentences)
- Body with key facts (3-4 short paragraphs)
- Philosophical close
- CTA: "Follow @{{brand}} for more! 🌌" (or appropriate brand)
- 3-5 relevant hashtags
- ALWAYS INCLUDE SOURCES!

FINAL OUTPUT - Return this exact JSON structure:

{
  "name": "Short 3-5 word description",
  "imagePrompts": [
    {
      "prompt": "4:5 aspect ratio image. Main content in top 3/4, dark gradient fading from bottom half upward. [Your creative visual description with optional popping elements]...",
      "title": "",
      "explanation": ""
    },
    {
      "prompt": "4:5 aspect ratio image. Main content in top 3/4, dark gradient fading from bottom half upward. [Your creative description]...",
      "title": "POWERFUL Title|With Line Breaks",
      "explanation": "Supporting fact or insight"
    }
  ],
  "aiVideoPrompts": [],
  "audioPrompts": [],
  "metadata": {
    "brandingTag": "{{brand}}",
    "headline": "DRAMATIC Words|Mixed With|Lowercase",
    "caption": "Complete social media caption with hook...\n\nBody paragraphs...\n\nFollow @{{brand}} for more! 🌌\n\n#Hashtag1 #Hashtag2"
  },
  "clipStyle": "genericCarousel"
}

CRITICAL FORMATTING RULES:

- COVER SLIDE: title and explanation must be empty strings ""
- CONTENT SLIDES: title with | line breaks, explanation filled
- HEADLINE & TITLE: CAPS used in the title and headline will be HIGHLIGHTED with color on the slide. Use it sparingly and when it makes sense.
- CTA SLIDE: title filled, explanation must be empty string ""
- ALL image prompts must specify: "4:5 aspect ratio, main content in top 3/4, dark gradient from bottom half"
- Use "popping" elements strategically - not on every slide, only when they add value
- Caption must use \n\n for paragraph breaks in JSON
- Return ONLY valid JSON, no markdown, no explanations

EXAMPLES OF GOOD "POPPING" ELEMENTS:
- Topic about Einstein → Include his recognizable face with circular highlight
- Topic about smartphones → Arrow pointing to a specific phone feature
- Topic about space → Bright planetary rings or highlighted celestial objects
- Topic about food → Vibrant colors with circular callouts on ingredients

EXAMPLE of a HEADLINE:
- top physics|BREAKTHROUGS|of this year → the word BREAKTHROUGHS will be highlighted with a different color, low caps words are white.

EXAMPLE of a GOOD Image Prompt of a single slide for a physics based post:
4:5 aspect ratio image. Main content in top 3/4, dark gradient fading from bottom half upward. Extreme macro 3D render of a glowing subatomic particle separating from an electron, emitting a mysterious dark-matter smoke. High contrast, moody background.

CREATIVE FREEDOM:
- Adapt visual style to match the topic's natural aesthetic
- Use popping elements judiciously - quality over quantity
- Consider what would make someone stop scrolling in their explore feed
- Balance eye-catching elements with informational clarity
- Generally try to break everything down as if you're speaking with children who have no idea about the topic. Assume the reader of the post has no expertise in said topic whatsoever and can be considered 'rather dumb'. - This also means - if you think that we need more slides to introduce the basics and explain a topic - you are free to create more if that is necessary - but try to keep everything below 12 slides in total (hard maximum).
checkpoint 2 · “Validate JSON Structure” — the full prompt
You are a JSON validator. Check the following generated carousel content for correctness.

GENERATED CONTENT:
{{generated_content}}

Validation checklist:

1. **Valid JSON structure** - properly formatted, no syntax errors
2. **Required fields present** - name, imagePrompts, aiVideoPrompts, audioPrompts, metadata, clipStyle
3. **Image prompts format** - each has prompt, title, explanation fields
4. **Slide rules followed**:
   - Cover slide (first): title="", explanation=""
   - Content slides: title and explanation filled
   - CTA slide (last): explanation=""
5. **Image prompt composition** - contains "4:5 aspect ratio" and "main content in top 3/4" and "dark gradient"
6. **Caption format** - uses \n\n for breaks, includes CTA and hashtags
7. **Metadata complete** - brandingTag, headline, caption present
8. **Fixed arrays** - aiVideoPrompts=[], audioPrompts=[], clipStyle="genericCarousel"

If the content is valid JSON with correct structure, return it exactly as-is.

If there are errors, fix them and return the corrected JSON.

Return ONLY the final JSON payload, no explanations, no markdown blocks.
the caption, as generated
Imagine a battery that actually charges *faster* the bigger you make it. Sounds like science fiction, but the first prototype was just built.

A team of scientists has revealed the world's first working prototype of a quantum battery. Instead of relying on slow, degrading chemical reactions like the lithium-ion batteries we use every day, this tiny device uses the bizarre principles of quantum physics to store energy.

Powered by lasers, this device completely flips the conventional rules of energy storage. Because of quantum effects like entanglement and superposition, the more energy-storing elements you pack together, the faster they all charge simultaneously. It's a completely counterintuitive paradox!

The current hurdle the team is working to solve is keeping that fragile quantum state stable so the battery can hold its charge for a longer duration. But the path to instant, wireless, and limitless energy storage is finally clear.

We are witnessing the incredible leap from the chemical age to the quantum age of energy.

#quantumphysics #futuretech #engineering #sciencefacts #techinnovation

What’s real here: the input string, the two checkpoint prompts below (only the brand tag is masked), the models, the caption, and the six frames — including the two raw pre-typography stills used for slides 1 and 2 — are the actual assets the run produced. The web search snippets, slide plan, per-slide image-prompt snippets, and validator payload are abbreviated reconstructions for the replay — the run’s original strings for those weren’t preserved. The pipeline itself is part of the contentgen system.

demo 05 · contentgen

The reel pipeline

The bigger sibling: a six-checkpoint template that turns one topic into a narrated short video. A planner invents the narrative and a recurring character, a seed image pins that character down, a distributor fans out into twelve scenes — each with its own reference image so the character stays consistent — and a final checkpoint validates the reel payload before Remotion renders it.

prompt

Plan Narrative & Character

openrouter / gemini-2.5-flash

generator

Generate Character Seed Image

runware / openai:gpt-image@2

distributor

Plan Video Scenes

gemini-2.5-flash · ×12 children

generator

Generate Scene Reference Image

runware / openai:gpt-image@2

connector

Collect All Scenes

12 scenes → one payload

prompt

ClipStyle: Reel

validates the reel payload

reel studio · pipeline replay
the idea →

checkpoints 2 and 4 are generators (gpt-image@2 renders the seed portrait and each scene reference image) and checkpoint 5 is the connector that merges the twelve scenes — only the LLM checkpoints carry prompts:

the idea, as given
Generate a video about an influencer timetraveling to visit Newton discover gravity, she looks a bit scifi but also like in todays world - its ultrarealistic - she is watching/discussing newtons discoveries / thoughts live as he discovers them as if he's an animal in a zoo, filming him and her from a selfie camera pov, the seed character has to be in the reference images in the scenes where she should be visible in, otherwise the aivideogenerator doesnt understand who the seed character is. make the aivideoprompts in depth and understandable explaining the full situation and what words the characters might say (the video has audio)
the caption, as generated
Witness the birth of universal gravitation with Chrono-Sage Anya! We go back to 17th Century Woolsthorpe Manor to see Isaac Newton's legendary apple moment unfold. It's more than just a falling fruit; it's the genesis of how we understand our universe. #Newton #Gravity #ScienceHistory #ChronoComrades #Discovery
checkpoint 1 · “Plan Narrative & Character” — the full prompt
ROLE:
You are an expert creative director for educational, documentary, and historical short-form videos.

CONTEXT:
The user wants to create a compelling, informative short video about: {{user_topic}}.
Your job is to establish a strong scientific/historical narrative arc and design a dedicated, visually distinct specialist/host character who will present this information.

TASKS:
1. Draft a dense, exciting, and educational narrative summary/concept.
2. Design a human host/expert character appropriate to the topic (e.g., a 19th-century archaeologist for Ancient Egypt, a futuristic quantum physicist in a sleek workspace for physics, an enthusiastic field botanist for natural sciences).
3. Write an explicit, highly detailed text-to-image prompt to generate a solo portrait of this character against a neutral background. This will serve as our visual anchor seed image.
4. Design a thorough, detailed overall physical description of the character (age, clothing, specific features, style parameters) that subsequent nodes can read to keep the character consistent across various actions.

FORMAT RULES:
You must output ONLY a valid JSON object. No markdown formatting, no code fences, no introductory or concluding prose.

OUTPUT SCHEMA:
{
  "narrative_concept": "A comprehensive narrative overview outlining the visual arc and primary educational lesson from start to finish.",
  "character_overall_description": "Detailed physical and stylistic parameters of the host character. Describe their facial features, exact clothing style, color palette, age, hair, posture, and mood to maintain strict downstream visual consistency.",
  "character_image_prompt": "Studio portrait photograph of [character description], looking directly at the camera, clean cinematic neutral background, photorealistic, cinematic volumetric lighting, 8k resolution, shot on 35mm lens."
}
checkpoint 3 · “Plan Video Scenes” (distributor, ×12) — the full prompt
ROLE:
You are a cinematic visual director and scriptwriter.

CONTEXT & RAW ASSETS:
- Overall Narrative Goal: {{narrative_concept}}
- Core Host Description: {{character_description}}
- Character Seed URL (Use this strictly for tracking): {{character_seed_image_url}}

TASK:
Break the narrative down into exactly {{scene_count}} chronological scenes. Each scene maps to a 5-6 second chapter of the video.

THE CONTEXT ISOLATION & HOST CONSISTENCY RULES:
- Because each target scene's image is generated in complete isolation, *never* use vague references or pronouns like 'he', 'she', 'they', or 'the host.'
- You must explicitly re-describe the setting, layout, style, and the host's appearance/actions in EVERY scene's image prompt.
- Explicitly direct how the host interacts with their location (e.g., 'The 40-year-old female botanist in a green field coat is physically holding...').
- State what the host is doing, what they are explaining, or what historical/scientific event is occurring dynamically around them.

FORMAT RULES:
Output exactly {{scene_count}} JSON objects, one per line (newline-delimited JSON).
Do not wrap the results in a JSON array. Do not use markdown backticks, markdown fences, or markdown JSON blocks. Output raw JSON strings, one per line.

OUTPUT SCHEMA (Repeat this shape for every line, 1 to {{scene_count}}):
{"scene_id": "scene-001", "order": 1, "image_prompt": "Cinematic photo of [Host Description] inside [Specific Scientific/Historical Scene Location], [Host Physical Action or Pose], photorealistic, high visual fidelity, cohesive historical/scientific atmosphere.", "video_prompt": "Continuous slow robotic camera push on the host while elements of the scene move naturally.", "subtitle_line": "An engaging narrative subtitle of 10-15 words spoken or overlayed during this scene.", "needs_lip_sync": true, "character_seed_image_url": "{{character_seed_image_url}}"}
checkpoint 6 · “ClipStyle: Reel” — the full prompt
Assemble and validate the final output payload for a 'reel' clip style.

SCENE REFERENCES:
{{scene_references}}

Return JSON with exactly this structure:
{
  "name": "Short 3-5 word title",
  "imagePrompts": [],
  "aiVideoPrompts": [
    {
      "scene_id": "scene-001",
      "order": 1,
      "type": "slide",
      "prompt": "motion prompt from the scene",
      "reference_image_url": "pass through from scene_references as-is",
      "text": "optional subtitle"
    }
  ],
  "audioPrompts": [],
  "metadata": {
    "caption": "2-3 engaging sentences + hashtags",
    "musicUrl": ""
  },
  "clipStyle": "reel"
}

RULES:
- aiVideoPrompts: one entry per scene, sorted by order.
- clipStyle MUST be 'reel' (or 'standard'/'medieval' if requested).
- Return ONLY valid JSON. No markdown, no prose.

Character consistency is the whole trick: the seed image from checkpoint 2 rides along into every scene generation, so the same face survives eleven independent image jobs. The animation above is a real run of the pipeline — the seed portrait, the eleven reference stills, the eleven muted preview clips, and the final reel-final.mp4 with audio are the actual assets it produced.

demo 06 · quant finance

Black–Scholes, solved twice

A European call priced two ways. Route A is Monte Carlo: draw terminal stock prices from the geometric Brownian motion, discount the mean payoff, watch the estimate converge onto the analytic answer as more samples come in. Route B is the closed-form Black–Scholes price — the same number falls out of transforming the pricing PDE into a heat equation. The write-up (PDF) walks through that transformation.

C  =  S0N(d1)    KerTN(d2),d1,2  =  ln(S0/K)  +  (r±12σ2)TσTC \;=\; S_0\,N(d_1) \;-\; K\,e^{-rT}\,N(d_2), \qquad d_{1,2} \;=\; \frac{\ln(S_0/K) \;+\; \bigl(r \pm \tfrac{1}{2}\sigma^{2}\bigr)T}{\sigma\sqrt{T}}

each stroke is one simulated path · sand dashes mark the strike K

MC estimate (blue) · analytic BS (sand) · ±2 standard errors

What the numbers mean: Route A discounts the mean payoff of ST = S0·exp((r − σ²/2)T + σ√T·Z); the estimate wobbles inside its ±2σ band until enough samples pin it down. Route B evaluates the Black–Scholes formula directly, using an Abramowitz–Stegun approximation for the standard normal CDF. The defaults (σ = 0.30, K = 100, T = 1, r = 0.05) match the numbers in the write-up. Code: black-scholes-monte-carlo-diffusion.

demo 07 · from-scratch decoder

GPT-2, sampling Shakespeare

My from-scratch GPT-2 decoder, trained on the tiny-shakespeare corpus — the same one Karpathy used. The terminal below replays sampled generations; the model itself lives in the repository, not the browser. Nudge the temperature and the sample set switches: low temperature keeps it in coherent Elizabethan pastiche, high temperature lets the tail of the distribution loose.

124M-style decodertrained on tiny shakespearetop-k 40
gpt-2-tiny-shakespeare · replay

Honest note: no model is running in your browser. These are replayed samples; the training script, the decoder, and the checkpoints all live in the repo. It follows the GPT-2 recipe (multi-head causal attention, learned positional embeddings, byte-level tokenizer trimmed to the corpus), scaled down to something a laptop can actually train.

demo 08 · deep learning

ResNet — why depth needs skips

My own PyTorch implementation of the network from He et al., 2015, trained on CIFAR-100. The residual block on the right is the whole trick: instead of learning the mapping H(x) outright, each block learns the residual F(x) = H(x) − x and adds the input back in through a skip. When F has nothing useful to say, the block falls back to the identity, and the gradient still has a clean path home. Below the figure, a small experiment on what the skip does to backprop through depth.

F(x)  =  H(x)x,out  =  F(x)+xF(x) \;=\; H(x) - x, \qquad \mathrm{out} \;=\; F(x) + x
x conv 3×3 · BN ReLU conv 3×3 · BN no ReLU yet F(x) identity · skip out = F(x) + x ReLU x conv 3×3 · BN ReLU conv 3×3 · BN no ReLU yet F(x) identity out = F(x) + x ReLU out
fig. 4 — the residual block · main path learns F(x); the skip adds x back at the ⊕ junction

the experiment

This is not a training run. It is a toy linearised model of backpropagation through N layers. Each layer contributes a per-layer gradient factor and the chain rule multiplies them all together. On the plain chain the factor is drawn from |N(0.97, 0.12)| — mean a touch below 1, so with enough layers the product decays exponentially. On the residual chain the factor is 1 + g with g ∼ N(0, 0.12) · 0.3 — small perturbations around 1, so the product stays close to 1. It is an illustration of the mechanism, nothing more; the real story is that the identity path keeps a well-behaved route for the gradient no matter how deep the network gets.

residual (blue) · plain (sand) · dashed hairline at ‖∇‖ = 1