非确定性不重要
Non-Determinism Doesn't Matter

原始链接: https://sklar.rocks/non-determinism-doesnt-matter/

我曾将LLM的非确定性视为精确软件开发的缺陷。然而,我意识到虽然正确的结果至关重要,但到达它们的路径不需要确定性。LLM作为概率行为体运行,而非僵化的代码。就像选择编程语言来解决问题一样,许多路径都能通向同一个结果。工程师因此必须通过上下文工程、工具使用和结构化抽象来降低模型的随机性,从而使LLM调用确定性仪器进行精确计算。这使自动化复合:AI生成自己的可靠工具,随时间推移减少token使用和随机性。这一模式镜像了历史上的DevOps进步,机器加速了人类曾手动完成的工作。最终,我们利用今天的随机性来构建更确定、更高效的系统。

这篇文章认为,LLM之所以不能替代编译器,不仅仅是因为它们是非确定性的;确定性可以被近似,而人类开发者也是非确定性的。更大的问题是抽象泄漏:LLM经常不能完全遵循指令,可能以难以察觉的方式失败,复杂代码仍需人工审查。评论者争论确定性是指字节级可复现性还是可靠的正确性,指出温度为零并不完全保证确定性,因为存在硬件和采样效应。一些人认为LLM的非确定性在代码生成中是可以接受或有用的,同时强调验证必须更加确定性。其他人强调不可预测性、自然语言的模糊性、缺乏形式化语义,以及实际的LLM产品很少暴露确定性模式。总体而言,该讨论表明LLM的实用性取决于错误率、人工监督和可靠的测试,而非仅仅是确定性输出。
相关文章

原文

One of my fundamental objections to LLM-driven software development was that model output is non-deterministic. Given the same input prompt, a model's output is not guaranteed to be identical on every run, at least under normal running conditions.

I used to think that this was a severe limitation of AI tools. How could we possibly use this unpredictable building block to craft systems that require precise and exact calculations?

But as I started to get more comfortable running AI as my primary means of "writing" code, I had a revelation:

While the result needs to be exact, there is not one correct way to get there. The means by which you obtain a correct result do not need to be deterministic!

Previously, I was used to specifying behavior in terms of code: precise sets of instructions that compile and execute in a predictable way. And mentally, I was treating LLM output like code. But over time, I realized that LLMs play a fundamentally different role than code does in software engineering. LLMs, and their respective harnesses, are actors in a system. Code is just an output.

It took me years to get comfortable with non-deterministic code generation, yet looking back on it, it seems so obvious that programming was always just a means to an end. Let's use languages, always a hot topic of debate amongst programmers, as an example. There are infinite ways to reach the same result as expressed by code, and that's only using a single programming language! There are hundreds of widely used languages out there, and it's possible to write a solution to a particular problem in just about any of them.

For years, developers have been building perfectly functional applications using very different piles of technologies, languages, and frameworks. Choosing one tech stack over another may have made it easier for a human to complete a given task. But clearly, the means of getting to that result could be wildly different across implementations.

Now that we're working with probabilistic actors, it's our job as engineers, or managers (depending on how you look at it), to reduce the probability space to a small, useful area. This is where all of the common LLM tricks come into play: context engineering, MCP, skills, harnesses, graphs, and memories are all tools used to reduce the amount of randomness in model output. But randomness in some form will always be there, which is at odds with the fact that there is still a need for the correct answer, especially when working on mission-critical software.

So let's remove more randomness by turning non-deterministic output into deterministic tools, writing software for agents to use. Agents can call these tools to perform precise, tested, and authorized operations that have the same desired result on every execution. As an added bonus, depending on the tool's complexity, we get the same correct outcome using significantly fewer tokens by calling our new agent-built abstractions.

I've seen this pattern develop both in industry, with tools like https://swamp.club, and in my own work managing production-grade infrastructure. This pattern is the modern incarnation of the compounding automation that drew me into DevOps and software development in the first place. But instead of writing our own tools, we can now use AI to create its own abstractions and instruct it to use them as it builds the foundations of our new agentic software systems.

I find it fascinating that we can harness randomness today in a way that reduces randomness in the future. In the end, it's not much different from writing your own automations on top of earlier abstractions. It's just that the machine is calling them, processing output, and taking action faster than humans ever could.

联系我们 contact @ memedata.com