Artificial Fintelligence 09月25日
LLMs使用贪婪采样的原因
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文探讨了大型语言模型(LLMs)为何采用贪婪采样方法进行文本生成。尽管在游戏强化学习和神经机器翻译领域,搜索算法(如蒙特卡洛树搜索和波束搜索)通常能带来更优性能,但LLMs如GPT系列却选择更简单的贪婪采样。文章分析了可能的原因,包括计算效率、模型复杂性和实际效果。尽管有证据表明未来模型可能整合搜索技术,但目前主流LLMs仍依赖贪婪采样的原因在于其简洁性和实用性,以及在某些任务上的足够表现。

😔 贪婪采样是一种简单高效的解码方法,在LLMs推理时能显著降低计算成本。相比于需要额外计算资源的搜索算法,贪婪采样在保持合理生成质量的同时,大幅减少了推理时间,使得大规模语言模型能够实时响应。

🤖 LLMs的核心优势在于庞大的参数量和训练数据,这使得模型能通过逐个词预测的方式生成流畅连贯的文本。贪婪采样充分利用了这一点,通过最大化每个步骤的似然度,避免了复杂搜索可能引入的冗余计算。

📈 尽管搜索算法在特定领域(如棋类游戏)表现优异,但在自然语言生成任务中,贪婪采样的效果已足够满足大多数应用场景的需求。随着模型能力的提升,简单的贪婪采样在生成质量上已难以被用户察觉,因此成为默认选择。

🔄 搜索算法需要维护和扩展复杂的搜索树结构,这增加了模型的维护成本和内存占用。而贪婪采样仅依赖于当前状态和模型输出,结构简单,易于实现和优化,更适合大规模部署。

🧐 目前尚无明确证据表明主流LLMs完全排斥搜索技术,但现有模型在性能和成本之间取得了较好平衡。未来可能看到混合方法的出现,即在关键节点或特定任务中引入搜索增强贪婪采样,而非完全替代。

Why do LLMs use greedy sampling?

This is a speculative article, so I’d greatly appreciate any feedback, particularly if you disagree.

When I began working on LLMs, I found it pretty surprising that the SOTA in generative text was to greedily sample from the bare outputs of the neural networks. In other words, with GPT-style models, the typical approach to generate a sequence of text is something like:

    Run your prompt through your model and generate probabilities over your vocabulary.

    Choose the most likely token (perhaps with some randomization, maybe with some preprocessing, like top-k or nucleus sampling).

    If the chosen token is <|endoftext|>, you’re done; otherwise, concatenate the new token to your prompt and go back to 1.

In games RL research, it is common to instead conduct a much more complicated calculation to choose the next step in your sequence. For instance, AlphaZero uses a somewhat complicated algorithm called Monte Carlo Tree Search (MCTS). Here, I explore some reasons for why LLMs don’t use a fancier decoding algorithm.

But first, a caveat: there’s a lot of literature proposing various ways to do this that I’m not going to engage with, for sake of time. I have a list of references at the end which I’d encourage you to look at if you want a more detailed look.

The current paradigm of language modelling, with GPT-style decoder models, uses greedy autoregressive sampling to generate a sequence of tokens. This is a somewhat surprising choice; if you look at the history of NLP research, particularly the Neural Machine Translation literature, beam search is often needed to reach SOTA performance (e.g. 1703.03906). Similarly, in games research, search is typically many times stronger than any pure neural network approach, and search will strictly dominate wherever it’s feasible (the exceptions are games like Stratego, where the game tree has much too high of a branching factor to be searched with any non-trivial depth). In games like Go, Chess, Poker, or Scotland Yard, search methods dominate.

By search, I am referring to algorithmic search, which I am defining as any method which uses additional compute at inference time to improve the answer. This has nothing to do with Google-style search (which I call “information retrieval”).

So why don’t GPTs use search? Well, there’s a few answers to this. The first one is a total copout:

    GPTs don’t use search as far as we know. OpenAI recently raised my eyebrows when they hired Noam Brown, an expert on search in games, to work on “multi-step reasoning, self-play, and multi-agent AI.” That sounds an awful lot like search to me (and, specifically, sounds a lot like Alpha/MuZero). We also know that Demis has talked about Gemini incorporating techniques from AlphaGo, which, again, makes me think about search (not to mention self-play).

    So it’s entirely possible that search is the secret sauce behind GPT-4’s performance, and the lack of it is why the open source world has been unable to match it. I’m suspicious of this— for reasons I’ll get into below— but if I were actively working on LLM research, I’d be focusing on trying to use search.

Let’s assume, then, that the key players (GPT-4, Claude, etc.) aren’t using search. Why?

Read more

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

LLMs 贪婪采样 搜索算法 自然语言生成 机器学习
相关文章