大模型(Large Model)解析:从数据类型、模型架构到任务选型

摘要:本文先介绍大模型的基本概念与代表性模型(GPT、BERT、BART、T5、LLaMA、AlphaFold 等),再从三个维度梳理其常见分类方式------按处理的数据类型(语言、视觉、多模态、基础科学)、按模型架构(Transformer 结构中的仅编码器/仅解码器/编码器---解码器,以及参数激活方式中的稠密与混合专家),以及按功能与领域(通用与领域模型、专用功能模型),并给出各类别的典型任务与代表模型。文中还提供一张分类速查表、一张按任务场景的选型对照表,以及一张带颜色区分的选型决策流程图,帮助读者从「认识大模型」走到「按任务选型」,快速建立大模型类型的整体认知框架。

目录

一、什么是大模型

大模型(Large Model)通常指参数量达到数十亿乃至数千亿级别、在海量数据上预训练得到的深度神经网络模型。它依托 Transformer 架构与大规模自监督学习,把语言、图像、语音等原始数据压缩为可迁移的通用表示,再通过微调或提示即可适配下游任务。相比传统模型,大模型的核心特征是参数规模大、训练数据广、通用能力强,并常伴随涌现能力(如上下文学习、指令遵循)。

代表性的大模型及其英文简称如下:

模型 英文简称 / 全称 主要特点
GPT 系列 GPT(Generative Pre-trained Transformer) 仅解码器架构,通用生成式大语言模型代表
BERT BERT(Bidirectional Encoder Representations from Transformers) 仅编码器架构,擅长理解类任务
BART BART(Bidirectional and Auto-Regressive Transformers) 编码器---解码器架构,常用于翻译与摘要
T5 T5(Text-to-Text Transfer Transformer) 统一「文本到文本」范式的编码器---解码器模型
LLaMA LLaMA(Large Language Model Meta AI) 开源仅解码器大语言模型系列
PaLM PaLM(Pathways Language Model) 大规模仅解码器语言模型
AlphaFold AlphaFold 基础科学大模型,用于蛋白质结构预测
Stable Diffusion SD(Stable Diffusion) 扩散模型,用于文生图
Vision Transformer ViT(Vision Transformer) 将 Transformer 用于图像分类的视觉模型

二、大模型分类速查表及选型决策

分类维度 类别 典型任务 代表模型
按处理的数据类型 大语言模型 文本生成、翻译、问答、内容创作 GPT 系列、Claude
按处理的数据类型 视觉大模型 图像分类、目标检测、图像生成 Vision Transformer 类模型
按处理的数据类型 多模态大模型 看图说话、图文问答、文生视频 GPT-4o、Gemini
按处理的数据类型 基础科学大模型 蛋白质结构预测、化学反应模拟 AlphaFold
按模型架构(Transformer 结构) 仅编码器架构 文本分类、信息提取等理解任务 BERT
按模型架构(Transformer 结构) 仅解码器架构 聊天、写代码等生成任务 GPT、千问
按模型架构(Transformer 结构) 编码器---解码器架构 机器翻译、文本摘要 BART
按模型架构(参数激活方式) 稠密架构 通用任务,全参数参与计算 多数常规大模型
按模型架构(参数激活方式) 混合专家架构 大容量下的高效推理 DeepSeek、千问部分模型
按功能与领域 通用大模型 面向广泛任务的通用能力 GPT-4
按功能与领域 领域大模型 法律、医疗、金融、天文等专业场景 各行业微调模型
按功能与领域 专用功能模型 代码生成、图像生成 Codex、Stable Diffusion

大模型的类型可以从多个维度来划分。最常见的分类方式包括按处理的数据类型 、按模型架构 ,以及按功能与领域。

如何根据任务选型

了解了分类维度之后,更实际的问题是:面对一个具体任务,该选哪类架构和模型?下表按常见任务场景给出推荐与一句话理由,可作为选型的起点。

任务场景 推荐架构 推荐模型类型 选择理由
文本分类 仅编码器 大语言模型(理解型) 只需双向理解整句语义并输出标签,无需逐字生成,编码器加分类头最经济高效。
机器翻译 编码器---解码器 大语言模型(序列到序列) 输入与输出是两段不同序列,编码器理解源文、解码器逐词生成译文最匹配。
开放域对话 仅解码器 通用大模型 对话本质是自回归续写,仅解码器架构天然适合多轮自由生成。
图文问答 多模态(编码器 + 解码器) 多模态大模型 需先编码图像再以文本生成答案,跨模态融合能力是关键。
代码生成 仅解码器 专用功能模型(代码模型) 代码是严格从左到右的序列生成任务,且需在代码语料上专门训练。
蛋白质结构预测 专用编码器式结构 基础科学大模型 输入氨基酸序列、输出三维结构,属于结构化预测而非自由文本生成。

上面的表格可以进一步浓缩成一张决策流程图:从任务输入出发,先判断是「理解」还是「生成」,再判断输入输出是否为两段不同序列、是否涉及图像等非文本模态,最终落到对应的架构与模型类型。
#mermaid-svg-TXXcy0ETIck3M4K8{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-TXXcy0ETIck3M4K8 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-TXXcy0ETIck3M4K8 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-TXXcy0ETIck3M4K8 .error-icon{fill:#552222;}#mermaid-svg-TXXcy0ETIck3M4K8 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-TXXcy0ETIck3M4K8 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-TXXcy0ETIck3M4K8 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-TXXcy0ETIck3M4K8 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-TXXcy0ETIck3M4K8 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-TXXcy0ETIck3M4K8 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-TXXcy0ETIck3M4K8 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-TXXcy0ETIck3M4K8 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-TXXcy0ETIck3M4K8 .marker.cross{stroke:#333333;}#mermaid-svg-TXXcy0ETIck3M4K8 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-TXXcy0ETIck3M4K8 p{margin:0;}#mermaid-svg-TXXcy0ETIck3M4K8 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-TXXcy0ETIck3M4K8 .cluster-label text{fill:#333;}#mermaid-svg-TXXcy0ETIck3M4K8 .cluster-label span{color:#333;}#mermaid-svg-TXXcy0ETIck3M4K8 .cluster-label span p{background-color:transparent;}#mermaid-svg-TXXcy0ETIck3M4K8 .label text,#mermaid-svg-TXXcy0ETIck3M4K8 span{fill:#333;color:#333;}#mermaid-svg-TXXcy0ETIck3M4K8 .node rect,#mermaid-svg-TXXcy0ETIck3M4K8 .node circle,#mermaid-svg-TXXcy0ETIck3M4K8 .node ellipse,#mermaid-svg-TXXcy0ETIck3M4K8 .node polygon,#mermaid-svg-TXXcy0ETIck3M4K8 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-TXXcy0ETIck3M4K8 .rough-node .label text,#mermaid-svg-TXXcy0ETIck3M4K8 .node .label text,#mermaid-svg-TXXcy0ETIck3M4K8 .image-shape .label,#mermaid-svg-TXXcy0ETIck3M4K8 .icon-shape .label{text-anchor:middle;}#mermaid-svg-TXXcy0ETIck3M4K8 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-TXXcy0ETIck3M4K8 .rough-node .label,#mermaid-svg-TXXcy0ETIck3M4K8 .node .label,#mermaid-svg-TXXcy0ETIck3M4K8 .image-shape .label,#mermaid-svg-TXXcy0ETIck3M4K8 .icon-shape .label{text-align:center;}#mermaid-svg-TXXcy0ETIck3M4K8 .node.clickable{cursor:pointer;}#mermaid-svg-TXXcy0ETIck3M4K8 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-TXXcy0ETIck3M4K8 .arrowheadPath{fill:#333333;}#mermaid-svg-TXXcy0ETIck3M4K8 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-TXXcy0ETIck3M4K8 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-TXXcy0ETIck3M4K8 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-TXXcy0ETIck3M4K8 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-TXXcy0ETIck3M4K8 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-TXXcy0ETIck3M4K8 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-TXXcy0ETIck3M4K8 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-TXXcy0ETIck3M4K8 .cluster text{fill:#333;}#mermaid-svg-TXXcy0ETIck3M4K8 .cluster span{color:#333;}#mermaid-svg-TXXcy0ETIck3M4K8 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-TXXcy0ETIck3M4K8 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-TXXcy0ETIck3M4K8 rect.text{fill:none;stroke-width:0;}#mermaid-svg-TXXcy0ETIck3M4K8 .icon-shape,#mermaid-svg-TXXcy0ETIck3M4K8 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-TXXcy0ETIck3M4K8 .icon-shape p,#mermaid-svg-TXXcy0ETIck3M4K8 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-TXXcy0ETIck3M4K8 .icon-shape .label rect,#mermaid-svg-TXXcy0ETIck3M4K8 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-TXXcy0ETIck3M4K8 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-TXXcy0ETIck3M4K8 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-TXXcy0ETIck3M4K8 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}#mermaid-svg-TXXcy0ETIck3M4K8 .start>*{fill:#E3F2FD!important;stroke:#1E88E5!important;stroke-width:2px!important;color:#0D47A1!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .start span{fill:#E3F2FD!important;stroke:#1E88E5!important;stroke-width:2px!important;color:#0D47A1!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .start tspan{fill:#0D47A1!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .decision>*{fill:#FFF3E0!important;stroke:#EF6C00!important;stroke-width:2px!important;color:#E65100!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .decision span{fill:#FFF3E0!important;stroke:#EF6C00!important;stroke-width:2px!important;color:#E65100!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .decision tspan{fill:#E65100!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .encoder>*{fill:#C8E6C9!important;stroke:#2E7D32!important;stroke-width:2px!important;color:#1B5E20!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .encoder span{fill:#C8E6C9!important;stroke:#2E7D32!important;stroke-width:2px!important;color:#1B5E20!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .encoder tspan{fill:#1B5E20!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .multimodal>*{fill:#F3E5F5!important;stroke:#8E24AA!important;stroke-width:2px!important;color:#4A148C!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .multimodal span{fill:#F3E5F5!important;stroke:#8E24AA!important;stroke-width:2px!important;color:#4A148C!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .multimodal tspan{fill:#4A148C!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .seq2seq>*{fill:#E0F7FA!important;stroke:#00838F!important;stroke-width:2px!important;color:#006064!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .seq2seq span{fill:#E0F7FA!important;stroke:#00838F!important;stroke-width:2px!important;color:#006064!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .seq2seq tspan{fill:#006064!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .decoder>*{fill:#FFE0B2!important;stroke:#F57C00!important;stroke-width:2px!important;color:#E65100!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .decoder span{fill:#FFE0B2!important;stroke:#F57C00!important;stroke-width:2px!important;color:#E65100!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .decoder tspan{fill:#E65100!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .special>*{fill:#FCE4EC!important;stroke:#C2185B!important;stroke-width:2px!important;color:#880E4F!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .special span{fill:#FCE4EC!important;stroke:#C2185B!important;stroke-width:2px!important;color:#880E4F!important;}#mermaid-svg-TXXcy0ETIck3M4K8 .special tspan{fill:#880E4F!important;} 理解 / 打标签
生成 / 续写
否,纯文本
是,含图像等
是,如翻译 / 摘要
否,如对话 / 代码
否,通用场景
是,如代码 / 科学
任务输入
主要目标是理解还是生成
是否需要跨模态输入
输入与输出是否为两段不同序列
仅编码器架构

大语言模型(理解型)
多模态架构

多模态大模型
编码器---解码器架构

序列到序列模型
是否面向特定专业领域
仅解码器架构

通用大模型
仅解码器或专用结构

专用功能 / 基础科学大模型

图中四类决策节点统一用橙色系,五个结果节点则按架构类型区分颜色:仅编码器为绿色、多模态为紫色、编码器---解码器为青色、仅解码器为橙色、专用/基础科学为玫红色,便于一眼对应到上表的推荐结论。

三、按处理的数据类型划分

这是最直观的分类方式,反映了模型的核心能力边界:

  • 大语言模型:专门处理和理解自然语言文本,是当前应用最广的一类。典型任务包括文本生成、翻译、问答和内容创作。代表模型有 GPT 系列、Claude 等。
  • 视觉大模型:主要处理图像和视频数据,用于图像分类、目标检测、图像生成等。早期多基于 CNN,现在越来越多地采用 Vision Transformer 等架构。
  • 多模态大模型:能同时理解和处理文本、图像、音频等多种数据,实现跨模态的信息融合。例如,可以看图说话或根据文字生成视频。代表模型有 GPT-4o、Gemini 等。
  • 基础科学大模型:面向生物、化学、物理等科研领域,用于蛋白质结构预测(如 AlphaFold)、化学反应模拟等,辅助科学研究。

四、按模型架构划分

这关系到模型内部的"工作方式",主要分两个层面:

1. 按 Transformer 结构(信息处理方式)
  • 仅编码器架构:擅长"阅读理解",适合文本分类、信息提取等理解任务。代表模型是 BERT。
  • 仅解码器架构:擅长"写作接龙",根据上文预测下文,是当前生成式大语言模型(如 GPT、千问)的主流架构,用于聊天、写代码等。
  • 编码器---解码器架构:先理解输入,再生成输出,适合机器翻译、文本摘要等任务。代表模型有 BART。

以下是三种结构的数据流:

1.1 仅编码器架构的信息流向

输入文本先被切分为 token 并转为向量,再送入多层编码器。编码器的自注意力机制让每个 token 同时"看到"整句中的所有其他 token,因此每个位置都能获得融合了全局上下文的表示。信息在层内双向流动、逐层抽象,最终输出的是每个 token 的上下文向量(或汇聚后的句向量),而不是逐字生成的文本。这类结构没有自回归解码过程,输出通常接一个分类头或抽取头,直接给出标签、类别或实体片段。
#mermaid-svg-wnCsI1pu2EH4G9za{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-wnCsI1pu2EH4G9za .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-wnCsI1pu2EH4G9za .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-wnCsI1pu2EH4G9za .error-icon{fill:#552222;}#mermaid-svg-wnCsI1pu2EH4G9za .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-wnCsI1pu2EH4G9za .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-wnCsI1pu2EH4G9za .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-wnCsI1pu2EH4G9za .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-wnCsI1pu2EH4G9za .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-wnCsI1pu2EH4G9za .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-wnCsI1pu2EH4G9za .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-wnCsI1pu2EH4G9za .marker{fill:#333333;stroke:#333333;}#mermaid-svg-wnCsI1pu2EH4G9za .marker.cross{stroke:#333333;}#mermaid-svg-wnCsI1pu2EH4G9za svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-wnCsI1pu2EH4G9za p{margin:0;}#mermaid-svg-wnCsI1pu2EH4G9za .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-wnCsI1pu2EH4G9za .cluster-label text{fill:#333;}#mermaid-svg-wnCsI1pu2EH4G9za .cluster-label span{color:#333;}#mermaid-svg-wnCsI1pu2EH4G9za .cluster-label span p{background-color:transparent;}#mermaid-svg-wnCsI1pu2EH4G9za .label text,#mermaid-svg-wnCsI1pu2EH4G9za span{fill:#333;color:#333;}#mermaid-svg-wnCsI1pu2EH4G9za .node rect,#mermaid-svg-wnCsI1pu2EH4G9za .node circle,#mermaid-svg-wnCsI1pu2EH4G9za .node ellipse,#mermaid-svg-wnCsI1pu2EH4G9za .node polygon,#mermaid-svg-wnCsI1pu2EH4G9za .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-wnCsI1pu2EH4G9za .rough-node .label text,#mermaid-svg-wnCsI1pu2EH4G9za .node .label text,#mermaid-svg-wnCsI1pu2EH4G9za .image-shape .label,#mermaid-svg-wnCsI1pu2EH4G9za .icon-shape .label{text-anchor:middle;}#mermaid-svg-wnCsI1pu2EH4G9za .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-wnCsI1pu2EH4G9za .rough-node .label,#mermaid-svg-wnCsI1pu2EH4G9za .node .label,#mermaid-svg-wnCsI1pu2EH4G9za .image-shape .label,#mermaid-svg-wnCsI1pu2EH4G9za .icon-shape .label{text-align:center;}#mermaid-svg-wnCsI1pu2EH4G9za .node.clickable{cursor:pointer;}#mermaid-svg-wnCsI1pu2EH4G9za .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-wnCsI1pu2EH4G9za .arrowheadPath{fill:#333333;}#mermaid-svg-wnCsI1pu2EH4G9za .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-wnCsI1pu2EH4G9za .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-wnCsI1pu2EH4G9za .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-wnCsI1pu2EH4G9za .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-wnCsI1pu2EH4G9za .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-wnCsI1pu2EH4G9za .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-wnCsI1pu2EH4G9za .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-wnCsI1pu2EH4G9za .cluster text{fill:#333;}#mermaid-svg-wnCsI1pu2EH4G9za .cluster span{color:#333;}#mermaid-svg-wnCsI1pu2EH4G9za div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-wnCsI1pu2EH4G9za .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-wnCsI1pu2EH4G9za rect.text{fill:none;stroke-width:0;}#mermaid-svg-wnCsI1pu2EH4G9za .icon-shape,#mermaid-svg-wnCsI1pu2EH4G9za .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-wnCsI1pu2EH4G9za .icon-shape p,#mermaid-svg-wnCsI1pu2EH4G9za .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-wnCsI1pu2EH4G9za .icon-shape .label rect,#mermaid-svg-wnCsI1pu2EH4G9za .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-wnCsI1pu2EH4G9za .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-wnCsI1pu2EH4G9za .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-wnCsI1pu2EH4G9za :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}#mermaid-svg-wnCsI1pu2EH4G9za .input>*{fill:#E3F2FD!important;stroke:#1E88E5!important;stroke-width:2px!important;color:#0D47A1!important;}#mermaid-svg-wnCsI1pu2EH4G9za .input span{fill:#E3F2FD!important;stroke:#1E88E5!important;stroke-width:2px!important;color:#0D47A1!important;}#mermaid-svg-wnCsI1pu2EH4G9za .input tspan{fill:#0D47A1!important;}#mermaid-svg-wnCsI1pu2EH4G9za .process>*{fill:#BBDEFB!important;stroke:#1565C0!important;stroke-width:2px!important;color:#0D47A1!important;}#mermaid-svg-wnCsI1pu2EH4G9za .process span{fill:#BBDEFB!important;stroke:#1565C0!important;stroke-width:2px!important;color:#0D47A1!important;}#mermaid-svg-wnCsI1pu2EH4G9za .process tspan{fill:#0D47A1!important;}#mermaid-svg-wnCsI1pu2EH4G9za .output>*{fill:#90CAF9!important;stroke:#0D47A1!important;stroke-width:2px!important;color:#0D47A1!important;}#mermaid-svg-wnCsI1pu2EH4G9za .output span{fill:#90CAF9!important;stroke:#0D47A1!important;stroke-width:2px!important;color:#0D47A1!important;}#mermaid-svg-wnCsI1pu2EH4G9za .output tspan{fill:#0D47A1!important;} 输入文本
分词与向量化
编码器第 1 层

双向自注意力
编码器第 2..N 层

逐层抽象
上下文向量表示
任务头

分类 / 抽取
输出标签或实体

1.2 仅解码器架构的信息流向

输入(提示词)同样先转为向量,但进入的是带因果掩码的解码器层:每个 token 只能关注它之前的 token,信息严格从左到右单向流动。模型在每一步根据已生成的全部上文,预测下一个 token 的概率分布,采样出该 token 后再把它拼回输入,循环往复直到结束。因此输出是逐 token 自回归生成的序列,这也是聊天、写代码等生成式任务的主流形态。
#mermaid-svg-UfbhlVG5Q8Dubm9d{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-UfbhlVG5Q8Dubm9d .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-UfbhlVG5Q8Dubm9d .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-UfbhlVG5Q8Dubm9d .error-icon{fill:#552222;}#mermaid-svg-UfbhlVG5Q8Dubm9d .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-UfbhlVG5Q8Dubm9d .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-UfbhlVG5Q8Dubm9d .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-UfbhlVG5Q8Dubm9d .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-UfbhlVG5Q8Dubm9d .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-UfbhlVG5Q8Dubm9d .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-UfbhlVG5Q8Dubm9d .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-UfbhlVG5Q8Dubm9d .marker{fill:#333333;stroke:#333333;}#mermaid-svg-UfbhlVG5Q8Dubm9d .marker.cross{stroke:#333333;}#mermaid-svg-UfbhlVG5Q8Dubm9d svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-UfbhlVG5Q8Dubm9d p{margin:0;}#mermaid-svg-UfbhlVG5Q8Dubm9d .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-UfbhlVG5Q8Dubm9d .cluster-label text{fill:#333;}#mermaid-svg-UfbhlVG5Q8Dubm9d .cluster-label span{color:#333;}#mermaid-svg-UfbhlVG5Q8Dubm9d .cluster-label span p{background-color:transparent;}#mermaid-svg-UfbhlVG5Q8Dubm9d .label text,#mermaid-svg-UfbhlVG5Q8Dubm9d span{fill:#333;color:#333;}#mermaid-svg-UfbhlVG5Q8Dubm9d .node rect,#mermaid-svg-UfbhlVG5Q8Dubm9d .node circle,#mermaid-svg-UfbhlVG5Q8Dubm9d .node ellipse,#mermaid-svg-UfbhlVG5Q8Dubm9d .node polygon,#mermaid-svg-UfbhlVG5Q8Dubm9d .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-UfbhlVG5Q8Dubm9d .rough-node .label text,#mermaid-svg-UfbhlVG5Q8Dubm9d .node .label text,#mermaid-svg-UfbhlVG5Q8Dubm9d .image-shape .label,#mermaid-svg-UfbhlVG5Q8Dubm9d .icon-shape .label{text-anchor:middle;}#mermaid-svg-UfbhlVG5Q8Dubm9d .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-UfbhlVG5Q8Dubm9d .rough-node .label,#mermaid-svg-UfbhlVG5Q8Dubm9d .node .label,#mermaid-svg-UfbhlVG5Q8Dubm9d .image-shape .label,#mermaid-svg-UfbhlVG5Q8Dubm9d .icon-shape .label{text-align:center;}#mermaid-svg-UfbhlVG5Q8Dubm9d .node.clickable{cursor:pointer;}#mermaid-svg-UfbhlVG5Q8Dubm9d .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-UfbhlVG5Q8Dubm9d .arrowheadPath{fill:#333333;}#mermaid-svg-UfbhlVG5Q8Dubm9d .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-UfbhlVG5Q8Dubm9d .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-UfbhlVG5Q8Dubm9d .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-UfbhlVG5Q8Dubm9d .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-UfbhlVG5Q8Dubm9d .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-UfbhlVG5Q8Dubm9d .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-UfbhlVG5Q8Dubm9d .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-UfbhlVG5Q8Dubm9d .cluster text{fill:#333;}#mermaid-svg-UfbhlVG5Q8Dubm9d .cluster span{color:#333;}#mermaid-svg-UfbhlVG5Q8Dubm9d div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-UfbhlVG5Q8Dubm9d .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-UfbhlVG5Q8Dubm9d rect.text{fill:none;stroke-width:0;}#mermaid-svg-UfbhlVG5Q8Dubm9d .icon-shape,#mermaid-svg-UfbhlVG5Q8Dubm9d .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-UfbhlVG5Q8Dubm9d .icon-shape p,#mermaid-svg-UfbhlVG5Q8Dubm9d .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-UfbhlVG5Q8Dubm9d .icon-shape .label rect,#mermaid-svg-UfbhlVG5Q8Dubm9d .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-UfbhlVG5Q8Dubm9d .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-UfbhlVG5Q8Dubm9d .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-UfbhlVG5Q8Dubm9d :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}#mermaid-svg-UfbhlVG5Q8Dubm9d .input>*{fill:#FFF3E0!important;stroke:#EF6C00!important;stroke-width:2px!important;color:#E65100!important;}#mermaid-svg-UfbhlVG5Q8Dubm9d .input span{fill:#FFF3E0!important;stroke:#EF6C00!important;stroke-width:2px!important;color:#E65100!important;}#mermaid-svg-UfbhlVG5Q8Dubm9d .input tspan{fill:#E65100!important;}#mermaid-svg-UfbhlVG5Q8Dubm9d .process>*{fill:#FFE0B2!important;stroke:#F57C00!important;stroke-width:2px!important;color:#E65100!important;}#mermaid-svg-UfbhlVG5Q8Dubm9d .process span{fill:#FFE0B2!important;stroke:#F57C00!important;stroke-width:2px!important;color:#E65100!important;}#mermaid-svg-UfbhlVG5Q8Dubm9d .process tspan{fill:#E65100!important;}#mermaid-svg-UfbhlVG5Q8Dubm9d .decision>*{fill:#FFCC80!important;stroke:#E65100!important;stroke-width:2px!important;color:#BF360C!important;}#mermaid-svg-UfbhlVG5Q8Dubm9d .decision span{fill:#FFCC80!important;stroke:#E65100!important;stroke-width:2px!important;color:#BF360C!important;}#mermaid-svg-UfbhlVG5Q8Dubm9d .decision tspan{fill:#BF360C!important;}#mermaid-svg-UfbhlVG5Q8Dubm9d .output>*{fill:#FFB74D!important;stroke:#BF360C!important;stroke-width:2px!important;color:#BF360C!important;}#mermaid-svg-UfbhlVG5Q8Dubm9d .output span{fill:#FFB74D!important;stroke:#BF360C!important;stroke-width:2px!important;color:#BF360C!important;}#mermaid-svg-UfbhlVG5Q8Dubm9d .output tspan{fill:#BF360C!important;} 否
是
输入提示词
分词与向量化
解码器层

因果掩码自注意力
预测下一个 token 概率
是否结束
拼接新 token 回输入
输出完整序列

1.3 编码器---解码器架构的信息流向

输入序列先经过编码器做双向理解,得到一组包含全局上下文的表示;解码器在生成时通过交叉注意力不断查询这组编码结果,同时用因果掩码保证已生成部分不被未来 token 影响。信息流因此分为两段:编码阶段把输入压缩为语义表示,解码阶段以该表示为条件逐 token 生成输出,适合输入与输出是两段不同序列的任务,如机器翻译和文本摘要。
#mermaid-svg-LGj1qkoVpop9xaur{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-LGj1qkoVpop9xaur .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-LGj1qkoVpop9xaur .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-LGj1qkoVpop9xaur .error-icon{fill:#552222;}#mermaid-svg-LGj1qkoVpop9xaur .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-LGj1qkoVpop9xaur .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-LGj1qkoVpop9xaur .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-LGj1qkoVpop9xaur .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-LGj1qkoVpop9xaur .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-LGj1qkoVpop9xaur .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-LGj1qkoVpop9xaur .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-LGj1qkoVpop9xaur .marker{fill:#333333;stroke:#333333;}#mermaid-svg-LGj1qkoVpop9xaur .marker.cross{stroke:#333333;}#mermaid-svg-LGj1qkoVpop9xaur svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-LGj1qkoVpop9xaur p{margin:0;}#mermaid-svg-LGj1qkoVpop9xaur .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-LGj1qkoVpop9xaur .cluster-label text{fill:#333;}#mermaid-svg-LGj1qkoVpop9xaur .cluster-label span{color:#333;}#mermaid-svg-LGj1qkoVpop9xaur .cluster-label span p{background-color:transparent;}#mermaid-svg-LGj1qkoVpop9xaur .label text,#mermaid-svg-LGj1qkoVpop9xaur span{fill:#333;color:#333;}#mermaid-svg-LGj1qkoVpop9xaur .node rect,#mermaid-svg-LGj1qkoVpop9xaur .node circle,#mermaid-svg-LGj1qkoVpop9xaur .node ellipse,#mermaid-svg-LGj1qkoVpop9xaur .node polygon,#mermaid-svg-LGj1qkoVpop9xaur .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-LGj1qkoVpop9xaur .rough-node .label text,#mermaid-svg-LGj1qkoVpop9xaur .node .label text,#mermaid-svg-LGj1qkoVpop9xaur .image-shape .label,#mermaid-svg-LGj1qkoVpop9xaur .icon-shape .label{text-anchor:middle;}#mermaid-svg-LGj1qkoVpop9xaur .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-LGj1qkoVpop9xaur .rough-node .label,#mermaid-svg-LGj1qkoVpop9xaur .node .label,#mermaid-svg-LGj1qkoVpop9xaur .image-shape .label,#mermaid-svg-LGj1qkoVpop9xaur .icon-shape .label{text-align:center;}#mermaid-svg-LGj1qkoVpop9xaur .node.clickable{cursor:pointer;}#mermaid-svg-LGj1qkoVpop9xaur .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-LGj1qkoVpop9xaur .arrowheadPath{fill:#333333;}#mermaid-svg-LGj1qkoVpop9xaur .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-LGj1qkoVpop9xaur .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-LGj1qkoVpop9xaur .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-LGj1qkoVpop9xaur .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-LGj1qkoVpop9xaur .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-LGj1qkoVpop9xaur .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-LGj1qkoVpop9xaur .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-LGj1qkoVpop9xaur .cluster text{fill:#333;}#mermaid-svg-LGj1qkoVpop9xaur .cluster span{color:#333;}#mermaid-svg-LGj1qkoVpop9xaur div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-LGj1qkoVpop9xaur .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-LGj1qkoVpop9xaur rect.text{fill:none;stroke-width:0;}#mermaid-svg-LGj1qkoVpop9xaur .icon-shape,#mermaid-svg-LGj1qkoVpop9xaur .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-LGj1qkoVpop9xaur .icon-shape p,#mermaid-svg-LGj1qkoVpop9xaur .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-LGj1qkoVpop9xaur .icon-shape .label rect,#mermaid-svg-LGj1qkoVpop9xaur .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-LGj1qkoVpop9xaur .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-LGj1qkoVpop9xaur .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-LGj1qkoVpop9xaur :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}#mermaid-svg-LGj1qkoVpop9xaur .input>*{fill:#E8F5E9!important;stroke:#2E7D32!important;stroke-width:2px!important;color:#1B5E20!important;}#mermaid-svg-LGj1qkoVpop9xaur .input span{fill:#E8F5E9!important;stroke:#2E7D32!important;stroke-width:2px!important;color:#1B5E20!important;}#mermaid-svg-LGj1qkoVpop9xaur .input tspan{fill:#1B5E20!important;}#mermaid-svg-LGj1qkoVpop9xaur .encode>*{fill:#C8E6C9!important;stroke:#388E3C!important;stroke-width:2px!important;color:#1B5E20!important;}#mermaid-svg-LGj1qkoVpop9xaur .encode span{fill:#C8E6C9!important;stroke:#388E3C!important;stroke-width:2px!important;color:#1B5E20!important;}#mermaid-svg-LGj1qkoVpop9xaur .encode tspan{fill:#1B5E20!important;}#mermaid-svg-LGj1qkoVpop9xaur .decode>*{fill:#A5D6A7!important;stroke:#2E7D32!important;stroke-width:2px!important;color:#1B5E20!important;}#mermaid-svg-LGj1qkoVpop9xaur .decode span{fill:#A5D6A7!important;stroke:#2E7D32!important;stroke-width:2px!important;color:#1B5E20!important;}#mermaid-svg-LGj1qkoVpop9xaur .decode tspan{fill:#1B5E20!important;}#mermaid-svg-LGj1qkoVpop9xaur .decision>*{fill:#81C784!important;stroke:#1B5E20!important;stroke-width:2px!important;color:#1B5E20!important;}#mermaid-svg-LGj1qkoVpop9xaur .decision span{fill:#81C784!important;stroke:#1B5E20!important;stroke-width:2px!important;color:#1B5E20!important;}#mermaid-svg-LGj1qkoVpop9xaur .decision tspan{fill:#1B5E20!important;}#mermaid-svg-LGj1qkoVpop9xaur .output>*{fill:#66BB6A!important;stroke:#1B5E20!important;stroke-width:2px!important;color:#FFFFFF!important;}#mermaid-svg-LGj1qkoVpop9xaur .output span{fill:#66BB6A!important;stroke:#1B5E20!important;stroke-width:2px!important;color:#FFFFFF!important;}#mermaid-svg-LGj1qkoVpop9xaur .output tspan{fill:#FFFFFF!important;} 否
是
源输入序列
编码器

双向理解
源端语义表示
解码器

因果掩码 + 交叉注意力
已生成的目标 token
预测下一个目标 token
是否结束
输出目标序列

2. 按参数激活方式(计算调度方式)
  • 稠密架构:处理每个任务时,模型的大部分参数都会参与计算,计算路径直接但资源消耗较大。
  • 混合专家架构:模型内部有多个"专家"网络,每次根据任务只激活其中一部分,旨在保持大模型容量的同时提升推理效率。DeepSeek、千问的部分模型采用了此架构。

五、按功能与领域划分

  • 通用大模型 vs. 领域大模型:通用模型(如 GPT-4)面向广泛任务;领域模型则针对法律、医疗、金融、天文等特定行业数据进行微调,以提升专业场景的准确性。
  • 专用功能模型 :例如专注于编程语言的代码模型 (如 Codex),或用于生成图像的扩散模型(如 Stable Diffusion)。
相关推荐
船神丿男人35 分钟前
Redis 缓存击穿与雪崩实测:同键合并、TTL 错峰与迟到回填
数据库·redis·缓存
富贵儿9983 小时前
NL2SQL 实践手记 04:多表查询为什么更难——让模型找对表、连对关系
数据库·sql·ai·自然语言处理·langchain
Decay__3 小时前
PostgreSQL 索引与 SQL 优化 —— B-tree、GiST、GIN、BRIN、执行计划与索引设计实战
运维·数据库·sql·postgresql
fly-iot3 小时前
【摩尔线程S4000卡】执行Qwen3-14B-W8A8 量化、启动与接口性能测试报告,结果更慢了13 tok/s
人工智能·语言模型
Kainy3 小时前
生产服务器从机械盘迁移NVMe固态:旧盘不动、退路先行的六步实操全记录
运维·服务器
Risehuxyc4 小时前
MTU 和 MSS 详解
网络·智能路由器
ikgy4 小时前
JAVA EE:7.网络初识
网络
Dawson Zhu5 小时前
Agent记忆架构深度解析:为什么摘要会丢信息?如何构建“无损优先“的记忆系统
人工智能·语言模型·架构·aigc·agi
安枳杦5 小时前
用 OpenSpec 开启SDD(规范开发)
架构