为何Transformer在计算机视觉中如此受欢迎?
转自:为何Transformer在计算机视觉中如此受欢迎? (msra.cn)
2021-09-24 | 作者:胡瀚
编者按:近一年来,Transformer 在计算机视觉领域所带来的革命性提升,引起了学术界的广泛关注,有越来越多的研究人员投入其中。Transformer 的特点和优势是什么?为什么在计算机领域中 Transformer 可以频频出圈?让我们通过今天的文章来一探究竟吧!
“统一性”是很多学科共同追求的目标,例如在物理学领域,科学家们追求的大统一,就是希望用单独一种理论来解释力与力之间的相互作用。人工智能领域自然也存在着关于“统一性”的目标。在深度学习的浪潮中,人工智能领域已经朝着统一性的目标前进了一大步。比如,一个新的任务基本都会遵循同样的流程对新数据进行预测:收集数据,做标注,定义网络结构,训练网络参数。
但是,在人工智能的不同子领域中,基本建模的方式各种各样,并不统一,例如:在自然语言处理(NLP)领域目前的主导建模网络是 Transformer;计算机视觉(CV)领域很长一段时间的主导网络是卷积神经网络(CNN);社交网络领域目前的主导网络则是图网络等。
尽管如 ...
论文精读 BERT
2.BERT论文链接:1810.04805.pdf (arxiv.org)
解读视频:BERT 论文逐段精读【论文精读】_哔哩哔哩_bilibili
参考代码:personal/bert_torch at main · wdndev/personal · GitHub
1.题目+作者“BERT” (Devlin 等, 2018, p. 1) 自然语言中中近三年最重要的文章;在计算机视觉里面很早就能够在一个大的数据集(比如说ImageNet)上训练出一个CNN模型,用这个模型可以用来处理一大片的机器视觉任务,来提升他们的性能;但是在自然语言处理里面,在BERT之前一直没有一个深的神经网络使得它训练好之后能够帮处理一大片的NLP任务,在NLP中很多时候还是对每个任务构造自己的神经网路,然后再做训练;BERT的出现使得我们能够在一个大的数据集上面训练好一个比较深的神经网络,然后应用在很多的NLP任务上面,这样既简化了NLP任务的训练,又提升了它的性能,所以BERT和它之后的一系列工作使得自然语言处理在过去三年中有了质的飞跃;
pre-training:在一个数据集上训练好一个模型,这个模型 ...
LLMs 目录
0.LLM八股1.LLMs相关文章
LLMs推理优化技术
主流大语言模型的技术原理细节
LLaMA系列模型架构
ChatGLM系列模型架构
RAG(检索增强生成)技术
大模型Agent技术
大语言模型方法与实践
LLM 推理常见参数
检索增强LLM
2.LLMs相关论文
ZeRO
GPT_GPT-2_GPT-3
InstructGPT
GPT-4
ChatGPT 相关核心算法
3.Transformer相关文章
Transformer综述
The Annotated Transformer最新翻译
Transformer架构解析
Transformer构建语言模型
Transformer为啥这么欢迎
Transformer中的注意力
Transformer架构细节
Transformer中的位置编码
4.Transformer相关论文
Transformer
BERT
ViT
Swim Transformer
MAE
5.清华大模型公开课
视频连接:https://www.bilibili.com/video/BV1UG411p7zv
文档资料:OpenBMB - 让大模型飞入 ...
论文精读目录
0.如何阅读论文
如何阅读论文
1.Deep Learning
GNN
GAN
MoCo
对比学习论文综述
ELMo
MoE
MoE经典论文简牍
2.Transformer
Transformer
BERT
ViT
Swim Transformer
GPT_GPT-2_GPT-3
InstructGPT
GPT-4
MAE
3.Reinforcement Learning
WU-UCT
Rainbow
4.LLMs
ZeRO
5.Others
ChatGPT 相关核心算法
大模型时代下做科研的四个思路
论文精读 Transformer
论文地址: https://arxiv.org/pdf/1810.04805.pdf
解析视频:Transformer论文逐段精读【论文精读
Transformer Model:Transformer架构解析
代码链接:personal/transformer · GitHub
1.Transformer
1.摘要1、transduction models”:序列转录模型:给以序列生成另一个序列
2.结论3.导言4.相关工作5.模型
5.1 LayerNorm 和 BatchNorm(1)BatchNorm 简单的 2 维 情况(蓝色)每一行是一个样本 X,每一列是 一个 feature
BatchNorm:每次把一列(1 个 feature)放在一个 mini-batch 里,均值变成 0, 方差变成 1 的标准化。
How:(该列向量 - mini-batch 该列向量的均值)/(mini - batch 该列向量的方差)
训练时:mini-batch 计算均值;
测试时:使用 全局 均值、方差。
BatchNorm 还会学 lambda beta,BatchNorm 可以通过学习 ...
Transformer构建语言模型
Transformer构建语言模型本文主要来自:The Annotated Transformer
Transformer Model:Transformer架构解析
论文地址: https://arxiv.org/pdf/1810.04805.pdf
代码链接:personal/transformer · GitHub
什么是语言模型:
以一个符合语言规律的序列为输入,模型将利用序列间关系等特征,输出一个在所有词汇上的概率分布.这样的模型称为语言模型.
123# 语言模型的训练语料一般来自于文章,对应的源文本和目标文本形如:src1 = "I can do" tgt1 = "can do it"src2 = "can do it", tgt2 = "do it <eos>"
语言模型能解决哪些问题
根据语言模型的定义,可以在它的基础上完成机器翻译,文本生成等任务,因为我们通过最后输出的概率分布来预测下一个词汇是什么.
语言模型可以判断输入的序列是否为一句完整的话,因为我们可以根据输出的概率 ...
Transformer架构解析
Transformer架构解析本文主要来自:The Annotated Transformer
论文地址: https://arxiv.org/pdf/1810.04805.pdf
代码链接:personal/transformer · GitHub
1.Transformer架构图1.1 Transformer模型的作用基于seq2seq架构的transformer模型可以完成NLP领域研究的典型任务, 如机器翻译, 文本生成等. 同时又可以构建预训练语言模型,用于不同任务的迁移学习.
https://www.bilibili.com/video/BV1qh4y1o7UU
1.2 Transformer总体架构
(1)输入部分
源文本嵌入层及其位置编码器
目标文本嵌入层及其位置编码器
(2)输出部分
线性层
softmax层
(3)编码器
由N个编码器层堆叠而成
每个编码器层由两个子层连接结构组成
第一个子层连接结构包括一个多头自注意力子层和规范化层以及一个残差连接
第二个子层连接结构包括一个前馈全连接子层和规范化层以及一个残差连接
(4)解码器部分:
由N个解码器层堆叠 ...
The Annotated Transformer最新翻译
The Annotated Transformer最新翻译
2023版最新The Annotated Transformer翻译
原文地址:http://nlp.seas.harvard.edu/annotated-transformer/#hardware-and-schedule
0.Prelims123456789101112131415161718192021222324252627import osfrom os.path import existsimport torchimport torch.nn as nnfrom torch.nn.functional import log_softmax, padimport mathimport copyimport timefrom torch.optim.lr_scheduler import LambdaLRimport pandas as pdimport altair as altfrom torchtext.data.functional import to_map_style_datasetfrom torch.u ...
如何阅读论文
解读视频:https://www.bilibili.com/video/BV1H44y1t75x/?spm_id_from=333.999.0.0
花三遍,读一篇论文
第一遍(花时最少,做海选)第一遍读论文的时候,需要去关注标题和摘要
读完摘要之后,直接跳到结论这边
读完这三个部分,大致就知道这篇论文是在讲什么东西了
第二遍(对相关论文做以进一步精选)第二遍里面我们就要对整个文章完整过一遍,然后知道每一块到底在干什么东西,我们可以沿着从标题一直往下读到最后,但是这个时候也不需要注意太多的细节,以及一些公式的证明等等。
关注的地方:第二遍阅读的时候,最重要是搞明白那些重要的图和表,都要知道他每一个字在干什么事情 ;作者提出的方法和别人提出的方法是怎么进行对比的?之间差距有多大?这个时候可能你还没有特别搞懂他在干什么。但是不要紧,你可以将不懂的地方标记下来,留到之后第三遍进行阅读
达到的效果:第二遍阅读完之后,你就对整个论文的各个部分,都有一个大概的了解,中间可以把作者引用的别人的相关文献圈出来,比如作者是在某某某的方法上进行了改进,做了哪些改进之类的。这里需要注意的是,如果你发现作 ...
论文精读 Rainbow
RainbowRainbow: Combining Improvements in Deep Reinforcement LearningRainbow: 结合深度强化学习的改进论文地址:https://arxiv.org/abs/1710.02298
摘要深度强化学习社区对DQN算法进行了几项独立改进。然而,尚不清楚这些扩展中的哪一个是互补的,并且可以有效地结合。本文研究了DQN算法的六个扩展,并实证研究了它们的组合。我们的实验表明,在数据效率和最终性能方面,该组合在雅达利2600基准上提供了最先进的性能。我们还提供了详细的消融研究结果,该研究显示了每个部件对整体性能的贡献。
AbstractThe deep reinforcement learning community has made several independent improvements to the DQN algorithm. However, it is unclear which of these extensions are complementary and can be fruitfully comb ...
论文精读 一种简单的蒙特卡洛树搜索并行化方法
监控未观察样本: 一种简单的蒙特卡洛树搜索并行化方法Watch the Unobserved: a Sample Approach to Parallelizing Monte Carlo TreeSearch论文地址:https://openreview.net/forum?id=BJlQtJSKDB
Github :https://github.com/liuanji/WU-UCT
摘要蒙特卡洛树搜索 (MCTS) 算法在许多具有挑战性的基准测试上(例如,围棋等)取得了巨大成功.然而,它们通常需要大量部署,这使得它们的应用成本很高. 此外,由于 MCTS固有的顺序性质,并行化 MCTS 也极具挑战性:每次模拟都严重依赖从先前模拟的数据 (例如,节点访问计数),用于实现有效的探索和利用的权衡. 尽管存在这些困难,我们还是开发了一种算法WU-UCT, 来有效地并行化 MCTS, 它实现了线性加速,并且随着线程数量的增加表现出有限的性能损失. WU-UCT的关键思想是我们引入一组统计数据来跟踪正在进行未结束的模拟样本(称为未观察样本) 的数量. 当我们将最耗时的扩展和模拟步骤并行化时,这 ...
1.强化学习基础
关键词
强化学习(reinforcement learning,RL):智能体可以在与复杂且不确定的环境进行交互时,尝试使所获得的奖励最大化的算法。
动作(action): 环境接收到的智能体基于当前状态的输出。
状态(state):智能体从环境中获取的状态。
奖励(reward):智能体从环境中获取的反馈信号,这个信号指定了智能体在某一步采取了某个策略以后是否得到奖励,以及奖励的大小。
探索(exploration):在当前的情况下,继续尝试新的动作。其有可能得到更高的奖励,也有可能一无所有。
开发(exploitation):在当前的情况下,继续尝试已知的可以获得最大奖励的过程,即选择重复执行当前动作。
深度强化学习(deep reinforcement learning):不需要手动设计特征,仅需要输入状态就可以让系统直接输出动作的一个端到端(end-to-end)的强化学习方法。通常使用神经网络来拟合价值函数(value function)或者策略网络(policy network)。
全部可观测(full observability)、完全可观测(fully observed ...
10.模仿学习
关键词
模仿学习(imitation learning,IL):其讨论我们没有奖励或者无法定义奖励但是有与环境进行交互时怎么进行智能体的学习。这与我们平时处理的问题有些类似,因为通常我们无法从环境中得到明确的奖励。模仿学习又被称为示范学习(learning from demonstration)、学徒学习(apprenticeship learning)以及观察学习(learning by watching)等。
行为克隆(behavior cloning):类似于机器学习中的监督学习,通过收集专家的状态与动作等对应信息,来训练我们的网络。在使用时,输入状态就可以输出对应的动作。
数据集聚合(dataset aggregation):用来应对在行为克隆中专家提供不到数据的情况,其希望收集专家在各种极端状态下的动作。
逆强化学习(inverse reinforcement learning,IRL):逆强化学习先找出奖励函数,再用强化学习找出最优演员。这么做是因为我们没有环境中的奖励,但是有专家的示范,使用逆强化学习,我们可以推断专家是因为何种奖励函数才会采取这些动作。有了奖励函数以后就 ...
2.马尔可夫决策过程
关键词
马尔可夫性质(Markov property,MP):如果某一个过程未来的状态与过去的状态无关,只由现在的状态决定,那么其具有马尔可夫性质。换句话说,一个状态的下一个状态只取决于它的当前状态,而与它当前状态之前的状态都没有关系。
马尔可夫链(Markov chain): 概率论和数理统计中具有马尔可夫性质且存在于离散的指数集(index set)和状态空间(state space)内的随机过程(stochastic process)。
状态转移矩阵(state transition matrix):状态转移矩阵类似于条件概率(conditional probability),其表示当智能体到达某状态后,到达其他所有状态的概率。矩阵的每一行描述的是从某节点到达所有其他节点的概率。
马尔可夫奖励过程(Markov reward process,MRP): 本质是马尔可夫链加上一个奖励函数。在马尔可夫奖励过程中,状态转移矩阵和它的状态都与马尔可夫链的一样,只多了一个奖励函数。奖励函数是一个期望,即在某一个状态可以获得多大的奖励。
范围(horizon):定义了同一个回合(episod ...
3.表格型方法
关键词
概率函数和奖励函数:概率函数定量地表达状态转移的概率,其可以表现环境的随机性。但是实际上,我们经常处于一个未知的环境中,即概率函数和奖励函数是未知的。
Q表格:其表示形式是表格,其中表格的横轴为动作(智能体的动作),纵轴为环境的状态,每一个坐标点对应某时刻智能体和环境的状态,并通过对应的奖励反馈选择被执行的动作。一般情况下,Q表格是一个已经训练好的表格,不过我们也可以每执行一步,就对Q表格进行更新,然后用下一个状态的Q值来更新当前状态的Q值(即时序差分方法)。
时序差分(temporal difference,TD)方法:一种Q函数(Q值)的更新方式,流程是使用下一步的Q值 $Q(s_{t+1},a_{t+1})$ 来更新当前步的Q值 $Q(s_t,a_t)$。完整的计算公式如下:$Q(s_t,a_t) \leftarrow Q(s_t,a_t) + \alpha [r_{t+1}+\gamma Q(s_{t+1},a_{t+1})-Q(s_t,a_t)]$ 。
Sarsa算法:一种更新前一时刻状态的单步更新的强化学习算法,也是一种同策略学习算法。该算法由于每次更新Q函数时需要 ...