Files
maths-cs-ai-compendium-zh/images/contrastive_temperature.svg

87 lines
6.1 KiB
XML

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 650 250" width="650" height="250">
<!-- Title -->
<text x="325" y="22" text-anchor="middle" font-family="Arial, sans-serif" font-size="14" font-weight="bold" fill="#333">Effect of Temperature on Contrastive Softmax</text>
<!-- Divider -->
<line x1="325" y1="34" x2="325" y2="242" stroke="#ccc" stroke-width="1" stroke-dasharray="4,3"/>
<!-- ====== LEFT: Low Temperature ====== -->
<text x="162" y="48" text-anchor="middle" font-family="Arial, sans-serif" font-size="11" font-weight="bold" fill="#e74c3c">Low Temperature (τ → 0)</text>
<text x="162" y="62" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#666">Sharp / peaked distribution</text>
<!-- Left axes -->
<line x1="55" y1="200" x2="280" y2="200" stroke="#999" stroke-width="1"/>
<line x1="55" y1="200" x2="55" y2="75" stroke="#999" stroke-width="1"/>
<text x="167" y="220" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#999">Candidates</text>
<text x="42" y="140" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#999" transform="rotate(-90,42,140)">Softmax prob.</text>
<!-- Left bar chart — peaked at correct match -->
<!-- Bar 1 (low) -->
<rect x="72" y="190" width="28" height="10" rx="2" fill="#3498db" fill-opacity="0.4"/>
<!-- Bar 2 (low) -->
<rect x="112" y="188" width="28" height="12" rx="2" fill="#3498db" fill-opacity="0.4"/>
<!-- Bar 3 — correct match (very tall) -->
<rect x="152" y="82" width="28" height="118" rx="2" fill="#27ae60" fill-opacity="0.8"/>
<text x="166" y="78" text-anchor="middle" font-family="Arial, sans-serif" font-size="8" font-weight="bold" fill="#27ae60">correct</text>
<!-- Bar 4 (low) -->
<rect x="192" y="192" width="28" height="8" rx="2" fill="#3498db" fill-opacity="0.4"/>
<!-- Bar 5 (low) -->
<rect x="232" y="191" width="28" height="9" rx="2" fill="#3498db" fill-opacity="0.4"/>
<!-- Tick labels -->
<text x="86" y="212" text-anchor="middle" font-family="Arial, sans-serif" font-size="8" fill="#999">1</text>
<text x="126" y="212" text-anchor="middle" font-family="Arial, sans-serif" font-size="8" fill="#999">2</text>
<text x="166" y="212" text-anchor="middle" font-family="Arial, sans-serif" font-size="8" fill="#999">3</text>
<text x="206" y="212" text-anchor="middle" font-family="Arial, sans-serif" font-size="8" fill="#999">4</text>
<text x="246" y="212" text-anchor="middle" font-family="Arial, sans-serif" font-size="8" fill="#999">5</text>
<!-- Y-axis ticks left -->
<line x1="52" y1="200" x2="55" y2="200" stroke="#999" stroke-width="1"/>
<text x="48" y="203" text-anchor="end" font-family="Arial, sans-serif" font-size="8" fill="#999">0</text>
<line x1="52" y1="140" x2="55" y2="140" stroke="#999" stroke-width="1"/>
<text x="48" y="143" text-anchor="end" font-family="Arial, sans-serif" font-size="8" fill="#999">0.5</text>
<line x1="52" y1="80" x2="55" y2="80" stroke="#999" stroke-width="1"/>
<text x="48" y="83" text-anchor="end" font-family="Arial, sans-serif" font-size="8" fill="#999">1.0</text>
<!-- ====== RIGHT: High Temperature ====== -->
<text x="488" y="48" text-anchor="middle" font-family="Arial, sans-serif" font-size="11" font-weight="bold" fill="#3498db">High Temperature (τ → ∞)</text>
<text x="488" y="62" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#666">Uniform / flat distribution</text>
<!-- Right axes -->
<line x1="380" y1="200" x2="605" y2="200" stroke="#999" stroke-width="1"/>
<line x1="380" y1="200" x2="380" y2="75" stroke="#999" stroke-width="1"/>
<text x="492" y="220" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#999">Candidates</text>
<text x="367" y="140" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#999" transform="rotate(-90,367,140)">Softmax prob.</text>
<!-- Right bar chart — nearly uniform -->
<rect x="397" y="175" width="28" height="25" rx="2" fill="#3498db" fill-opacity="0.5"/>
<rect x="437" y="173" width="28" height="27" rx="2" fill="#3498db" fill-opacity="0.5"/>
<!-- correct match — only slightly taller -->
<rect x="477" y="170" width="28" height="30" rx="2" fill="#f39c12" fill-opacity="0.6"/>
<text x="491" y="166" text-anchor="middle" font-family="Arial, sans-serif" font-size="8" fill="#f39c12">correct</text>
<rect x="517" y="174" width="28" height="26" rx="2" fill="#3498db" fill-opacity="0.5"/>
<rect x="557" y="176" width="28" height="24" rx="2" fill="#3498db" fill-opacity="0.5"/>
<!-- Tick labels -->
<text x="411" y="212" text-anchor="middle" font-family="Arial, sans-serif" font-size="8" fill="#999">1</text>
<text x="451" y="212" text-anchor="middle" font-family="Arial, sans-serif" font-size="8" fill="#999">2</text>
<text x="491" y="212" text-anchor="middle" font-family="Arial, sans-serif" font-size="8" fill="#999">3</text>
<text x="531" y="212" text-anchor="middle" font-family="Arial, sans-serif" font-size="8" fill="#999">4</text>
<text x="571" y="212" text-anchor="middle" font-family="Arial, sans-serif" font-size="8" fill="#999">5</text>
<!-- Y-axis ticks right -->
<line x1="377" y1="200" x2="380" y2="200" stroke="#999" stroke-width="1"/>
<text x="373" y="203" text-anchor="end" font-family="Arial, sans-serif" font-size="8" fill="#999">0</text>
<line x1="377" y1="140" x2="380" y2="140" stroke="#999" stroke-width="1"/>
<text x="373" y="143" text-anchor="end" font-family="Arial, sans-serif" font-size="8" fill="#999">0.5</text>
<line x1="377" y1="80" x2="380" y2="80" stroke="#999" stroke-width="1"/>
<text x="373" y="83" text-anchor="end" font-family="Arial, sans-serif" font-size="8" fill="#999">1.0</text>
<!-- Uniform line reference -->
<line x1="390" y1="176" x2="595" y2="176" stroke="#ccc" stroke-width="0.8" stroke-dasharray="3,3"/>
<text x="600" y="174" text-anchor="start" font-family="Arial, sans-serif" font-size="7" fill="#ccc">1/N</text>
<!-- Bottom note -->
<text x="325" y="244" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#666">softmax(sᵢ / τ) — lower τ sharpens the distribution, higher τ flattens it</text>
</svg>