<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Transformer on 老张开工了</title>
    <link>/transformer/</link>
    <description>Recent content in Transformer on 老张开工了</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    <lastBuildDate>Wed, 03 Jun 2026 00:00:00 +0000</lastBuildDate>
    <atom:link href="/transformer/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>大语言模型原理与实践</title>
      <link>/posts/2026/06/llm-fundamentals/</link>
      <pubDate>Wed, 03 Jun 2026 00:00:00 +0000</pubDate>
      <guid>/posts/2026/06/llm-fundamentals/</guid>
      <description>你不需要在 2026 年亲手写一个 Transformer，但你需要知道它&amp;quot;葫芦里卖的什么药&amp;quot;。AI 协作之所以常常翻车，根源往往是把模型当成&amp;quot;懂你心思的人&amp;quot;——而它实际只是在玩一个非常精彩的语言接龙游戏。本章把 LLM 的几个底层概念讲清楚，让你以后每一句 prompt 都有底。&#xA;2.1 LLM 在干什么 一句话：给定上文，预测下一个 token。&#xA;Input: &amp;#34;今天天气&amp;#34; Model: → 预测概率分布 {&amp;#34;真&amp;#34;:0.21, &amp;#34;不&amp;#34;:0.18, &amp;#34;挺&amp;#34;:0.10, ...} Output: 选一个 → &amp;#34;真&amp;#34; Loop: &amp;#34;今天天气真&amp;#34; → 再预测下一个 token ... 仅此而已。模型不做&amp;quot;思考&amp;quot;，它输出一段看起来像思考的字符序列。理解这一点非常重要——所有的&amp;quot;魔法&amp;quot;都来自这个朴素的循环。&#xA;2.2 Transformer 与注意力 Transformer 是当前主流 LLM 的骨架，核心是 self-attention：让序列中每个 token 与其他所有 token 算一组相似度权重，再用权重做加权平均。&#xA;# 自注意力的最简示意（省略缩放、归一化、多头等细节） import torch import torch.nn.functional as F def attention(Q, K, V): # Q, K, V: (seq_len, d_k) scores = Q @ K.T # (seq_len, seq_len) 谁和谁相关 weights = F.</description>
    </item>
  </channel>
</rss>
