什么是大型语言模型

概述

  • 从转换器模型到大型语言模型
  • 如何构建大型语言模型?

 

从转换器模型到大型语言模型

若要使用转换器模型处理文本输入,首先需要将其标记化为单词序列。然后将这些标记编码为数字并转换为嵌入,嵌入是保留其含义的标记的向量空间表示。接下来,转换器中的编码器将所有令牌的嵌入转换为上下文向量。

下面是文本字符串、其标记化和向量嵌入的示例。注意,标记化可以是子词,例如文本中的单词“nosegay”被标记为“nose”和“gay”。

Example of input text
1
As she said this, she looked down at her hands, and was surprised to find that she had put on one of the rabbit's little gloves while she was talking. "How can I have done that?" thought she, "I must be growing small again." She got up and went to the table to measure herself by it, and found that, as nearly as she could guess, she was now about two feet high, and was going on shrinking rapidly: soon she found out that the reason of it was the nosegay she held in her hand: she dropped it hastily, just in time to save herself from shrinking away altogether, and found that she was now only three inches high.

Tokenized Text

1
['As', ' she', ' said', ' this', ',', ' she', ' looked', ' down', ' at', ' her', ' hands', ',', ' and', ' was', ' surprised', ' to', ' find', ' that', ' she', ' had', ' put', ' on', ' one', ' of', ' the', ' rabbit', "'s", ' little', ' gloves', ' while', ' she', ' was', ' talking', '.', ' "', 'How', ' can', ' I', ' have', ' done', ' that', '?"', ' thought', ' she', ',', ' "', 'I', ' must', ' be', ' growing', ' small', ' again', '."', ' She', ' got', ' up', ' and', ' went', ' to', ' the', ' table', ' to', ' measure', ' herself', ' by', ' it', ',', ' and', ' found', ' that', ',', ' as', ' nearly', ' as', ' she', ' could', ' guess', ',', ' she', ' was', ' now', ' about', ' two', ' feet', ' high', ',', ' and', ' was', ' going', ' on', ' shrinking', ' rapidly', ':', ' soon', ' she', ' found', ' out', ' that', ' the', ' reason', ' of', ' it', ' was', ' the', ' nose', 'gay', ' she', ' held', ' in', ' her', ' hand', ':', ' she', ' dropped', ' it', ' hastily', ',', ' just', ' in', ' time', ' to', ' save', ' herself', ' from', ' shrinking', ' away', ' altogether', ',', ' and', ' found', ' that', ' she', ' was', ' now', ' only', ' three', ' inches', ' high', '.']

Embedding of the Above Text

2
3
4
5
[ 2.49 0.22 -0.36 -1.55 0.22 -2.45 2.65 -1.6 -0.14 2.26
-1.26 -0.61 -0.61 -1.89 -1.87 -0.16 3.34 -2.67 0.42 -1.71
...
2.91 -0.77 0.13 -0.24 0.63 -0.26 2.47 -1.22 -1.67 1.63
1.13 0.03 -0.68 0.8 1.88 3.05 -0.82 0.09 0.48 0.33]

上下文向量就像整个输入的本质。使用此向量,转换器解码器根据线索生成输出。例如,您可以提供原始输入作为线索,并让转换器解码器生成自然跟随的后续单词。然后,您可以重复使用相同的解码器,但这次的线索将是之前生成的下一个单词。可以重复此过程以创建整个段落,从前导句开始。

转存失败重新上传取消

变压器架构

此过程称为自回归生成。这就是大型语言模型的工作方式,除了这样的模型是一个转换器模型,可以接受很长的输入文本,上下文向量很大,因此它可以处理非常复杂的概念,并且其编码器和解码器中有许多层。

如何构建大型语言模型?

大型语言模型是大规模的转换器模型。它是如此之大,以至于通常无法在一台计算机上运行。因此,它自然是通过API或Web界面提供的服务。正如你所料,这样一个大型模型是在能够记住语言的模式和结构之前从大量的文本中学习的。

例如,支持 ChatGPT 服务的 GPT-3 模型是在来自互联网的大量文本数据上进行训练的。这包括书籍、文章、网站和各种其他来源。在训练过程中,模型学习单词、短语和句子之间的统计关系,使其能够在给定提示或查询时生成连贯且上下文相关的响应。

从这些大量的文本中提炼出来,GPT-3 模型因此可以理解多种语言并拥有各种主题的知识。这就是为什么它可以生成不同风格的文本。虽然您可能会惊讶于大型语言模型可以执行翻译、文本摘要和问答,但如果您认为这些是与前导文本(也称为提示)匹配的特殊“语法”,也就不足为奇了。

总结

开发了多种大型语言模型。例子包括OpenAI的GPT-3和GPT-4,Meta的LLaMA和Google的PaLM2。这些是可以理解语言并可以生成文本的模型。在这篇文章中,您了解到:

  • 大语言模型基于变压器架构。
  • 注意力机制允许LLM捕获单词之间的长期依赖关系,因此模型可以理解上下文。
  • 大型语言模型基于以前生成的标记以自动回归方式生成文本。
  • 学习分享,感谢Adrian Tam知识分享,感谢Dear_MrJack的学习分享

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

全球学习中心

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值