Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

langevin-dynamics

БесплатноБез исполняемых скриптовНе проверен

Layer 5: SDE-Based Learning Analysis via Langevin Dynamics

plurigridот plurigrid★ 73 звезды на GitHub

Об этом скилле

langevin-dynamics-skill

Layer 5: SDE-Based Learning Analysis via Langevin Dynamics

bmorphism Contributions

"what would it mean to become the Fokker-Planck equation—identity as probability flow?" — bmorphism gist

Active Inference Connection: Langevin dynamics is the generative model underlying Active Inference in String Diagrams (Tull, Kleiner, Smithe). The gradient descent + noise duality maps to:

  • Drift term (−∇L) → Action: minimizing surprise
  • Diffusion term (√2T dW) → Perception: sampling uncertainty

Philosophical Frame: bmorphism's question about "becoming the Fokker-Planck equation" points to identity as probability flow — the self is not a fixed point but a trajectory through parameter space, converging toward equilibrium while maintaining exploratory uncertainty.

Ergodic Convergence: For ergodic systems, time averages equal ensemble averages. This is the mathematical foundation for the GF(3) ERGODIC trit — the neutral state that connects BACKFILL (-1) and LIVE (+1) through mixing.

Version: 1.0.0 Trit: 0 (Ergodic - understands convergence) Bundle: analysis Status: ✅ New (based on Moritz Schauer's approach)


Overview

Langevin Dynamics Skill implements Moritz Schauer's approach to understanding neural network training through stochastic differential equations (SDEs). Instead of treating training as a black-box optimization, this skill instruments the randomness to reveal:

  1. Temperature control: How noise scale affects exploration vs exploitation
  2. Fokker-Planck convergence: When training reaches equilibrium
  3. Mixing time: How long until the network reaches steady state
  4. Discretization effects: How learning rate affects continuous theory

Key Contribution (Schauer 2015-2025): Continuous-time theory is a guide, not gospel. Real training is discrete. We instrument and verify empirically.

Research Foundation

Based on Moritz Schauer's work:

  • Bayesian Inference for Discretely Observed Diffusion Processes (Ph.D. Thesis, 2015)
  • Guided Proposals for Simulating Multi-Dimensional Diffusion Bridges (van der Meulen, Schauer & van Zanten, 2017)
  • Automatic Backward Filtering Forward Guiding for Markov Processes (Schauer & van der Meulen, 2020)
  • Controlled Stochastic Processes for Simulated Annealing (2025)

Schauer emphasizes that:

"Don't use continuous theory as a black box. Solve the SDE numerically, compare different discretizations, then verify empirically."

Core Concepts

Langevin Dynamics SDE

dθ(t) = -∇L(θ(t)) dt + √(2T) dW(t)

Where:
  θ = network parameters
  L = loss function
  ∇L = gradient (drift)
  T = temperature (noise scale)
  dW = Brownian motion (noise)

Fokker-Planck Equation

The distribution of θ evolves according to:

∂p/∂t = ∇·(∇L·p) + T∆p

Stationary distribution: p∞(θ) ∝ exp(-L(θ)/T)

Convergence to this Gibbs distribution governs learning dynamics.

Mixing Time (τ_mix)

τ_mix ≈ 1 / λ_min(H)

Where H = Hessian of loss landscape

Time until the network reaches equilibrium. Training that stops before equilibration reaches different minima than continuous theory predicts.

Capabilities

1. solve-langevin-sde

Solve Langevin SDE with multiple discretization schemes:

from langevin_dynamics import LangevinSDE, solve_langevin

# Define SDE
sde = LangevinSDE(
    loss_fn=neural_network_loss,
    gradient_fn=compute_gradient,
    temperature=0.01,
    base_seed=0xDEADBEEF
)

# Solve with different solvers
solutions = {}
for solver in [EM(), SOSRI(), RKMil()]:
    sol, tracking = solve_langevin(
        sde=sde,
        θ_init=initial_params,
        time_span=(0.0, 1.0),
        solver=solver,
        dt=0.01
    )
    solutions[solver.__class__.__name__] = (sol, tracking)

# Compare solutions to understand discretization effects

2. analyze-fokker-planck-convergence

Check if trajectory is approaching Gibbs distribution:

from langevin_dynamics import check_gibbs_convergence

convergence = check_gibbs_convergence(
    trajectory=solution,
    temperature=0.01,
    loss_fn=loss_fn,
    gradient_fn=gradient_fn
)

print(f"Mean loss (initial): {convergence['mean_initial_loss']:.5f}")
print(f"Mean loss (final): {convergence['mean_final_loss']:.5f}")
print(f"Std dev (final): {convergence['std_final']:.5f}")
print(f"Gibbs probability ratio: {convergence['gibbs_ratio']:.4f}")

if convergence['converged']:
    print("✓ Trajectory has reached Gibbs equilibrium")
else:
    print("⚠ Training stopped before equilibration")

3. estimate-mixing-time

Estimate how long until network reaches steady state:

from langevin_dynamics import estimate_mixing_time

tau_mix = estimate_mixing_time(
    solution=trajectory,
    gradient_fn=gradient_fn,
    temperature=T
)

print(f"Estimated mixing time: {tau_mi
Полный SKILL.md на GitHub

Установить langevin-dynamics в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл langevin-dynamics?

Layer 5: SDE-Based Learning Analysis via Langevin Dynamics

Как установить скилл langevin-dynamics?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл langevin-dynamics запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить langevin-dynamics с