SPB Git

spb/forge-studio Public

The Instruments of LLM training — a native macOS cockpit for Forge. Train language models from scratch on Apple Silicon without a terminal.

Swift 95.7% Shell 4.3%
800 B · 23 lines swift
Raw Blame History
1// Author: Simon-Pierre Boucher — contact@spboucher.ai2//3// Bias-corrected exponential moving average (TensorBoard semantics): with4// smoothing s ∈ [0,1), ema_t = s·ema_{t-1} + (1−s)·x_t, displayed as5// ema_t / (1 − s^(t+1)) so early points aren't dragged toward zero.6import Foundation78enum Smoothing {9    static func ema(_ values: [Double], smoothing: Double) -> [Double] {10        guard smoothing > 0, smoothing < 1, !values.isEmpty else { return values }11        var out: [Double] = []12        out.reserveCapacity(values.count)13        var acc = 0.014        var correction = 1.015        for v in values {16            acc = smoothing * acc + (1 - smoothing) * v17            correction *= smoothing18            out.append(acc / (1 - correction))19        }20        return out21    }22}23