Md. Asif Uddin
    II.3.X01

    Softmax at three temperatures

    limit▲△△

    Compute softmax⁡(s/τ)\softmax(\vec{s}/\tau) for s=(2,1,0)\vec{s} = (2, 1, 0) at τ=1\tau = 1, τ=0.5\tau = 0.5 and τ=2\tau = 2. State what each result says about the temperature’s role, and name the two limits.

    Hint

    Divide before exponentiating, and subtract the largest entry of the scaled vector first. The three denominators are all you need.

    Solution

    τ = 1. Scaled scores (2,1,0)(2,1,0). Subtract the maximum: (0,−1,−2)(0,-1,-2), giving exponentials 11, 0.36790.3679, 0.13530.1353, and a denominator of 1.50321.5032.

    a=(0.6652,  0.2447,  0.0900)\vec{a} = (0.6652,\; 0.2447,\; 0.0900)

    τ = 0.5. Scaled scores (4,2,0)(4,2,0). Shifted: (0,−2,−4)(0,-2,-4), exponentials 11, 0.13530.1353, 0.01830.0183, denominator 1.15361.1536.

    a=(0.8668,  0.1173,  0.0159)\vec{a} = (0.8668,\; 0.1173,\; 0.0159)

    τ = 2. Scaled scores (1,0.5,0)(1, 0.5, 0). Shifted: (0,−0.5,−1)(0,-0.5,-1), exponentials 11, 0.60650.6065, 0.36790.3679, denominator 1.97441.9744.

    a=(0.5065,  0.3072,  0.1863)\vec{a} = (0.5065,\; 0.3072,\; 0.1863)

    Each row sums to 1.00001.0000.

    What it says. Lowering τ\tau multiplies every score gap by 1/τ1/\tau before exponentiating, so the distribution concentrates on the largest entry; raising τ\tau shrinks the gaps toward zero and flattens it. The mass on the top token moves from 0.50650.5065 to 0.86680.8668 as τ\tau falls from 2 to 0.5, on unchanged scores.

    The two limits. As τ→0+\tau \to 0^{+} the distribution approaches one-hot(arg⁡max⁡s)\text{one-hot}(\arg\max \vec{s}); as τ→∞\tau \to \infty it approaches the uniform distribution over the three entries, (1/3,1/3,1/3)(1/3, 1/3, 1/3). Neither limit is reached at any finite τ\tau.

    Draws on