gpt⑶GPT4:你有没深入想过,什么造成了GPT⑷的输出很随机? 奔走相告
欢迎大家能看到这篇文章: 机器之心报道编辑:小舟Google Deepmind 可能早就意识到了这个问题今年,大...
欢迎大家能看到这篇文章:
机器之心报道编辑:小舟Google Deepmind 可能早就意识到了这个问题今年,大型语言模型(LLM)成为 AI 领域最受关注的焦点,OpenAI 的 ChatGPT 和 GPT⑷ 更是爆火出圈GPT⑷ 在自然语言理解取生成、逻辑推理、代码生成等方面性能出色,令人惊艳。
然而,人们逐渐发现 GPT⑷ 的生成结果具有较大的没有确定性对于用户输入的问题,GPT⑷ 给出的回答往往是随机的我们知道,大模型中有1个 temperature 参数,用于控制生成结果的多样性和随机性。
temperature 设置为 0 意味着贪婪采样(greedy sampling),模型的生成结果应该是确定的,而 GPT⑷ 即使在 temperature=0.0 时,生成的结果依然是随机的在1场圆桌开发者会议上,有人曾直接向 OpenAI 的技术人员询问过这个问题,得到的回答是这样的:「老实说,我们也很困惑。
我们认为系统中可能存在1些错误,或者优化的浮点计算中存在1些没有确定性......」值得注意的是,早在 2021 年就有网友针对 OpenAI Codex 提出过这个疑问这意味着这种随机性可能有更深层次的原因。
图源:https://community.openai.com/t/a-question-on-determinism/8185现在,1位名为 Sherman Chann 的开发者在小我博客中详细分析了这个问题,并表示:「GPT⑷ 生成结果的没有确定性是由稀疏 MoE 引起的」。
Sherman Chann 博客地址:https://152334h.github.io/blog/non-determinism-in-gpt⑷/Sherman Chann 这篇博客受到了 Google DeepMind 最近1篇关于 Soft MoE 的论文《From Sparse to Soft Mixtures of Experts》启发。
论文地址:https://arxiv.org/pdf/2308.00951.pdf在 Soft MoE 论文的 2.2 节中,有这样1段描述:在容量限制下,所有稀疏 MoE 都以固定大小的组来路由 token,并强制(或鼓励)组内平衡。
当组内包含来自没有同序列或输入的 token 时,这些 token 通常会相互竞争专家缓冲区中的可用位置因此,模型在序列级别没有再具有确定性,而仅在批次级别(batch-level)具有确定性,因为某些输入序列可能会影响其他输入的最终预测。
此前,有人称 GPT⑷ 是1个混合专家模型(MoE)Sherman Chann 基于此做出了1个假设:GPT⑷ API 用执行批推理(batch inference)的后端来托管尽管1些随机性可能是因为其他因素,但 API 中的绝大多数没有确定性是由于其稀疏 MoE 架构未能强制执行每个序列的确定性。
也就是说,Sherman Chann 假设:「稀疏 MoE 模型中的批推理是 GPT⑷ API 中大多数没有确定性的根本原因」为了验证这个假设,Sherman Chann 用 GPT⑷ 编写了1个代码脚本:。
import osimport jsonimport tqdmimport openaifrom time import sleepfrom pathlib import Pathchat_models = ["gpt⑷", "gpt⑶.5-turbo"]message_history = [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Write a unique, surprising, extremely randomized story with highly unpredictable changes of events."}]completion_models = ["text-davinci-003", "text-davinci-001", "davinci-instruct-beta", "davinci"]prompt = "[System: You are a helpful assistant]\n\nUser: Write a unique, surprising, extremely randomized story with highly unpredictable changes of events.\n\nAI:"results = []import timeclass TimeIt: def __init__(self, name): self.name = name def __enter__(self): self.start = time.time() def __exit__(self, *args): print(f"{self.name} took {time.time() - self.start} seconds")C = 30 # number of completions to make per modelN = 128 # max_tokens# Testing chat modelsfor model in chat_models: sequences = set() errors = 0 # although I track errors, at no point were any errors ever emitted with TimeIt(model): for _ in range(C): try: completion = openai.ChatCompletion.create( model=model, messages=message_history, max_tokens=N, temperature=0, logit_bias={"100257": ⑴00.0}, # this doesnt really do anything, because chat models dont do much ) sequences.add(completion.choices[0].message[content]) sleep(1) # cheaply avoid rate limiting except Exception as e: print(something went wrong for, model, e) errors += 1 print(f"\nModel {model} created {len(sequences)} ({errors=}) unique sequences:") print(json.dumps(list(sequences))) results.end((len(sequences), model))# Testing completion modelsfor model in completion_models: sequences = set() errors = 0 with TimeIt(model): for _ in range(C): try: completion = openai.Completion.create( model=model, prompt=prompt, max_tokens=N, temperature=0, logit_bias = {"50256": ⑴00.0}, # prevent EOS ) sequences.add(completion.choices[0].text) sleep(1) except Exception as e: print(something went wrong for, model, e) errors += 1 print(f"\nModel {model} created {len(sequences)} ({errors=}) unique sequences:") print(json.dumps(list(sequences))) results.end((len(sequences), model))# Printing table of resultsprint("\nTable of Results:")print("Num_Sequences\tModel_Name")for num_sequences, model_name in results: print(f"{num_sequences}\t{model_name}")
当 N=30,max_tokens=128 时,结果如下表所示:
在 Sherman Chann 注意到 logit_bias 问题之前,还得到了如下结果(max_tokens=256):
实验结果表明,GPT⑷ 的输出总是没有确定的(unique completion 数值很高,表明对于相同的输入,GPT⑷ 生成的输出总是没有同的),这几乎可以证实 GPT⑷ 存在问题并且,所有其他没有会陷入重复无用循环的模型也存在某种程度的没有确定性。
这似乎说明没有可靠的 GPU 计算也会造成1定程度的随机性Sherman Chann 表示:「如果没有确定性是稀疏 MoE 批推理固有的特征,那么这1事实对于任何使用该类模型的研究来说都应该是显而易见的Google Deepmind 的研究团队显然知道这1点,并且他们认为这个问题很微没有足道,以至于只是把它写成了1句没有经意的话放在论文中」。
此外,Sherman Chann 还推测 GPT⑶.5-Turbo 可能也使用了 MoE网友怎么看这篇博客发表后,开发者们也开始讨论 GPT⑷ 输出的没有确定问题有人认为这可能是「多线程并行」造成的:。
也有人表示:「虽然计算是确定的,但是执行计算的多个处理器之间可能存在时钟频率偏差」:
1位支持 Sherman Chann 的假设的开发者说道:「GPT⑶.5-Turbo 可能就是 OpenAI 为 GPT⑷ 构建的小型测试模型」。
还有开发者分析道:「按照 Soft MoE 论文的说法,稀疏 MoE 没有仅引入了没有确定性,还可能会使模型的响应质量取决于有多少并发请求正在争夺专家模块的分配」。
对此,你怎么看?参考链接:https://news.ycombinator.com/item?id=37006224告发/反馈
文章伪原创_免费伪原创工具_AI在线文章伪原创工具 -weiyuanchuang.wanxiangsucai.com
当前非电脑浏览器正常宽度,请使用移动设备访问本站!