跳到内容
当前位置:首页>Excel>LLM学习笔记-Transformer 结构详解

LLM学习笔记-Transformer 结构详解

  • 2026-11-15 10:38:10
LLM学习笔记-Transformer 结构详解

本篇文章主要介绍

  • 什么是Transformer,它主要用于解决什么问题,以及依靠什么结构设计来解决这些问题
  • Transformer结构概览
  • Encoder结构
  • Decoder结构

什么是Transformer

Transformer首次提出于Attention is all you need这篇论文。Transformer提出之前,序列建模主要方法是RNN,LSTM等。诚然这些模型在序列建模领域取得了非常优异的效果,但是它们存在一个非常致命的问题。以RNN为例,它利用当前位置t的输入和上一个位置t-1的隐状态生成当前位置t的隐状态,这种顺序处理的特性阻碍了训练并行化。此外attention机制可以有效的对长序列进行建模,但是大部分情况下attention都是与RNN结构一起使用。为了实现计算并行化,同时保持长序列建模的能力,Transformer去掉了RNN结构,仅保留了Attention机制,这也就是论文名字的来源。


Transformer结构概览

在这一节,我们主要了解Transformer的整体结构。

从左至右依次为Embedding层,Encoder模块,Decoder模块,Linear Layer、Softmax。我们简单介绍一下流经过这些模组的数据:

  • 图中input是一系列文本或者token;
  • Intermediate result1是embedding后的输出,一般是词嵌入 + 位置嵌入,形状为二维[seq_length, embedding_dim]或三维[batch_size, seq_length, embedding_dim],embedding部分的作用是把人类可理解的文本型信息编码成模型可理解的数值型信息。由于Transformer本身对位置信息不敏感,因此需要在embedding阶段加入位置编码;
  • 给定Embedding结果,Encoder生成输入序列特征,Intermediate result2,其维度和embedding的输出一致。Encoder的作用是提取文本特征,编码语义信息;
  • 给定序列特征,Decoder生成输出序列中某个字符的特征,Intermediate result3,其维度和embedding的输出一致。Decoder的作用是利用Encoder编码的输入文本信息生成输出序列。在生成输出结果的每一步,Decoder会使用之前的生成结果作为额外的输入来生成下一个字符(即图中transformer下方输入给Dencoder部分的Output);
  • Intermediate result3会通过一个线性层(Linear Layer)转换为与词汇表大小相对应的维度。然后,通过softmax层将线性层的输出转换为概率分布,即每个词汇在当前位置上的概率;

Encoder结构

Encoder 是N个Encoder layer的堆叠,每个Encoder layer接受上一个Encoder layer的输出作为其输入,并产生一个输出作为下一个Encoder Layer的输入。直到最后一层Encoder layer,它输出的结果作为Encoder 的输出。采用这种结构,可以让后续Encoder layer基于前面的Encoder layer提取特征,挖掘出高级语义和语法信息。因此让我们放大Encoder layer,看看Encoder Layer的结构。

从图中可以看到,Encoder Layer 包含两个sublayers,分别是MultiHead Attention和Positionwise Feed Foward Networks,sublayer间使用残差连接。每个sublayer后跟了一个LayerNorm,因此每个sublayer的输出实际上是LayerNorm( x + sublayer(x)), x为sublayer的输入。

不同sublayer的作用

在上一篇文章中我已经介绍了attention机制的结构和作用,这里我再简单介绍一下。attention机制是用来捕获序列中不同token间的依赖关系,以学习序列的表征。multihead attention则是从不同表征空间(multi head)挖掘token之间的关系,其次单头注意力在计算不同位置间关联时用到了加权平均,这在一定程度上影响了特征计算的准确性,因此要用多头注意力来抵消这种影响。

Feed Forward结构为 Linear Layer + ReLU + Linear Layer, FFN(x) = max(0, xW1 + b1)W2 + b2。Feed Forward的作用如下:

  • 通过使用ReLU补充attention机制中缺乏的非线性变换,提升模型拟合复杂的分布的能力
  • 通过先升维度再降维的方式,在attention结果的基础上进一步学习到更丰富的特征
  • MultiHead Attention对于位置信息编码较弱,Feed Forward通过逐位置操作(point-wise),补充位置相关特征

sublayer间的数据流动

  • 输入给multihead attention的数据input_multiatt形状为[batch_size, seq_length, dim]。
  • input_multiatt与矩阵Wq,Wk,Wv,Wo计算得到 Q,K,V,O,形状为[batch_size, seq_length, dim]。
  • QKV通过矩阵变换实现多头机制,矩阵变换后的形状为[batch_size, head_num, seq_length, head_dim], 其中head_num * head_dim = dim
  • QKV进行attention计算,得到结果的形状为[batch_size, head_num, seq_length, head_dim],再经过矩阵变换(恢复)成 [batch_size, seq_length, dim]
  • 上一个步骤的结果与矩阵O进行计算,得到Multihead Attention阶段的输出,形状为 [batch_size, seq_length, dim]

具体实现

def self_attention(q, k, v, mask=None, dropout=None):    d_k = k.size(-1)    score = torch.matmul(q, k.transpose(-2, -1)) / math.sqrt(d_k)    if mask:        score = score.fill_mask(mask == 0, -1e9)    score = score.softmax(dim=-1)    if dropout:        score = dropout(score)    return torch.matmul(score, v)
class MultiheadAttention:    def __init__(self, head_num, dim, dropout=0.1):        super(MultiHeadAttention, self).__init__()        assert dim % head_num == 0        self.head_dim = dim / head_num        self.head_num = head_num        self.wq = torch.linear(dim, dim)        self.wk = torch.linear(dim, dim)        self.wv = torch.linear(dim, dim)        self.wo = torch.linear(dim, dim)        self.dropout = torch.nn.Dropout(dropout)    def forward(x, mask=None, dropout=None):        if mask:            mask = mask.unsqueeze(1)        batch_size = x.size(0)# x与矩阵Wq, Wk, Wv, Wo计算得到 Q,K,V, O, 形状为[batch_size, seq_length, dim]。# QKV通过矩阵变换实现多头机制,矩阵变换后的形状为[batch_size, head_num, seq_length, head_dim], 其中head_num * head_dim = dim        q = self.wq(x).view(batch_size, -1, self.head_num, self.head_dim).transpose(1, 2)        k = self.wk(x).view(batch_size, -1, self.head_num, self.head_dim).transpose(1, 2)        v = self.wv(x).view(batch_size, -1, self.head_num, self.head_dim).transpose(1, 2)# QKV进行attention计算,得到结果的形状为[batch_size, head_num, seq_length, head_dim],再经过矩阵变换(恢复)成 [batch_size, seq_length, dim]        output = self_attention(q, k, v, mask, self.dropout)        output = output.transpose(1, 2).contiguous().view(batch_size, -1, self.head_num * self.head_dim)        del q        del k        del v# 上一个步骤的结果与矩阵O进行计算,得到Multihead Attention阶段的输出,形状为 [batch_size, seq_length, dim]        return self.wo(output)
  • Feed Forward的输入为Multihead Attention层的输出,形状为[batch_size, seq_length, dim]
  • input_ff 经过第一个线性变换层,得到输出 input_ff_1 [batch_size, seq_length, dim_ff], dim_ff一般比dim要大,用于增强模型的表达能力,学到更复杂的函数关系
  • input_ff_1 经过一个激活函数,得到input_ff_act形状不变
  • input_ff_act 经过第二个线性变换层,得到输出input_ff_2 [batch_size, seq_length, dim],这里的形状又和输入的形状一样了,目的是为了能够匹配下一个Encoder Layer

具体实现

class FeedForward:    def __init__(self, dim, dim_ff, dropout=0.1):        super(FeedForwad, self).__init__()        self.ff1 = torch.nn.Linear(dim, dim_ff)        self.ff2 = torch.nn.Linear(dim_ff, dim)        self.drop = torch.nn.Dropout(dropout)    def forward(self, x):        return self.ff2(self.dropout(self.ff1(x).relu()))

LayerNorm的作用

  • 归一化数据,使数据分布更加稳定,避免梯度消失和爆炸的情况,进而使训练更加稳定
  • 归一化数据之后,减少了数据噪音对模型的影响,使模型更加鲁棒

具体实现

class LayerNorm:    def __init__(self, features, eps=1e-6):        super(LayerNorm, self).__init__()        self.weight = torch.nn.Parameter(torch.ones(features))        self.bias = torch.nn.Parameter(torch.zeros(features))        self.eps = eps    def forward(self, x):# 计算均值        mean = x.mean(-1, keepdim=True)# 计算标准差        std = x.std(-1, keepdim=True)# 归一化        normalized = (x - mean) / (std + eps)# 对归一化后的结果乘上可学习的权重并加上可学习的偏差        return self.weight * normalized + self.bias

最后返回的时候需要对归一化的结果乘上可学习的权重和偏差,是为了恢复数据的表达能力。

Encoder 的具体实现

def clones(module, n):    return nn.ModuleList([copy.deepcopy(module) for _ in range(n)])class SublayerConnection:    def __init__(self, size, dropout):        super(SublayerConnection, self).__init__()        self.layernorm = LayerNorm(size)        self.dropout = torch.nn.Dropout(dropout)    def forward(self, x, sublayer):        return x + self.dropout(self.layernorm(x))class EncoderLayer:    def __init__(self, size, multihead_atten, feedforward, dropout):        super(EncoderLayer, self).__init__()        self.multiatten = multihead_atten        self.feedforward = feedforward        self.sublayerconnectionlist = clones(SublayerConnection(size, dropout), 2)        self.size = size    def forward(self, x, mask=None):        output = self.sublayerconnectionlist[0](x, lambda x: self.multiatten(x, mask))        return self.sublayerconnectionlist[1](x, self.feedforward)class Encoder:    def __init__(self, layer, n):        super(Encoder, self).__init__()        self.encoder_layer = clones(layer, n)        self.layernorm = LayerNorm(layer.size)    def forward(self, x):        for layer in self.encoder_layer:            x = layer(x)        return self.layernorm(x)

Decoder

输入输出

Decoder的输入包含三个部分:

  • 目标序列(Target Sequence)在训练过程中,Decoder的输入是目标语言的序列(例如,在英语到法语翻译任务中,这是法语句子)。这个目标序列会被右移(Right Shift),以确保Decoder生成当前词时不会看到未来的词。例如,输入序列 ["Je", "suis", "content"] 会变成 ["", "Je", "suis"]。
  • Encoder输出(Context from Encoder)Decoder还接收来自Encoder的上下文表示,这个表示捕获了源语言输入的所有信息。
  • 位置编码(Positional Encoding)为了给序列中的每个词提供位置信息,输入序列会添加位置编码,以保留词在句子中的顺序。

Decoder的输出为预测的目标序列(Predicted Target Sequence),以翻译为例Decoder输出的序列是目标语言的预测翻译结果。在每个时间步,Decoder会生成下一个词的概率分布,并选取概率最高的词作为输出。

Decoder结构

Decoder的结构和Encoder类似,Decoder 是N个Decoder layer的堆叠。每一个Decoder layer包含三个sublayer,依次是Masked MultiHead Attention,Encoder-Decoder Attention,FFN。Encoder-Decoder Attention,FFN 的结构和Encoder Layer中 Multihead Attention,FFN的结构是一样的,Masked Multihead Attention相比MultiHead Attention,多了一个mask机制,关于mask机制的作用,我们会在下一小节介绍。

Decoder Layer的具体结构为下图中最右侧部分所示。第一层Masked MultiHead Attention接收上一层Decoder的输出,第二层Encoder-Decoder Attention接收Encoder的输出和Masked Multihead Attention的输出。

不同sublayer的作用

该sublayer利用掩码(mask)机制用来阻止Decoder在生成当前token的时候去"看"它之后的tokens,确保每个位置的预测只依赖于它之前的tokens,而不应该看到后面的tokens。这样做的原因是因为Decoder是用来预测下一位token的,在训练Decoder预测能力时不能提前让它看到答案,因此需要将未来的token遮蔽住。当然阻止模型看到未来的token也是为了保证自回归模型的特征。

每层Decoder Layer中的Encoder-Decoder Attention都会接收Encoder的输出和Masked Multihead Attention的输出结果,这样Decoder Layer可以获取输入文本的信息,并利用attention机制建立输入文本和输出文本间的关系。

与Encoder Layer中FFN的作用一致。

sublayer间的数据流动

  • 输入给masked multihead attention的query,key,value数据相同,均来自于上一层decoder layer的输出,数据形状为[batch_size, target_seq_length, dim]。

  • QKV分别与矩阵Wq,Wk,Wv计算得到 Q,K,V,形状为[batch_size, target_seq_length, dim]。

  • QKV通过矩阵变换实现多头机制,矩阵变换后的形状为[batch_size, head_num, target_seq_length, head_dim], 其中head_num * head_dim = dim

  • QKV进行attention计算,得到结果的形状为[batch_size, head_num, target_seq_length, head_dim],再经过矩阵变换(恢复)成 [batch_size, target_seq_length, dim]

  • 上一个步骤的结果与矩阵WO进行计算,得到Multihead Attention阶段的输出,形状为 [batch_size, target_seq_length, dim]

  • 输入给Encoder-Decoder Attention的query来自Masked Multihead Attention,数据形状为[batch_size, target_seq_length, dim]。key,value来自Encoder均来自于上一层decoder layer的输出,数据形状为[batch_size, source_seq_length, dim]。

  • QKV分别与矩阵Wq,Wk,Wv计算得到 Q,K,V,形状依次为[batch_size, target_seq_length, dim],[batch_size, source_seq_length, dim],[batch_size, source_seq_length, dim]。

  • QKV通过矩阵变换实现多头机制,矩阵变换后的形状分别为[batch_size, head_num, target_seq_length, head_dim]、[batch_size, head_num, source_seq_length, head_dim]、[batch_size, head_num, source_seq_length, head_dim],其中head_num * head_dim = dim

  • QKV进行attention计算,得到结果的形状为[batch_size, head_num, target_seq_length, head_dim],再经过矩阵变换(恢复)成 [batch_size, target_seq_length, dim]

  • 上一个步骤的结果与矩阵WO进行计算,得到Encoder-Decoder Attention阶段的输出,形状为 [batch_size, target_seq_length, dim]

参考Encoder Layer中的FFN数据流动。

Masked Multihead Attention中Mask的实现

def subsequent_mask(size):    attn_shape = (1, size, size)    mask = torch.triu(torch.ones(attn_shape), diagonal=1).type(torch.uint8)    return mask == 0

示例输出,假设size=5的话,得到的mask如下:

[[[True,  False, False, False, False],  [True,  True,  False, False, False],  [True,  True,  True,  False, False],  [True,  True,  True,  True,  False],  [True,  True,  True,  True,  True]]]

这里,我一开始不理解为什么tgt_mask的shape是(1,size,size),而不是(1,size),后来再翻看self_attention代码的时候发现,在masked multihead attention中qk/sqrt(d_k)结果的shape是(batch_size, target_seq_length, target_seq_length),然后对这个结果施加掩码,mask中第二个维度表示当前步的token,第三个维度表示当前步token能够查看到的所有其他词。将mask==0的位置设置为-inf,经过softmax之后这些位置的权重变为0,这样就能保证第i步的token在进行注意力计算时只能利用到小于等于位置i的token的value值。

Encoder-Decoder Attention中src_mask的形状为[batch_size, 1, source_seq_length],在该attention模块,qk结果的shape是(batch_size, target_seq_length, source_seq_length),src_mask会自动广播匹配(batch_size, target_seq_length, source_seq_length),屏蔽掉输入文本中不需要关注的填充字符。

Decoder的具体实现

class DecoderLayer:    def __init__(self, size, self_attn, src_attn, ffn, dropout):        super(DecoderLayer, self).__init__()        self.size = size        self.self_attn = self_attn        self.src_attn = src_attn        self.ffn = ffn        self.sublayer = clones(SublayerConnection(size, dropout), 3)    def forward(self, x, memory, src_mask, tgt_mask):        m = memory        x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, tgt_mask))        x = self.sublayer[1](x, lambda x: self.src_attn(x, memory, memory, src_mask))        return self.sublayer[2](x, self.ffn)class Decoder(nn.Module):    def __init__(self, layer, n):        super(Decoder, self).__init__()        self.decoder_layers = clone(layer, n)        self.norm = LayerNorm(layer.size)    def forward(self, x, memory, src_mask, tgt_mask):        for layer in self.decoder_layers:            x = layer(x, memory, src_mask, tgt_mask)        return self.norm(x)

总结

本篇文章首先介绍了Transformer的总体结构,Encoder用来编码输入信息,Decoder用来逐步产生输出。并详细介绍了Encoder、Decoder内部的结构,数据是如何流动变换的、以及重点模块的代码实现。

Ref

  • The Annotated Transformer
  • Attention is all you need
基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-11-16 21:31:10 HTTP/1.1 GET : http://h.sjds.net/a/579887.html
  2. 运行时间 : 0.088240s [ 吞吐率:11.33req/s ] 内存消耗:4,533.95kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=21e18093f4a4806ded4ee60690f48c7b
  1. /www/wwwroot/h.sjds.net/public/index.php ( 0.79 KB )
  2. /www/wwwroot/h.sjds.net/vendor/autoload.php ( 0.17 KB )
  3. /www/wwwroot/h.sjds.net/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /www/wwwroot/h.sjds.net/vendor/composer/platform_check.php ( 0.90 KB )
  5. /www/wwwroot/h.sjds.net/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /www/wwwroot/h.sjds.net/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /www/wwwroot/h.sjds.net/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /www/wwwroot/h.sjds.net/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /www/wwwroot/h.sjds.net/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /www/wwwroot/h.sjds.net/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /www/wwwroot/h.sjds.net/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /www/wwwroot/h.sjds.net/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /www/wwwroot/h.sjds.net/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /www/wwwroot/h.sjds.net/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /www/wwwroot/h.sjds.net/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /www/wwwroot/h.sjds.net/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /www/wwwroot/h.sjds.net/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /www/wwwroot/h.sjds.net/app/provider.php ( 0.19 KB )
  23. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /www/wwwroot/h.sjds.net/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /www/wwwroot/h.sjds.net/app/common.php ( 0.03 KB )
  27. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /www/wwwroot/h.sjds.net/config/app.php ( 0.95 KB )
  30. /www/wwwroot/h.sjds.net/config/cache.php ( 0.78 KB )
  31. /www/wwwroot/h.sjds.net/config/console.php ( 0.23 KB )
  32. /www/wwwroot/h.sjds.net/config/cookie.php ( 0.56 KB )
  33. /www/wwwroot/h.sjds.net/config/database.php ( 2.48 KB )
  34. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /www/wwwroot/h.sjds.net/config/filesystem.php ( 0.61 KB )
  36. /www/wwwroot/h.sjds.net/config/lang.php ( 0.91 KB )
  37. /www/wwwroot/h.sjds.net/config/log.php ( 1.35 KB )
  38. /www/wwwroot/h.sjds.net/config/middleware.php ( 0.19 KB )
  39. /www/wwwroot/h.sjds.net/config/route.php ( 1.89 KB )
  40. /www/wwwroot/h.sjds.net/config/session.php ( 0.57 KB )
  41. /www/wwwroot/h.sjds.net/config/trace.php ( 0.34 KB )
  42. /www/wwwroot/h.sjds.net/config/view.php ( 0.82 KB )
  43. /www/wwwroot/h.sjds.net/app/event.php ( 0.25 KB )
  44. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /www/wwwroot/h.sjds.net/app/service.php ( 0.13 KB )
  46. /www/wwwroot/h.sjds.net/app/AppService.php ( 0.26 KB )
  47. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /www/wwwroot/h.sjds.net/vendor/services.php ( 0.14 KB )
  53. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /www/wwwroot/h.sjds.net/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /www/wwwroot/h.sjds.net/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /www/wwwroot/h.sjds.net/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /www/wwwroot/h.sjds.net/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /www/wwwroot/h.sjds.net/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /www/wwwroot/h.sjds.net/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /www/wwwroot/h.sjds.net/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /www/wwwroot/h.sjds.net/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /www/wwwroot/h.sjds.net/app/Request.php ( 0.09 KB )
  84. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /www/wwwroot/h.sjds.net/app/middleware.php ( 0.25 KB )
  86. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /www/wwwroot/h.sjds.net/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /www/wwwroot/h.sjds.net/route/app.php ( 1.72 KB )
  100. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /www/wwwroot/h.sjds.net/app/controller/Index.php ( 4.81 KB )
  104. /www/wwwroot/h.sjds.net/app/BaseController.php ( 2.05 KB )
  105. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /www/wwwroot/h.sjds.net/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /www/wwwroot/h.sjds.net/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /www/wwwroot/h.sjds.net/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /www/wwwroot/h.sjds.net/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /www/wwwroot/h.sjds.net/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /www/wwwroot/h.sjds.net/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /www/wwwroot/h.sjds.net/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /www/wwwroot/h.sjds.net/runtime/temp/c1d6e8c94b2c2fa10e259903674c804d.php ( 8.11 KB )
  140. /www/wwwroot/h.sjds.net/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000657s ] mysql:host=172.18.0.4;port=3306;dbname=h_sjds;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000884s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000382s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000420s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000626s ]
  6. SELECT * FROM `set` [ RunTime:0.000333s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000813s ]
  8. SELECT * FROM `article` WHERE `id` = 579887 LIMIT 1 [ RunTime:0.000522s ]
  9. UPDATE `article` SET `lasttime` = 1794835870 WHERE `id` = 579887 [ RunTime:0.010309s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 65 LIMIT 1 [ RunTime:0.000358s ]
  11. SELECT * FROM `article` WHERE `id` < 579887 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000444s ]
  12. SELECT * FROM `article` WHERE `id` > 579887 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000607s ]
  13. SELECT * FROM `article` WHERE `id` < 579887 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.000992s ]
  14. SELECT * FROM `article` WHERE `id` < 579887 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.001444s ]
  15. SELECT * FROM `article` WHERE `id` < 579887 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.000674s ]
0.099425s