<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="720" viewBox="0 0 1200 720">
  <rect x="0" y="0" width="1200" height="720" fill="#f6f9ff"/>
  <rect x="40" y="30" width="1120" height="660" rx="22" fill="#ffffff" stroke="#d8e2f1"/>
  <text x="600" y="78" text-anchor="middle" font-family="Arial, sans-serif" font-size="32" fill="#1f2d3d">Token 编解码流水线（Encoding / Decoding）</text>

  <rect x="90" y="120" width="1020" height="74" rx="14" fill="#edf3ff"/>
  <text x="600" y="165" text-anchor="middle" font-family="Arial, sans-serif" font-size="20" fill="#3a506b">核心问题：自然语言不是模型的直接输入，必须先转换为 Token ID 序列</text>

  <rect x="90" y="230" width="240" height="130" rx="16" fill="#ffd37f"/>
  <text x="210" y="285" text-anchor="middle" font-family="Arial, sans-serif" font-size="24" fill="#1f2d3d">输入文本</text>
  <text x="210" y="312" text-anchor="middle" font-family="Arial, sans-serif" font-size="17" fill="#3b4c62">中文 / English / Emoji</text>
  <text x="210" y="336" text-anchor="middle" font-family="Arial, sans-serif" font-size="17" fill="#3b4c62">上下文片段 + 指令</text>

  <rect x="360" y="230" width="240" height="130" rx="16" fill="#7be5cc"/>
  <text x="480" y="285" text-anchor="middle" font-family="Arial, sans-serif" font-size="24" fill="#1f2d3d">Tokenizer</text>
  <text x="480" y="312" text-anchor="middle" font-family="Arial, sans-serif" font-size="17" fill="#3b4c62">BPE / Unigram 等规则</text>
  <text x="480" y="336" text-anchor="middle" font-family="Arial, sans-serif" font-size="17" fill="#3b4c62">子词切分 + 词表映射</text>

  <rect x="630" y="230" width="240" height="130" rx="16" fill="#b8d1ff"/>
  <text x="750" y="285" text-anchor="middle" font-family="Arial, sans-serif" font-size="24" fill="#1f2d3d">Token IDs</text>
  <text x="750" y="312" text-anchor="middle" font-family="Arial, sans-serif" font-size="17" fill="#3b4c62">[1234, 98, 456...]</text>
  <text x="750" y="336" text-anchor="middle" font-family="Arial, sans-serif" font-size="17" fill="#3b4c62">可供矩阵计算</text>

  <rect x="900" y="230" width="210" height="130" rx="16" fill="#ffbecd"/>
  <text x="1005" y="285" text-anchor="middle" font-family="Arial, sans-serif" font-size="24" fill="#1f2d3d">模型输出</text>
  <text x="1005" y="312" text-anchor="middle" font-family="Arial, sans-serif" font-size="17" fill="#3b4c62">Next Token</text>
  <text x="1005" y="336" text-anchor="middle" font-family="Arial, sans-serif" font-size="17" fill="#3b4c62">采样策略控制</text>

  <line x1="330" y1="295" x2="360" y2="295" stroke="#8aa0bf" stroke-width="4"/>
  <line x1="600" y1="295" x2="630" y2="295" stroke="#8aa0bf" stroke-width="4"/>
  <line x1="870" y1="295" x2="900" y2="295" stroke="#8aa0bf" stroke-width="4"/>

  <rect x="90" y="410" width="495" height="220" rx="18" fill="#ffe9b3"/>
  <text x="338" y="462" text-anchor="middle" font-family="Arial, sans-serif" font-size="28" fill="#1f2d3d">Encoding 阶段</text>
  <text x="120" y="500" font-family="Arial, sans-serif" font-size="19" fill="#34475f">1) 文本规范化（空白、标点、Unicode）</text>
  <text x="120" y="532" font-family="Arial, sans-serif" font-size="19" fill="#34475f">2) 子词切分（Subword Segmentation）</text>
  <text x="120" y="564" font-family="Arial, sans-serif" font-size="19" fill="#34475f">3) 映射为 Token ID + Position 信息</text>
  <text x="120" y="596" font-family="Arial, sans-serif" font-size="19" fill="#34475f">4) 统计 Token 数用于成本估算</text>

  <rect x="615" y="410" width="495" height="220" rx="18" fill="#c9f3e8"/>
  <text x="862" y="462" text-anchor="middle" font-family="Arial, sans-serif" font-size="28" fill="#1f2d3d">Decoding 阶段</text>
  <text x="645" y="500" font-family="Arial, sans-serif" font-size="19" fill="#34475f">1) 根据概率分布采样 Next Token</text>
  <text x="645" y="532" font-family="Arial, sans-serif" font-size="19" fill="#34475f">2) Top-k / Top-p / Temperature 控制多样性</text>
  <text x="645" y="564" font-family="Arial, sans-serif" font-size="19" fill="#34475f">3) Token 序列还原为自然语言</text>
  <text x="645" y="596" font-family="Arial, sans-serif" font-size="19" fill="#34475f">4) 命中停止条件（Stop Sequence / Max Tokens）</text>
</svg>
