GPT-3是一种基于深度学习原理的语言预测模型。它是由OpenAI开发的,可以从互联网数据中生成任何类型的文本。它只需要一小段文本作为输入,就可以生成大量的准确和复杂的机器生成文本²⁴。
GPT-3是基于Transformer模型的,使用了仅有解码器的自回归架构。它使用下一个单词预测目标进行训练¹²。GPT-3有8个不同的模型,参数从1.25亿到1750亿不等。最大的GPT-3模型有1750亿参数,是有史以来参数最多的神经网络模型¹²。
GPT-3在许多任务上展示了强大的零样本和少样本的能力。它可以从非常少的数据中学习,不需要进行微调¹²。GPT-3在文本生成、机器翻译和数据有限的领域方面取得了实质性进展,但在阅读理解、自然语言推理和常识推理等任务上表现较差¹²。
Source: Conversation with Bing, 2023/5/16
(1) GPT-3 - 维基百科,自由的百科全书. https://zh.wikipedia.org/wiki/GPT-3.
(2) GPT-3是什么?OpenAI GPT-3大白话指南:对未来的影响 … https://blog.csdn.net/sunny_day_day/article/details/108754577.
(3) 理解GPT-3: OpenAI最新的语言模型 - 知乎. https://zhuanlan.zhihu.com/p/212070154.
(4) ChatGPT是什么,一文读懂ChatGPT - 知乎. https://zhuanlan.zhihu.com/p/589961989.
(5) What are GPT-3 Parameters? - Analytics Insight. https://www.analyticsinsight.net/what-are-gpt-3-parameters/.
GPT-3 的主要特点和优势是:
Source: Conversation with Bing, 2023/5/16
(1) GPT-3 - Wikipedia. https://en.wikipedia.org/wiki/GPT-3.
(2) GPT-3 powers the next generation of apps - OpenAI. https://openai.com/blog/gpt-3-apps/.
(3) GPT-3: Language Models are Few-Shot Learners - GitHub. https://github.com/openai/gpt-3.
GPT-3 的主要局限和缺点有:
Source: Conversation with Bing, 2023/5/16
(1) Considering the possibilities and pitfalls of Generative Pre … https://www.nature.com/articles/s41746-021-00464-x.
(2) GPT-3 - Wikipedia. https://en.wikipedia.org/wiki/GPT-3.
(3) GPT-3: Language Models are Few-Shot Learners - GitHub. https://github.com/openai/gpt-3.
GPT-3 是通过以下方式解决生成不安全文本的问题的:
Source: Conversation with Bing, 2023/5/16
(1) New GPT-3 capabilities: Edit & insert - OpenAI. https://openai.com/blog/gpt-3-edit-insert/.
(2) arXiv:2005.14165v4 [cs.CL] 22 Jul 2020. https://arxiv.org/pdf/2005.14165.pdf.
GPT-3 是一种先进的自然语言处理技术,它可以用于多种应用场景,例如搜索、对话、文本生成、问答、创意写作等。¹ GPT-3 的特点是可以通过少量的示例或指令来完成不同的语言任务,而不需要进行任务特定的微调。² 例如,GPT-3 可以用于:
当然,GPT-3 也有一些局限性和挑战,比如数据质量、社会影响、安全性等。²³
Source: Conversation with Bing, 2023/5/16
(1) GPT-3 powers the next generation of apps - OpenAI. https://openai.com/blog/gpt-3-apps/.
(2) GPT-3: Language Models are Few-Shot Learners - GitHub. https://github.com/openai/gpt-3.
(3) Considering the possibilities and pitfalls of Generative Pre … https://www.nature.com/articles/s41746-021-00464-x.
GPT-3 与 GPT-1、GPT-2 的区别主要有以下几个方面:
总之,GPT-3 是在 GPT-2 和 GPT-1 的基础上,通过大幅提升模型规模和数据规模,实现了更强的泛化能力和生成能力的语言模型。
Source: Conversation with Bing, 2023/5/16
(1) 预训练语言模型之GPT-1,GPT-2和GPT-3 - 知乎. https://zhuanlan.zhihu.com/p/350017443.
(2) GPT-1/GPT-2/GPT-3/GPT-3.5 语言模型详细介绍 - 知乎. https://zhuanlan.zhihu.com/p/620494604.
(3) GPT-1 to GPT-4: Each of OpenAI’s GPT Models Explained … https://www.makeuseof.com/gpt-models-explained-and-compared/.
(4) 一招鉴别真假ChatGPT,并简要介绍ChatGPT、GPT、GPT2 … https://blog.csdn.net/suiyingy/article/details/129106431.
(5) GPT-1,GPT-2,GPT-3三兄弟 - 简书. https://www.jianshu.com/p/93f0d1938d75.
GPT-3 的网络结构是基于 Transformer Decoder 的自回归语言模型,只有 解码器 没有编码器。³ 它的输入是一个长度为 2048 的单词序列,经过以下几个步骤处理:
以上步骤构成了 GPT-3 的一个 解码器层,GPT-3 有不同数量的解码器层,从最小的模型的 12 层到最大的模型的 96 层。³
GPT-3 与 GPT-1、GPT-2 的网络结构有以下几个差别:
Source: Conversation with Bing, 2023/5/16
(1) GPT-3 - Wikipedia. https://en.wikipedia.org/wiki/GPT-3.
(2) 最新最全GPT-3模型网络结构详细解析 - 知乎. https://zhuanlan.zhihu.com/p/174782647.
(3) 理解GPT-3: OpenAI最新的语言模型 - 知乎. https://zhuanlan.zhihu.com/p/212070154.
稀疏注意力机制(sparse attention mechanism)是一种优化 Transformer 模型的方法,它可以减少计算和存储的复杂度,提高模型的效率和扩展性。¹²
稀疏注意力机制的基本思想是,不需要计算每个位置与其他所有位置的相关性,而是只选择一部分重要或者相关的位置进行计算。¹² 这样可以减少注意力矩阵中的非零元素,从而节省计算和存储资源。¹²
稀疏注意力机制有不同的实现方式,比如:
稀疏注意力机制可以应用在不同的领域和任务中,如图像生成、音乐生成、文本生成、长文本理解等。¹²
Source: Conversation with Bing, 2023/5/16
(1) 线性self-attention的漫漫探索路(1)—稀疏Attention - 知乎. https://zhuanlan.zhihu.com/p/469853664.
(2) Transformer优化之稀疏注意力 - 知乎. https://zhuanlan.zhihu.com/p/260928791.
(3) 稀疏性在机器学习中的发展趋势:MoE、稀疏注意力机制. https://cloud.tencent.com/developer/article/1957022.
GPT-3 中的稀疏注意力机制是一种利用结构信息限制计算出的相似性得分对的数目的方法,它将对输入长度的二次依赖降低为线性。¹ 这种方法被称为 ETC(Extended Transformer Construction),它可以扩展 Transformer 结构,提高模型的扩展性和效率。¹
GPT-3 中的稀疏注意力机制是在不同的任务和场景中使用不同的稀疏模式,比如滑动窗口、空洞卷积、局部区域等,来确定每个位置需要关注的其他位置。¹ 这样可以减少注意力矩阵中的非零元素,从而节省计算和存储资源。¹
GPT-3 中的稀疏注意力机制可以应用在不同的领域和任务中,如语言建模、问答、翻译、推理等。¹²
Source: Conversation with Bing, 2023/5/16
(1) GPT-3: Language Models are Few-Shot Learners - GitHub. https://github.com/openai/gpt-3.
(2) arXiv:2005.14165v4 [cs.CL] 22 Jul 2020. https://arxiv.org/pdf/2005.14165.pdf.
(3) Transformer优化之稀疏注意力 - 知乎. https://zhuanlan.zhihu.com/p/260928791.
GPT-3 中的自适应注意力跨度是一种新的技术,它可以根据输入的文本长度和复杂度动态地调整模型的注意力范围,从而提高模型的效率和效果¹。自适应注意力跨度的主要思想是,对于较短或较简单的文本,模型可以使用较大的注意力跨度来捕捉全局的语义信息;而对于较长或较复杂的文本,模型可以使用较小的注意力跨度来关注局部的语法结构和细节¹。这样,模型可以根据不同的任务和场景灵活地调整自己的注意力机制,从而在保证准确性的同时节省计算资源和内存消耗¹。
¹: GPT-3: Language Models are Few-Shot Learners - GitHub
Source: Conversation with Bing, 2023/5/16
(1) GPT-3: Language Models are Few-Shot Learners - GitHub. https://github.com/openai/gpt-3.
(2) GPT-3 powers the next generation of apps - OpenAI. https://openai.com/blog/gpt-3-apps/.
(3) Considering the possibilities and pitfalls of Generative Pre … https://www.nature.com/articles/s41746-021-00464-x.
pytorch 版本的代码实现可以参考:
https://github.com/facebookresearch/adaptive-span/blob/main/adaptive_span.py
GPT-3 的核心机制是基于 Transformer 的自回归语言模型,它使用深度学习来生成类似人类的文本¹。GPT-3 的特点是它的规模非常大,有 1750 亿个参数,是目前最大的非稀疏语言模型²。GPT-3 的训练过程是基于大量的互联网文本进行生成式预训练,从而学习语言的统计规律和模式³。GPT-3 的应用过程是基于少量的示例或提示进行文本交互,从而完成不同的任务或领域的适应²。GPT-3 的输入是一系列的 token,经过一系列的注意力层的处理,输出是一个文本补全或生成⁴。
¹: GPT-3: Its Nature, Scope, Limits, and Consequences
²: GPT-3 powers the next generation of apps - OpenAI
³: What is GPT-3? Everything You Need to Know - TechTarget
⁴: GPT-3 architecture and working - Automate Your Sales
Source: Conversation with Bing, 2023/5/16
(1) GPT-3: Its Nature, Scope, Limits, and Consequences. https://link.springer.com/article/10.1007/s11023-020-09548-1.
(2) GPT-3 powers the next generation of apps - OpenAI. https://openai.com/blog/gpt-3-apps/.
(3) What is GPT-3? Everything You Need to Know - TechTarget. https://www.techtarget.com/searchenterpriseai/definition/GPT-3.
(4) GPT-3 architecture and working - Automate Your Sales. https://boostenx.ai/gpt-3-architecture-and-working-mechanism/.
GPT-3 的输入层、中间层、输出层分别是:
¹: GPT-3: Its Nature, Scope, Limits, and Consequences
²: Layer normalization details in GPT-2 - Data Science Stack Exchange
³: interpreting GPT: the logit lens - LessWrong
Source: Conversation with Bing, 2023/5/16
(1) interpreting GPT: the logit lens - LessWrong. https://www.lesswrong.com/posts/AcKRB8wDpdaN6v6ru/interpreting-gpt-the-logit-lens.
(2) Layer normalization details in GPT-2 - Data Science Stack … https://datascience.stackexchange.com/questions/88552/layer-normalization-details-in-gpt-2.
(3) Intermediate layer output · Issue #148 · openai/gpt-2 · GitHub. https://github.com/openai/gpt-2/issues/148.
GPT-3 的位置向量是由两部分组成的:位置编码和位置嵌入。位置编码是使用固定的正弦、余弦函数来生成的,它可以表示任意长度的序列,但是它的维度是固定的。位置嵌入是使用一个可训练的参数矩阵来表示每个位置的信息,它的维度可以和 token 嵌入相匹配,但是它的长度是有限的。GPT-3 将位置编码和位置嵌入相加,得到最终的位置向量。因此,GPT-3 的位置向量既包含了固定的正弦函数,又包含了在训练中学习的参数。
用正弦、余弦函数来生成位置向量的公式是:
PE(pos,2i)=sin(pos/100002i/dmodel) PE_{(pos,2i)} = sin(pos / 10000^{2i/d_{model}}) PE(pos,2i)=sin(pos/100002i/dmodel)
PE(pos,2i+1)=cos(pos/100002i/dmodel) PE_{(pos,2i+1)} = cos(pos / 10000^{2i/d_{model}}) PE(pos,2i+1)=cos(pos/100002i/dmodel)
其中,pospospos 是位置,iii 是维度,dmodeld_{model}dmodel 是嵌入的维度。
GPT-3 中的遮盖机制是指在预训练阶段,将右侧的上下文遮盖起来,只让模型看到左侧的上下文,从而生成下一个词¹。这样可以保证模型不会看到未来的信息,从而生成更自然的语言。这种遮盖机制也被称为 causal masking(因果遮盖),因为它是为了保持因果关系而设计的¹。
Source: Conversation with Bing, 2023/5/16
(1) GPT-3: Language Models are Few-Shot Learners - GitHub. https://github.com/openai/gpt-3.
(2) Considering the possibilities and pitfalls of Generative Pre … https://www.nature.com/articles/s41746-021-00464-x.
(3) GPT-3 powers the next generation of apps - OpenAI. https://openai.com/blog/gpt-3-apps/.
GPT-3 的激活函数是GeLU,即高斯误差线性单元。¹² 它的数学表达式是:
GeLU(x)=xΦ(x)=x12[1+erf(x2)] \text{GeLU}(x) = x \Phi(x) = x \frac{1}{2} \left[1 + \text{erf}\left(\frac{x}{\sqrt{2}}\right)\right] GeLU(x)=xΦ(x)=x21[1+erf(