同じ確率分布でも、予測損失として解釈することもできれば、理想的な符号長として解釈することもできる。しかし、出力のランダム性、モデルの知識、回答の価値は、それぞれ別々に議論する必要がある。
交差エントロピー:実際に出現したトークンにどの程度の確率を与えるか
位置 t において、モデルはコンテキスト x < t に基づき語彙上の分布 q θ ( ⋅ ∣ x < t ) を出力する。今回の観測されたトークンの one-hot ベクトルを e x t と表すとき、このステップの損失は
H ( e x t , q θ ) = − log q θ ( x t ∣ x < t ) .
となる。one-hot は1回の観測における目標表現 に過ぎず、このコンテキストにおいて真のデータに次のトークンが1つだけ存在するわけではない。全体的な分布においては、期待交差エントロピーはデータ条件エントロピーと条件付きKLダイバージェンスの平均に分解できる;有限の訓練データセットにおいては、逐トークンの対数尤度の最大化(NLL)を最小化することが最尤学習に対応する。
同じ確率を算術符号やANSに割り当てれば、NLLに近い可逆符号化長が得られる。実際の圧縮システムでは、符号化オーバーヘッド、モデルのコスト、符号化・復号側で共有されるコンテキストを考慮する必要がある;予測と圧縮の関連性 は「モデルファイルそのものが圧縮器である」とは限らない。
パープレキシティ:指数の奥に隠れた幾何平均
評価シーケンスを固定し、簡略化して q t = q θ ( x t ∣ x < t ) と書き、評価に関与する n 個のトークンのみで平均を取る:
L ˉ 2 = − n 1 t = 1 ∑ n log 2 q t , PPL = 2 L ˉ 2 = ( t = 1 ∏ n q t 1 ) 1/ n .
したがって、PPL は各項の 1/ q t の幾何平均 であり、算術平均ではない。自然対数で損失を計算する場合、同じ数は PPL = e L ˉ e と表すべきであり、底と単位は一致させる必要がある。
qₜ
ℓₜ / bit
PPL
0.5
0.25
0.125
L̄₂ = 2
4
図中の3つの位置では、観測されたトークンにそれぞれ確率 0.5 , 0.25 , 0.125 が与えられています。これらは異なるコンテキストから来ており、1つの語彙分布ではありません。対応する符号長は 1 , 2 , 3 bit で、点線は平均が 2 bit であり、したがって PPL は 4 です。右側の4つの等しい格子は、同じ PPL を持つ一様4択の基準であり、元のモデルの候補数ではありません。
各観測トークンが 1/ N の確率を得る場合、PPL はちょうど N となり、これが「等価な選択肢数」の正確な例となります。一般的な分布では、それは候補トークンの数でもなく、また「モデルがどのくらいの選択肢の間で迷っているか」を数えたものでもありません。
図を準備しています 再読み込み
パープレキシティの「平均」は、いったい何を平均しているのか? 4つの観測されたトークンの確率が符号長に変換され、点線は平均符号長を示す。一様分布と不均一だが同じPPLを持つ例を比較し、最後のトークンの確率を下げて幾何平均を観察する。
{"id":"llm-perplexity","title":"パープレキシティの「平均」は、いったい何を平均しているのか?","summary":"4つの観測されたトークンの確率が符号長に変換され、点線は平均符号長を示す。一様分布と不均一だが同じPPLを持つ例を比較し、最後のトークンの確率を下げて幾何平均を観察する。","height":950,"html":"<p class=\"eyebrow\" data-i18n=\"eyebrow\"></p><h2 data-i18n=\"heading\"></h2><p class=\"intro\" data-i18n=\"intro\"></p>\n<div class=\"presets\" role=\"group\" data-i18n-label=\"examples\"><button data-preset=\"balanced\" data-i18n=\"balanced\"></button><button data-preset=\"uneven\" data-i18n=\"uneven\"></button><button data-preset=\"rare\" data-i18n=\"rare\"></button></div>\n<label class=\"control\" for=\"probability\"><span data-i18n=\"control\"></span><output id=\"probability-value\"></output></label><input id=\"probability\" type=\"range\" min=\"1\" max=\"100\" value=\"50\">\n<div class=\"metric-pair\"><div><span data-i18n=\"loss\"></span><strong id=\"mean-loss\"></strong></div><div><span>PPL</span><strong id=\"ppl\"></strong></div></div><p class=\"note\" data-i18n=\"axis\"></p><div class=\"loss-chart\"><div id=\"loss-columns\"></div><div id=\"mean-line\"><span id=\"mean-label\"></span></div></div><div id=\"token-labels\"></div>\n<details class=\"audit-details\"><summary data-i18n=\"detailLabel\"></summary><div class=\"formula\" id=\"loss-formula\"></div><div class=\"formula\" id=\"ppl-formula\"></div></details><p class=\"note\" data-i18n=\"note\"></p>\n","css":".intro { margin:8px 0 18px; color:var(--muted); font-size:14px; }\n.control { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-top:18px; }\n.control output { min-width:4em; flex-shrink:0; text-align:center; background:var(--accent-soft); color:var(--accent); padding:2px 8px; border-radius:6px; font-weight:600; }\n.formula { margin-top:18px; padding:14px 0; border-block:1px solid var(--rule); font-size:16px; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }\n.copy-stack { display:grid; margin-top:14px; color:var(--muted); font-size:14px; }\n.copy-stack > * { grid-area:1/1; }\n.copy-stack .reserve { visibility:hidden; }\n.note { margin-top:14px; color:var(--muted); font-size:12px; }\n.metric-pair { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-top:18px; }\n.metric-pair > div { min-width:0; }\n.metric-pair span { display:block; font-size:12px; color:var(--muted); }\n.metric-pair strong { display:block; font-size:24px; font-weight:500; font-variant-numeric:tabular-nums; }\n.scale { display:flex; justify-content:space-between; color:var(--muted); font-size:12px; font-variant-numeric:tabular-nums; }\n@media(max-width:480px) { .metric-pair strong { font-size:21px; } }\n.presets { display:flex; }\n.plot { position:relative; margin-top:18px; height:190px; border-left:1px solid var(--rule); border-bottom:1px solid var(--muted); }\n.plot svg { width:100%; height:100%; overflow:hidden; }\n.plot .curve { fill:none; stroke:var(--accent); stroke-width:2.5; vector-effect:non-scaling-stroke; }\n.plot .curve.secondary { stroke:var(--second); stroke-dasharray:5 4; }\n.scale { position:relative; }.scale .middle { position:absolute; left:50%; transform:translateX(-50%); }\n.formula { font-size:14px; }.formula div+div { margin-top:6px; }\n@media(max-width:480px) { .plot { height:170px; } }\n.plot .curve { transition:d .28s cubic-bezier(.22,1,.36,1); }\n.band { display:flex; height:28px; border-radius:5px; overflow:hidden; background:var(--surface); margin-top:10px; }\n.band > div { background:var(--accent); transition:width .28s ease; }\n.band > .gold { background:var(--second); }\n.legend { display:flex; flex-wrap:wrap; gap:6px 18px; margin-top:10px; font-size:12px; color:var(--muted); }\n.legend .blue::before,.legend .gold::before { content:''; display:inline-block; width:9px; height:9px; border-radius:2px; margin-right:6px; background:var(--accent); }\n.legend .gold::before { background:var(--second); }\n.rows { margin-top:18px; display:grid; gap:12px; }\n.row { display:grid; grid-template-columns:32px 1fr 60px; align-items:center; gap:10px; font-size:13px; }\n.row > div { min-width:0; }.row output { text-align:right; font-variant-numeric:tabular-nums; }\n.track { height:14px; background:var(--surface); border-radius:3px; overflow:hidden; }\n.fill { height:100%; width:0; background:var(--accent); transition:width .28s ease; }\n.presets { flex-wrap:wrap; gap:4px; }.presets button { min-width:0; }\n.metric-pair strong { overflow-wrap:anywhere; }\n.loss-chart { height:210px; position:relative; margin-top:34px; border-bottom:1px solid var(--muted); }#loss-columns { display:grid; grid-template-columns:repeat(4,1fr); gap:16px; height:100%; align-items:end; padding:0 12px; }.loss-bar { background:var(--accent); position:relative; border-radius:5px 5px 0 0; transition:height .28s ease; }.loss-bar:last-child { background:var(--second); }.loss-bar span { position:absolute; bottom:100%; width:100%; text-align:center; font-size:12px; color:var(--ink); font-variant-numeric:tabular-nums; }#mean-line { position:absolute; width:100%; border-top:1px dashed var(--ink); transition:bottom .28s ease; pointer-events:none; }#mean-label { position:absolute; right:0; top:1px; background:var(--paper); font-size:11px; padding:1px 4px; }#token-labels { display:grid; grid-template-columns:repeat(4,1fr); text-align:center; gap:4px; font-size:12px; margin-top:8px; }#token-labels span { display:block; color:var(--muted); }\n\n.loss-chart { background:repeating-linear-gradient(to top,transparent 0,transparent calc(100% / 7 - 1px),var(--rule) calc(100% / 7 - 1px),var(--rule) calc(100% / 7)); }\n@media(max-width:480px) { .loss-chart { height:168px; } }\n\n.metric-pair{margin-top:12px}.loss-chart{margin-top:24px}.intro{margin-bottom:12px}\n@media(max-width:480px){.loss-chart{height:140px}.intro{font-size:13px}.note{margin-top:10px}.metric-pair strong{font-size:21px}}\n\n.audit-details { border-top:1px solid var(--rule); margin-top:14px; padding-top:8px; }\n.audit-details summary { cursor:pointer; color:var(--accent); font-size:13px; min-height:36px; padding:6px 0; }\n.audit-details summary:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }\n.audit-details .formula { border:0; margin-top:8px; padding:8px 0; }\n","js":"const $=s=>document.querySelector(s),presets={balanced:[.5,.5,.5,.5],uneven:[.25,1,.5,.5],rare:[.5,.5,.5,.01]};let probabilities=[...presets.balanced];\nfor(let i=0;i<4;i++){$('#loss-columns').insertAdjacentHTML('beforeend','<div class=\"loss-bar\"><span></span></div>');$('#token-labels').insertAdjacentHTML('beforeend','<div>t'+(i+1)+'<span></span></div>');}\nfunction draw(){const losses=probabilities.map(p=>-Math.log2(p)),mean=losses.reduce((a,b)=>a+b)/4,ppl=2**mean;$('#probability-value').textContent=viz.number(probabilities[3],2);document.querySelectorAll('.loss-bar').forEach((e,i)=>{e.style.height=losses[i]/7*100+'%';e.querySelector('span').textContent=viz.number(losses[i],2);});document.querySelectorAll('#token-labels span').forEach((e,i)=>e.textContent='q = '+viz.number(probabilities[i],2));$('#mean-line').style.bottom=mean/7*100+'%';$('#mean-label').textContent='L̄ = '+viz.number(mean,3);\n $('#loss-formula').textContent='L̄ = ('+losses.map(l=>viz.number(l,3)).join(' + ')+') / 4 ≈ '+viz.number(mean,3)+' bit';$('#ppl-formula').textContent='PPL ≈ ⁴√('+probabilities.map(p=>viz.number(1/p,3)).join(' × ')+') ≈ '+viz.number(ppl,3);$('#mean-loss').textContent=viz.number(mean,3)+' bit';$('#ppl').textContent=viz.number(ppl,3);\n document.querySelectorAll('[data-preset]').forEach(e=>e.setAttribute('aria-pressed',String(presets[e.dataset.preset].every((p,i)=>Math.abs(p-probabilities[i])<1e-9))));}\n$('#probability').addEventListener('input',()=>{probabilities[3]=+$('#probability').value/100;draw();});document.querySelectorAll('[data-preset]').forEach(e=>e.addEventListener('click',()=>{probabilities=[...presets[e.dataset.preset]];$('#probability').value=probabilities[3]*100;draw();}));draw();\n","audio":false,"strings":{"axis":"棒の高さの固定スケール:0–7 bit;点線は4項目の平均。下部の q はそれぞれ異なるコンテキストに属し、合計が1になる必要はない。","balanced":"一様な損失","control":"第4の正解トークンへの確率","detailLabel":"幾何平均の計算を展開","examples":"確率の例","eyebrow":"対数を先に平均し、その後指数化する","heading":"パープレキシティの「平均」は、いったい何を平均しているのか?","intro":"各棒は観測されたトークンの −log₂ q である。棒の高さは算術平均され、その後指数化される;4つの 1/q を直接平均するわけではない。","loss":"平均損失 L̄","note":"最初の2つの事前設定の結合確率はどちらも 1/16 であるため、PPL はどちらも 2 だが、逐項損失は異なる。ある正解トークンの確率を下げると、平均符号長が増加する。ここでは評価トークンとコンテキストを固定し、確率の割り当てのみを比較している。","rare":"稀な末尾項目","uneven":"同じPPL"}}
例えば q = ( 1/2 , 1/2 , 1/2 , 1/2 ) と q = ( 1/4 , 1 , 1/2 , 1/2 ) の結合確率はどちらも 1/16 で、平均損失はどちらも 1 bit、PPL はどちらも 2 である。後者で 1/ q t を直接平均すると 9/4 となり、これは PPL ではない。低確率の正解トークンは NLL を引き上げます;その確率がゼロの場合、損失と PPL は無限大になります。
PPL を比較するには、コーパス、トークン化、コンテキスト長、スコアリングルールを統一する必要がある。トークナイザを跨ぐ場合は、バイト単位などの共通単位に換算し、同じ原文と処理基準を維持する必要がある;単位を変えただけでは、異なる評価セットによる差異を修復することはできない。PPL はモデルの交差エントロピー率 を読み取るものであり、直接測定された真のデータエントロピー率ではない。
KL正則化:なぜ最適戦略が「指数関数的な傾き」を生むのか
プロンプト x を固定し、条件記号を省略する。KL正則化された報酬目標は
J ( π ) = E y ∼ π [ r ( y )] − β D KL ( π ∥ π ref ) , β > 0.
である。これはRLHFでPPOなどの手法を用いて最適化可能な目標形式であり、PPOアルゴリズム全体ではない。方向は新戦略から参考戦略へ向かう;確率を参考戦略がほとんどサポートしていない回答に移すと、大きなコストがかかる。これは戦略のドリフトを制限できるが、報酬モデルに脆弱性がないことを保証するものではなく、また回答が有用であることを単独で保証するものでもない。
有限の回答空間と正の参考確率に対して、すべての分布の中で直接最適解を求めると
π ∗ ( y ) = Z π ref ( y ) exp ( r ( y ) / β ) , Z = y ∑ π ref ( y ) exp ( r ( y ) / β ) .
が得られる。
この式には3つのステップがある:参考確率から始まり、報酬の指数重みを掛け、総量 Z で割る。報酬が同じ回答は元の確率比を維持する;報酬差が大きく、β が小さいほど、比の変化は顕著になる。参考確率がゼロの場合、有限KLの戦略もその場所でゼロでなければならない;この式によって参考分布のサポート集合を突破することはできない。
図を準備しています 再読み込み
KL制約下で、高報酬の回答はどの程度の確率を得るのか? 3つの回答の参考確率と報酬を固定し、βを変化させて、最適分布が exp(r/β) に従って傾き、再正規化される様子を観察し、同時に報酬、KL、目標値を計算する。
{"id":"llm-policy","title":"KL制約下で、高報酬の回答はどの程度の確率を得るのか?","summary":"3つの回答の参考確率と報酬を固定し、βを変化させて、最適分布が exp(r/β) に従って傾き、再正規化される様子を観察し、同時に報酬、KL、目標値を計算する。","height":950,"html":"<p class=\"eyebrow\" data-i18n=\"eyebrow\"></p><h2 data-i18n=\"heading\"></h2><p class=\"intro\" data-i18n=\"intro\"></p>\n<label class=\"control\" for=\"beta\"><span data-i18n=\"control\"></span><output id=\"beta-value\"></output></label><input id=\"beta\" type=\"range\" min=\"25\" max=\"400\" value=\"100\">\n<div class=\"legend\"><span class=\"gray\" data-i18n=\"reference\"></span><span class=\"blue\" data-i18n=\"optimal\"></span></div><div id=\"policy-rows\" class=\"policy-rows\"></div>\n<div class=\"formula\" id=\"normalizer\"></div><div class=\"metric-pair\"><div><span data-i18n=\"reward\"></span><strong id=\"reward\"></strong></div><div><span>KL(π* ∥ πref)</span><strong id=\"kl\"></strong></div></div><div class=\"formula\" id=\"objective\"></div><p class=\"note\" data-i18n=\"note\"></p>\n","css":".intro { margin:8px 0 18px; color:var(--muted); font-size:14px; }\n.control { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-top:18px; }\n.control output { min-width:4em; flex-shrink:0; text-align:center; background:var(--accent-soft); color:var(--accent); padding:2px 8px; border-radius:6px; font-weight:600; }\n.formula { margin-top:18px; padding:14px 0; border-block:1px solid var(--rule); font-size:16px; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }\n.copy-stack { display:grid; margin-top:14px; color:var(--muted); font-size:14px; }\n.copy-stack > * { grid-area:1/1; }\n.copy-stack .reserve { visibility:hidden; }\n.note { margin-top:14px; color:var(--muted); font-size:12px; }\n.metric-pair { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-top:18px; }\n.metric-pair > div { min-width:0; }\n.metric-pair span { display:block; font-size:12px; color:var(--muted); }\n.metric-pair strong { display:block; font-size:24px; font-weight:500; font-variant-numeric:tabular-nums; }\n.scale { display:flex; justify-content:space-between; color:var(--muted); font-size:12px; font-variant-numeric:tabular-nums; }\n@media(max-width:480px) { .metric-pair strong { font-size:21px; } }\n.presets { display:flex; }\n.plot { position:relative; margin-top:18px; height:190px; border-left:1px solid var(--rule); border-bottom:1px solid var(--muted); }\n.plot svg { width:100%; height:100%; overflow:hidden; }\n.plot .curve { fill:none; stroke:var(--accent); stroke-width:2.5; vector-effect:non-scaling-stroke; }\n.plot .curve.secondary { stroke:var(--second); stroke-dasharray:5 4; }\n.scale { position:relative; }.scale .middle { position:absolute; left:50%; transform:translateX(-50%); }\n.formula { font-size:14px; }.formula div+div { margin-top:6px; }\n@media(max-width:480px) { .plot { height:170px; } }\n.plot .curve { transition:d .28s cubic-bezier(.22,1,.36,1); }\n.band { display:flex; height:28px; border-radius:5px; overflow:hidden; background:var(--surface); margin-top:10px; }\n.band > div { background:var(--accent); transition:width .28s ease; }\n.band > .gold { background:var(--second); }\n.legend { display:flex; flex-wrap:wrap; gap:6px 18px; margin-top:10px; font-size:12px; color:var(--muted); }\n.legend .blue::before,.legend .gold::before { content:''; display:inline-block; width:9px; height:9px; border-radius:2px; margin-right:6px; background:var(--accent); }\n.legend .gold::before { background:var(--second); }\n.rows { margin-top:18px; display:grid; gap:12px; }\n.row { display:grid; grid-template-columns:32px 1fr 60px; align-items:center; gap:10px; font-size:13px; }\n.row > div { min-width:0; }.row output { text-align:right; font-variant-numeric:tabular-nums; }\n.track { height:14px; background:var(--surface); border-radius:3px; overflow:hidden; }\n.fill { height:100%; width:0; background:var(--accent); transition:width .28s ease; }\n.presets { flex-wrap:wrap; gap:4px; }.presets button { min-width:0; }\n.metric-pair strong { overflow-wrap:anywhere; }\n.policy-rows { display:grid; gap:18px; margin-top:18px; }.policy-row { border-bottom:1px solid var(--rule); padding-bottom:14px; }.policy-label { display:flex; gap:12px; justify-content:space-between; font-size:13px; margin-bottom:8px; }.policy-label code { color:var(--muted); font-size:12px; }.row { grid-template-columns:45px 1fr 55px; gap:8px; margin-top:5px; }.reference .fill { background:var(--muted); opacity:.45; }.legend .gray::before { content:''; display:inline-block; background:var(--muted); opacity:.45; width:9px; height:9px; margin-right:6px; border-radius:2px; }\n","js":"const $=s=>document.querySelector(s),ref=[.6,.3,.1],rewards=[0,1,2];for(let i=0;i<3;i++)$('#policy-rows').insertAdjacentHTML('beforeend','<div class=\"policy-row\"><div class=\"policy-label\"><strong>'+String.fromCharCode(65+i)+' · r = '+rewards[i]+'</strong><code class=\"weight\"></code></div><div class=\"row reference\"><span>πref</span><div class=\"track\"><div class=\"fill\" style=\"width:'+ref[i]*100+'%\"></div></div><output>'+viz.number(ref[i],3)+'</output></div><div class=\"row optimum\"><span>π*</span><div class=\"track\"><div class=\"fill\"></div></div><output></output></div></div>');\nfunction draw(){const b=+$('#beta').value/100,w=ref.map((p,i)=>p*Math.exp(rewards[i]/b)),z=w.reduce((a,b)=>a+b),q=w.map(v=>v/z),reward=q.reduce((a,p,i)=>a+p*rewards[i],0),kl=q.reduce((a,p,i)=>a+p*Math.log(p/ref[i]),0);$('#beta-value').textContent=viz.number(b,2);document.querySelectorAll('.policy-row').forEach((e,i)=>{e.querySelector('.weight').textContent=viz.number(ref[i],1)+' × e^('+rewards[i]+'/'+viz.number(b,2)+')';e.querySelector('.optimum .fill').style.width=q[i]*100+'%';e.querySelector('.optimum output').textContent=viz.number(q[i],3);});$('#normalizer').textContent='π*(y) = πref(y) e^(r(y)/β) / Z; Z ≈ '+viz.number(z,3);$('#reward').textContent=viz.number(reward,3);$('#kl').textContent=viz.number(kl,3)+' nat';$('#objective').textContent='J* = E[r] − β KL ≈ '+viz.number(reward,3)+' − '+viz.number(b,2)+' × '+viz.number(kl,3)+' ≈ '+viz.number(reward-b*kl,3)+' = β ln Z';}\n$('#beta').addEventListener('input',draw);draw();\n","audio":false,"strings":{"control":"KLペナルティ重み β","eyebrow":"報酬が確率をどのように再配分するか","heading":"KL制約下で、高報酬の回答はどの程度の確率を得るのか?","intro":"1つのプロンプトを固定し、A、B、Cの3つの回答のみを考慮する。参考確率は 0.6、0.3、0.1、報酬は 0、1、2;棒の幅は常に 0–1 の確率スケールで描画される。","note":"β が小さいほど、報酬差が拡大され、確率は C に集中する;β が大きいほど、分布は参考により近づく。ここでは有限回答空間の分布最適値を厳密に求解しており、KLは自然対数を使用している。これはPPOの訓練プロセスではなく、有限データ上のDPOがこの分布に到達することを保証するものでもない。","optimal":"最適分布","reference":"参考分布","reward":"期待報酬 E[r]"}}
最適性を直感に頼って信じる必要はない。log π ∗ = log π ref + r / β − log Z を代入し、整理すると
J ( π ) = β log Z − β D KL ( π ∥ π ∗ ) .
が得られる。第1項は選択される π に依存せず、第2項は非正(β > 0 かつ D K L ≥ 0 なので − β D K L ≤ 0 )であるため、π = π ∗ が最大値を達成する。ここでは KL を nat(自然対数単位)で測る。対数の底を変更する場合は、ペナルティ係数もそれに応じて調整する必要がある。分布についての閉じた形の解は、ニューラルネットワークのパラメータについての閉じた形の解ではない 。実際の訓練が必ずこの分布へ収束するわけでもない。
DPOはこの関係をどのように利用するのか?
上記の式を報酬について解き直すと、
r ( x , y ) = β log π ref ( y ∣ x ) π ∗ ( y ∣ x ) + β log Z ( x )
と書ける。
Bradley–Terry 選好モデルは2つの回答の報酬差のみに依存するため、同じプロンプト下での log Z ( x ) は相殺される。戦略を学習対象の π θ に置き換え、1組の選好データ ( y w , y l ) に対するDPO損失は
− log σ ( β [ log π ref ( y w ∣ x ) π θ ( y w ∣ x ) − log π ref ( y l ∣ x ) π θ ( y l ∣ x ) ] )
となる。
これは2つの回答の参考モデルに対する対数確率の向上 を比較している。標準的なDPOは、選好データを用いてこの目標を直接フィッティングし、個別の明示的な報酬モデルやPPOのステップを省略する。導出はKL正則化目標と関連しているが、有限データ、モデルのパラメータ化、最適化誤差は結果に影響を与える;これをもってDPOとPPOが同じ戦略を得ると認定することはできず、またDPOの β を最終的なKLの硬い予算として直接読み取ることもできない。
スケーリング則:圧縮の視点は有用だが、指数は経験則である
Chinchilla は、そのモデル族、データ、およびフィッティングの範囲内において、計算最適化のためのパラメータ数と訓練トークン数は、計算能力に対して概ね同期して増加すべきであることを発見した。原文でよく使われる近似は N ∝ C 0.5 、D ∝ C 0.5 であり、すべてのモデルや訓練条件に対して成り立つ定数ではない。
評価設定を固定した後、交差エントロピーの低下は理想的な平均符号長の低下として解釈できる。この視点は「計算資源をどのように配分するか」を「テスト交差エントロピーをいかに低く抑えるか」に変換するが、ソース符号化定理自体からはスケーリング則の形状や指数を導き出すことはできない。有限コンテキストにおける条件エントロピー、無限履歴におけるエントロピー率、経験的フィッティングにおける定数項は、直接交換できる量ではない。アーキテクチャ、最適化、データ品質はそれぞれ別々に研究する必要がある;稠密モデルとMoE を参照。
温度:ロジットを割るだけで、なぜランダム性が変わるのか?
固定された有限のロジット z i と T > 0 に対して、
q T ( i ) = ∑ j e z j / T e z i / T , q T ( j ) q T ( i ) = exp ( T z i − z j )
である。
2番目の式は1番目を説明している:温度は対数確率差のギャップ を縮小する。温度を上げると候補確率は近づき、温度を下げると既存のギャップが拡大する。固定されたロジットで、他の切り捨てを適用しない場合、分布のエントロピーは温度に対して単調非減少である;これはサンプリング分布の不確実性を示しており、知識量が増加したことを意味するものではない。
図を準備しています 再読み込み
温度が変化させるのは確率比であり、知識量ではない 4つのロジットを固定し、温度は exp((zA−zB)/T) によって確率比を変化させる。唯一の最大値と並んだ最大値を比較し、同時に分布エントロピーとBが観測された際の損失を観察する。
{"id":"llm-temperature","title":"温度が変化させるのは確率比であり、知識量ではない","summary":"4つのロジットを固定し、温度は exp((zA−zB)/T) によって確率比を変化させる。唯一の最大値と並んだ最大値を比較し、同時に分布エントロピーとBが観測された際の損失を観察する。","height":950,"html":"<p class=\"eyebrow\" data-i18n=\"eyebrow\"></p><h2 data-i18n=\"heading\"></h2><p class=\"intro\" data-i18n=\"intro\"></p>\n<div class=\"presets\" role=\"group\" data-i18n-label=\"examples\"><button data-mode=\"unique\" data-i18n=\"unique\"></button><button data-mode=\"tied\" data-i18n=\"tied\"></button></div>\n<label class=\"control\" for=\"temperature\"><span data-i18n=\"control\"></span><output id=\"temperature-value\"></output></label><input id=\"temperature\" type=\"range\" min=\"10\" max=\"400\" value=\"100\">\n<div class=\"rows\" id=\"temperature-rows\"></div><div class=\"formula\" id=\"odds\"></div><div class=\"metric-pair\"><div><span data-i18n=\"entropy\"></span><strong id=\"entropy\"></strong></div><div><span data-i18n=\"loss\"></span><strong id=\"token-loss\"></strong></div></div><div class=\"band\" role=\"img\" data-i18n-label=\"strip\"><div id=\"entropy-fill\"></div></div><div class=\"scale\"><span>0 bit</span><span>log₂ 4 = 2 bit</span></div><p class=\"note\" data-i18n=\"note\"></p>\n","css":".intro { margin:8px 0 18px; color:var(--muted); font-size:14px; }\n.control { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-top:18px; }\n.control output { min-width:4em; flex-shrink:0; text-align:center; background:var(--accent-soft); color:var(--accent); padding:2px 8px; border-radius:6px; font-weight:600; }\n.formula { margin-top:18px; padding:14px 0; border-block:1px solid var(--rule); font-size:16px; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }\n.copy-stack { display:grid; margin-top:14px; color:var(--muted); font-size:14px; }\n.copy-stack > * { grid-area:1/1; }\n.copy-stack .reserve { visibility:hidden; }\n.note { margin-top:14px; color:var(--muted); font-size:12px; }\n.metric-pair { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-top:18px; }\n.metric-pair > div { min-width:0; }\n.metric-pair span { display:block; font-size:12px; color:var(--muted); }\n.metric-pair strong { display:block; font-size:24px; font-weight:500; font-variant-numeric:tabular-nums; }\n.scale { display:flex; justify-content:space-between; color:var(--muted); font-size:12px; font-variant-numeric:tabular-nums; }\n@media(max-width:480px) { .metric-pair strong { font-size:21px; } }\n.presets { display:flex; }\n.plot { position:relative; margin-top:18px; height:190px; border-left:1px solid var(--rule); border-bottom:1px solid var(--muted); }\n.plot svg { width:100%; height:100%; overflow:hidden; }\n.plot .curve { fill:none; stroke:var(--accent); stroke-width:2.5; vector-effect:non-scaling-stroke; }\n.plot .curve.secondary { stroke:var(--second); stroke-dasharray:5 4; }\n.scale { position:relative; }.scale .middle { position:absolute; left:50%; transform:translateX(-50%); }\n.formula { font-size:14px; }.formula div+div { margin-top:6px; }\n@media(max-width:480px) { .plot { height:170px; } }\n.plot .curve { transition:d .28s cubic-bezier(.22,1,.36,1); }\n.band { display:flex; height:28px; border-radius:5px; overflow:hidden; background:var(--surface); margin-top:10px; }\n.band > div { background:var(--accent); transition:width .28s ease; }\n.band > .gold { background:var(--second); }\n.legend { display:flex; flex-wrap:wrap; gap:6px 18px; margin-top:10px; font-size:12px; color:var(--muted); }\n.legend .blue::before,.legend .gold::before { content:''; display:inline-block; width:9px; height:9px; border-radius:2px; margin-right:6px; background:var(--accent); }\n.legend .gold::before { background:var(--second); }\n.rows { margin-top:18px; display:grid; gap:12px; }\n.row { display:grid; grid-template-columns:32px 1fr 60px; align-items:center; gap:10px; font-size:13px; }\n.row > div { min-width:0; }.row output { text-align:right; font-variant-numeric:tabular-nums; }\n.track { height:14px; background:var(--surface); border-radius:3px; overflow:hidden; }\n.fill { height:100%; width:0; background:var(--accent); transition:width .28s ease; }\n.presets { flex-wrap:wrap; gap:4px; }.presets button { min-width:0; }\n.metric-pair strong { overflow-wrap:anywhere; }\n.rows .row { grid-template-columns:76px 1fr 55px; }.row:nth-child(2) .fill { background:var(--second); }.row > span { font-size:12px; }.row strong { font-size:14px; margin-right:6px; }\n","js":"const $=s=>document.querySelector(s);let mode='unique';for(let i=0;i<4;i++)$('#temperature-rows').insertAdjacentHTML('beforeend','<div class=\"row\"><span><strong>'+String.fromCharCode(65+i)+'</strong><small></small></span><div class=\"track\"><div class=\"fill\"></div></div><output></output></div>');\nfunction draw(){const t=+$('#temperature').value/100,z=mode==='unique'?[3,2,0,-1]:[3,3,0,-1],w=z.map(v=>Math.exp((v-3)/t)),sum=w.reduce((a,b)=>a+b),p=w.map(v=>v/sum),h=viz.entropy(p);$('#temperature-value').textContent=viz.number(t,2);document.querySelectorAll('.row').forEach((e,i)=>{e.querySelector('small').textContent='z='+z[i];e.querySelector('.fill').style.width=p[i]*100+'%';e.querySelector('output').textContent=viz.number(p[i],3);});$('#entropy').textContent=viz.number(h,3)+' bit';$('#token-loss').textContent=viz.number(-Math.log2(p[1]),3)+' bit';$('#entropy-fill').style.width=h/2*100+'%';$('#odds').textContent='qT(A) / qT(B) = exp((zA − zB) / T) = exp('+ (z[0]-z[1])+' / '+viz.number(t,2)+') ≈ '+viz.number(p[0]/p[1],3);document.querySelectorAll('[data-mode]').forEach(e=>e.setAttribute('aria-pressed',String(mode===e.dataset.mode)));}\n$('#temperature').addEventListener('input',draw);document.querySelectorAll('[data-mode]').forEach(e=>e.addEventListener('click',()=>{mode=e.dataset.mode;draw();}));draw();\n","audio":false,"strings":{"control":"サンプリング温度 T","entropy":"分布全体のエントロピー H(qT)","examples":"logitの例","eyebrow":"logit差から確率比へ","heading":"温度が変化させるのは確率比であり、知識量ではない","intro":"青/金の棒は4つの候補の確率を示し、金色のBは固定された観測トークンである。温度は分布全体を変化させる;分布エントロピーとBの損失は2つの異なる量である。","loss":"Bが観測された場合:−log₂ qT(B)","note":"確率棒は固定 0–1、エントロピー棒は固定 0–2 bit。最高値が唯一の場合のみ、T→0 のエントロピーは 0 に収束する;A、Bが並んだ場合は 1 bit に収束する。T→∞ の場合、4項目は一様に近づき、エントロピーは 2 bit に収束する。ここでは top-k/top-p の切り捨ては行われておらず;B の損失は確率再割り当てのデモに過ぎず、モデル全体のPPLではない。","strip":"分布エントロピーが4候補の最大エントロピー 2 bit に占める割合。","tied":"並んだ最高値","unique":"唯一の最高値"}}
厳密な理由を見たい場合は、自然対数を用いて H ( q T ) = log Z T − E q T [ z ] / T と書く。微分すると2つの項の一部が相殺され、残りは
d T d H e ( q T ) = T 3 Var q T ( z ) ≥ 0
となる。
唯一の最大ロジットは T → 0 で確率を独占し、エントロピーは 0 に収束する;m 項目が最大で並んでいる場合、極限はそれらの間で一様に分布し、エントロピーは log 2 m となる。T → ∞ の場合、有限の語彙は一様に近づく。実際の生成では、top-k、top-p などのサンプリング操作 が追加されるため、最終分布を分析する必要があり、切り捨てのない曲線をそのまま適用することはできない。
混同しやすいいくつかの量を分離する
量 答える質問 直接導出できないもの
テストNLL / PPL 実際のデータにどの程度の確率が割り当てられたか? 事実の正しさ、推論の信頼性、回答の有用性
サンプリングエントロピー H ( q T ) 現在の候補はどれくらい不確実か? コンテンツの創造性、モデルの知識の増加
戦略と参考のKL 確率分布はどれくらい逸脱したか? 報酬の悪用がないこと、すべての選好が満たされること
理想的な符号長 共有モデル下でテキストを符号化するために必要なbit数は? 圧縮率が理解能力の完全なスコアであること
温度は重みの中の知識を変更せず、低いPPLが自動的に幻覚を消すわけでもありません;より小さなKLが必ずしもより良いアライメントを意味するわけではありません。情報理論はこれらの問題に明確な測定言語を提供しますが、事実性、推論、人間の選好にはそれぞれ対応する評価が必要です。
参考文献
キーワード:パープレキシティ、幾何平均、交差エントロピー、NLL、RLHF、KL正則化、DPO、スケーリング則、温度、softmax