Stephen Wolfram:概率从何而来?

Where Do the Probabilities Come From?

概率从何而来?

OK, so ChatGPT always picks its next word based on probabilities. But where do those probabilities come from? Let’s start with a simpler problem. Let’s consider generating English text one letter (rather than word) at a time. How can we work out what the probability for each letter should be?

好的,ChatGPT 总是根据概率选择下一个词。但这些概率是从哪里来的呢?让我们从一个更简单的问题开始。考虑每次生成英文文本一个字母(而不是单词)。我们如何计算每个字母的概率呢?

A very minimal thing we could do is just take a sample of English text, and calculate how often different letters occur in it. So, for example, this counts letters in the Wikipedia article on “cats”:

最简单的方法是只需取一段英文文本样本,然后计算不同字母出现的频率。例如,这是统计维基百科关于“猫”的文章中不同字母出现的次数:

60c92069adf17ed22ed10450493e21aa.png

And this does the same thing for “dogs”:

这是关于“狗”的文章中做的字母计数:

e055571fc3593c2b1e0a4c7334e19a3b.png

The results are similar, but not the same (“o” is no doubt more common in the “dogs” article because, after all, it occurs in the word “dog” itself). Still, if we take a large enough sample of English text we can expect to eventually get at least fairly consistent results:

结果是相似的,但不完全相同(毫无疑问 “o”在关于“狗”的文章中更常见,因为毕竟它出现在单词“dog”中)。但是,如果我们取足够大的英文文本样本,我们可以预期最终得到至少相对一致的结果:

e987b38fe3e06fc42eebb01c58dd337b.png

Here’s a sample of what we get if we just generate a sequence of letters with these probabilities:

这是我们根据这些概率生成字母序列的示例:

0bc520f1e06d5e419f6e645ee4060647.png

We can break this into “words” by adding in spaces as if they were letters with a certain probability:

我们可以通过添加空格作为字母的一种形式来将其分割成“单词”:

6c7091a41e620bf454133aadcaca5236.png

We can do a slightly better job of making “words” by forcing the distribution of “word lengths” to agree with what it is in English:

我们可以通过强制“单词长度”的分布与英文一致,进一步改进“单词”的生成:

2a0fd985c0d2283163f10fc8077f847f.png

We didn’t happen to get any “actual words” here, but the results are looking slightly better. To go further, though, we need to do more than just pick each letter separately at random. And, for example, we know that if we have a “q”, the next letter basically has to be “u”.

这里没有得到“实际单词”,但结果看起来稍微好一些。然而,要进一步,我们需要比仅随机选择每个字母要多做些事情。例如,我们知道如果有一个“q”,下一个字母基本上必须是“u”。

Here’s a plot of the probabilities for letters on their own:

这是字母概率图表:

c51687fd37d9f845079077f40de562eb.png

And here’s a plot that shows the probabilities of pairs of letters (“2-grams”) in typical English text. The possible first letters are shown across the page, the second letters down the page:

这是显示一对字母(“2-grams”)在典型英文文本中的概率的图表。可能的第一个字母显示在页面上方(横坐标),第二个字母显示在页面下方(纵坐标):

03ccae7701290277a8a6c6412a98e98b.png

And we see here, for example, that the “q” column is blank (zero probability) except on the “u” row. OK, so now instead of generating our “words” a single letter at a time, let’s generate them looking at two letters at a time, using these “2-gram” probabilities. Here’s a sample of the result—which happens to include a few “actual words”:

我们可以看到,例如,“q”列是空白的(概率为零),除了“u”行。好的,现在,我们不是每次仅随机生成一个字母,而是同时查看两个字母,使用这些“2-gram”概率来生成我们的“单词”。这是结果的一个示例,其中包括一些“实际单词”:

42844133bbd60a51affb7d5ebc9fe5af.png

With sufficiently much English text we can get pretty good estimates not just for probabilities of single letters or pairs of letters (2-grams), but also for longer runs of letters. And if we generate “random words” with progressively longer n-gram probabilities, we see that they get progressively “more realistic”:

通过足够多的英文文本,我们不仅可以得到单个字母或一对字母(2-grams)的概率的相当好的估计,还可以得到更长的字母序列的估计。如果我们使用越来越长的 n-gram 概率生成“随机单词”,我们会发现它们变得“更真实”:

2a236765b7a285ad9e2af9e2464b527d.png

But let’s now assume—more or less as ChatGPT does—that we’re dealing with whole words, not letters. There are about 40,000 reasonably commonly used words in English. And by looking at a large corpus of English text (say a few million books, with altogether a few hundred billion words), we can get an estimate of how common each word is. And using this we can start generating “sentences”, in which each word is independently picked at random, with the same probability that it appears in the corpus. Here’s a sample of what we get:

但是现在让我们假设——就像 ChatGPT 一样——我们处理的是整个单词,而不是字母。英语中有大约 40,000 个常用词汇。通过查看大量的英语文本语料库(比如几百亿个单词的数百万本书),我们可以估计每个词汇的常见程度。根据这个,我们可以开始生成“句子”,其中每个词汇都是独立地随机选择的,其概率与它在语料库中出现的概率相同。这是我们得到的一个示例:

42b3507008d279d5c5a5d8ca7ca3b581.png

Not surprisingly, this is nonsense. So how can we do better? Just like with letters, we can start taking into account not just probabilities for single words but probabilities for pairs or longer n-grams of words. Doing this for pairs, here are 5 examples of what we get, in all cases starting from the word “cat”:

不出所料,这是无意义的。那么我们该怎么做得更好呢?就像字母一样,我们可以开始考虑不仅仅是单词的概率,还有一对或更长的单词 n-grams 的概率。在考虑了一对单词后,以下是我们得到的5个示例,所有示例均从单词“cat”开始:

50b74e24bf73b3a6a6ce53d6b03eeea7.png

It’s getting slightly more “sensible looking”. And we might imagine that if we were able to use sufficiently long n-grams we’d basically “get a ChatGPT”—in the sense that we’d get something that would generate essay-length sequences of words with the “correct overall essay probabilities”. But here’s the problem: there just isn’t even close to enough English text that’s ever been written to be able to deduce those probabilities.

这看起来稍微更加“合理”。我们可以想象,如果我们能够使用足够长的 n-grams,我们基本上会“得到一个 ChatGPT”——在这个意义上,我们会得到一个可以生成具有“正确整体概率”的文章长度的单词序列。但问题在于:已经没有足够的英文文本被书写出来,可以推断出这些概率。

In a crawl of the web there might be a few hundred billion words; in books that have been digitized there might be another hundred billion words. But with 40,000 common words, even the number of possible 2-grams is already 1.6 billion—and the number of possible 3-grams is 60 trillion. So there’s no way we can estimate the probabilities even for all of these from text that’s out there. And by the time we get to “essay fragments” of 20 words, the number of possibilities is larger than the number of particles in the universe, so in a sense they could never all be written down.

在网页中爬行可能会有几百亿个单词;在数字化的书籍中可能有另外几百亿个单词。但是,对于 40,000 个常见单词,甚至可能的 2-grams 数量已经达到 16 亿,而可能的 3-grams 数量为 60 万亿。因此,我们无法从已有的文本中估计出所有这些概率。当我们到达 20 个单词的“文章片段”时,可能性的数量已超过宇宙中粒子的数量,因此在某种意义上,它们永远不可能全部被写下来。

So what can we do? The big idea is to make a model that lets us estimate the probabilities with which sequences should occur—even though we’ve never explicitly seen those sequences in the corpus of text we’ve looked at. And at the core of ChatGPT is precisely a so-called “large language model” (LLM) that’s been built to do a good job of estimating those probabilities.

那么我们该怎么办呢?一个重要的想法是创建一个模型,让我们能够估计序列出现的概率——即使我们从未在查看过的文本语料库中明确看到过这些序列。ChatGPT 的核心正是一个被称为“大型语言模型(LLM)的模型,它的目标就是要能够很好地估计这些概率。

3d772edd68075684f71e703b1011d00f.jpeg

“点赞有美意,赞赏是鼓励”

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/45141.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Stephen Wolfram:一次只添加一个词

It’s Just Adding One Word at a Time 一次只添加一个词 That ChatGPT can automatically generate something that reads even superficially like human-written text is remarkable, and unexpected. But how does it do it? And why does it work? My purpose here is t…

C#安装包制作过程详解

本文讲解C#安装包制作过程。 文章目录 一、安装打包插件二、项目的部署与安装三、制作安装包时注意路径一、安装打包插件 打开VS2017:工具 --> 扩展和更新 --> 联机,搜索Microsoft Visual Studio Installer Projects,如图: 下载Microsoft Visual Studio Installe…

我在VScode学Python(Python函数,Python模块导入)

我的个人博客主页:如果’真能转义1️⃣说1️⃣的博客主页 (1)关于Python基本语法学习---->可以参考我的这篇博客《我在VScode学Python》 (2)pip是必须的在我们学习python这门语言的过程中Python ---->&a…

vue中的异步请求Axios(个人学习笔记五)

目录 友情提醒第一章、传统的jQuery方式获取数据1.1)后端controller层代码1.2)传统的jQuery获取数据1.3)使用vue对象和jQuery获取异步数据 第二章、使用Axios获取数据2.1)axios简介2.2)axios两种使用方式2.3&#xff0…

Clion开发stm32之微妙延迟(采用nop指令实现)

前言 需要借助逻辑分析仪动态调整参数此次测试的开发芯片为stm32f103vet6 延迟函数 声明 #define NOP_US_DELAY_MUL_CNT 5 /*nop 微妙延迟需要扩大的倍数(根据实际动态修改)*/ void bsp_us_delay_nop(uint32_t us);void bsp_ms_delay_nop(uint32_t ms);定义 void bsp_us_dela…

Java连锁门诊医院HIS信息管理系统源码

Java连锁门诊医院HIS信息管理系统源码:SaaS运维平台多医院多机构多门诊入驻强大的电子病历完整开发文档 一、系统概述 ❉采用主流成熟技术,软件结构简洁、代码规范易阅读,SaaS应用,全浏览器访问前后端分离,多服务协同…

CRM系统化整合从N-1做减法实践 | 京东物流技术团队

1 背景 京销易系统已经接入大网、KA以及云仓三个条线商机,每个条线商机规则差异比较大,当前现状是独立实现三套系统分别做支撑。 2 目标 2022年下半年CRM目标是完成9个新条线业务接入,完成销售过程线上化,实现销售规则统一。 …

IDEA使用lombok实体类加上@Data注解后无法找到get和set方法

文章目录 一、问题原因二、解决方法1.File→Settings2.Plugins→搜索"lombok"→Install3.Restart IDE(重启IDEA) 一、问题原因 IDEA没有安装lombok插件 二、解决方法 1.File→Settings 2.Plugins→搜索"lombok"→Install 3.Restart…

RocketMQ 5.0 无状态实时性消费详解

作者:绍舒 背景 RocketMQ 5.0 版本引入了 Proxy 模块、无状态 pop 消费机制和 gRPC 协议等创新功能,同时还推出了一种全新的客户端类型:SimpleConsumer。 SimpleConsumer 客户端采用了无状态的 pop 机制,彻底解决了在客户端发布…

MB5B在HDB上的性能调优

背景 MB5B是用于查询物料的收发以及现有库存。日常业务查询,通常会按照月份查看某片地区物料的库存以及收发状态。 调优思路 按照客户日常操作的习惯,得到日常操作的数据范围,选出数据量最为突出最有代表性的地区和物料;利用SE30分别运行不同数量级的数据,比如20个门店、…

基于LoRA进行Stable Diffusion的微调

文章目录 基于LoRA进行Stable Diffusion的微调数据集模型下载环境配置微调过程 基于LoRA进行Stable Diffusion的微调 数据集 本次微调使用的数据集为: LambdaLabs的Pokemon数据集 使用git clone命令下载数据集 git clone https://huggingface.co/datasets/lambd…

17. 电话号码的字母组合

题目描述 给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。答案可以按 任意顺序 返回。 给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。 示例 1: 输入:digits "23" …

数据结构的复杂度

> 作者简介:დ旧言~,目前大一,现在学习Java,c,c,Python等 > 座右铭:松树千年终是朽,槿花一日自为荣。 > 望小伙伴们点赞👍收藏✨加关注哟💕&#x1…

结构型设计模式之桥接模式【设计模式系列】

系列文章目录 C技能系列 Linux通信架构系列 C高性能优化编程系列 深入理解软件架构设计系列 高级C并发线程编程 设计模式系列 期待你的关注哦!!! 现在的一切都是为将来的梦想编织翅膀,让梦想在现实中展翅高飞。 Now everythi…

【玩转Linux】标准io缓冲区的操作

(꒪ꇴ꒪ ),hello我是祐言博客主页:C语言基础,Linux基础,软件配置领域博主🌍快上🚘,一起学习!送给读者的一句鸡汤🤔:集中起来的意志可以击穿顽石!作者水平很有限,如果发现错误&#x…

【前缀和】LeetCode 560. 和为k的字数组

文章目录 题目描述方法1 暴力方法2 暴力优化方法3 前缀和方法4 前缀和优化 题目描述 力扣560题,链接:https://leetcode.cn/problems/subarray-sum-equals-k 方法1 暴力 暴力法,三重for循环,时间复杂度 O ( N 3 ) O(N^3) O(N3)&a…

WebClient,HTTP Interface远程调用阿里云API

HTTP Interface Spring 允许我们通过定义接口的方式&#xff0c;给任意位置发送 http 请求&#xff0c;实现远程调用&#xff0c;可以用来简化 HTTP 远程访问。需要webflux场景才可 <dependency><groupId>org.springframework.boot</groupId><artifactId&…

二十三种设计模式第十七篇--迭代子模式

迭代子模式是一种行为型设计模式&#xff0c;它允许你按照特定方式访问一个集合对象的元素&#xff0c;而又不暴露该对象的内部结构。迭代子模式提供了一种统一的方式来遍历容器中的元素&#xff0c;而不需要关心容器的底层实现。 该模式包含以下几个关键角色&#xff1a; 迭…

K8S初级入门系列之五-Pod的高级特性

一、前言 前一篇我们了解了Pod的基本概念和操作&#xff0c;本篇我们继续研究Pod的一些高级特性&#xff0c;包括Pod的生命周期&#xff0c;pod探针&#xff0c;pod的调度等。 二、生命周期 1、Pod的生命周期 Pod的生命周期示意图如下&#xff1a; 挂起(Pending)&#xff0c…

【node-1】node validation exception. bootstrap checks failed

记录ElasticSearch 内存分配不足报错 背景做出的改变说在最后&#xff1a;最后访问es&#xff1a; 背景 从报错信息中看到&#xff0c;文件&#xff0c;虚拟内存的最大值太低&#xff0c;我们需要调整设置虚拟内存大小&#xff0c;以满足ElasticSearch 运行需求。 做出的改变 …
最新文章