DEV Community

Cover image for Generative AI and Non-Determinism
Andrea Chiarelli
Andrea Chiarelli

Posted on • Originally published at theturingmachine.net

Generative AI and Non-Determinism

The limits of my language are the limits of my world.

– Ludwig Wittgenstein

We often hear that generative AI is non-deterministic because it responds differently each time to the same prompt. This quality is both fascinating, because it is, in a sense, creative, and problematic, because it eludes our control in contexts where precision and predictability are essential.

So, is non-determinism really what lies behind the processing of an LLM?

What Is Non-Determinism?

To understand what non-determinism is, we need to turn to the theory of computation.

Imagine you’re in a maze. In a deterministic system, you are a lone explorer. You come to a fork in the road and choose the right path. If the path is blocked, you must go back (good old backtracking) and try the left path.

In a non-deterministic system, however, you possess the gift of ubiquity. When you reach the fork, you split into two people. One goes right and the other goes left.

According to Michael Sipser, the author of the book Introduction to the Theory of Computation, this process is perfect parallelism: just one clone needs to find the exit for the entire machine to succeed. The computation of a non-deterministic machine is not expressed as a transition from one state to another, but rather as a transition from one state to a set of states. This theoretical super-capacity is used to solve complex problems, such as those in the famous NP class.

In computer science, non-determinism is a model of logical perfection. If a solution exists, a non-deterministic machine will find it because it explores every possible path without ever making a mistake. However, be careful: there is no such thing as a purely non-deterministic physical computer.

The Many Faces of Non-Determinism

Before returning to generative AI, we need to clarify the various concepts of non-determinism that are often conflated in everyday language. In fact, the term’s meaning changes significantly depending on the context.

As we have seen, in computer science, non-determinism is a logical abstraction: a virtual perfect parallelism that allows us to solve a problem within a reasonable amount of time.

In physics, non-determinism, or more accurately, indeterminism, is the principle that it is impossible to simultaneously know two conjugate properties of a particle, such as position and momentum.

Biology also has the concept of indeterminism, though it is linked to the role of chance in the evolution of living beings. This chance seems to be present in other aspects of nature, such as the weather, which are so difficult to predict that they appear non-deterministic. In reality, these are not non-deterministic systems, but rather highly complex deterministic systems, as chaos theory explains.

Generative AI is often defined as non-deterministic because of the chaos effect: small variations in the input produce different outputs. However, as we will see, its nature is quite different.

AI and Probability

When you ask an LLM to answer a question or write code, the system doesn't use a non-deterministic approach to find the solution. The LLM simply… guesses.

LLMs are probabilistic machines, not non-deterministic machines. Their entire universe boils down to assigning a probability percentage to the next token. For example, if you write, “The cat is on the...”, the model isn’t thinking about physical space. It calculates that:

  • carpet has an 80% probability.

  • lawn has a 15% probability.

Unlike Sipser’s non deterministic machine, an LLM doesn’t traverse all logical branches. It chooses one based on a statistical distribution. This is a substantial difference!

A non-deterministic machine would virtually always give the correct solution. It would explore all possible branches of the computation to identify the correct one. If a solution is incorrect, that branch of the computation simply ends. There cannot be an output that is not a valid solution to the problem.

The LLM follows likelihood, not truth. It can generate a grammatically perfect sentence that is factually false because those words sound good together statistically. For instance, the LLM might tell you that the capital of Brazil is Rio de Janeiro because Rio is associated with Brazil much more often than Brasília in its training data. Statistically, Rio is the more likely answer, even if it is logically incorrect.

Why Is Imprecise AI Useful?

If AI is fallible and imprecise, why is it revolutionizing the world? Why is it permeating our daily lives?

Traditional, deterministic software is like a train traveling on tracks. It only does what it was programmed to do. It doesn’t make decisions beyond what the programmer intended, and it doesn’t evolve on its own. Traditional software expects input in a specific format. It cannot handle ambiguity or imprecision. For example, if you want to reschedule an appointment from today to tomorrow, you can do so by following one of a few predefined methods.

In contrast, if you ask a chatbot “Move today’s appointment to tomorrow,” or “Move today’s meeting to tomorrow,” or even “Tooday’s apointment goes to tomorow,” it uses its probabilistic nature to correctly interpret your request.

This ability to handle unstructured data, such as analyzing the sentiment of an email, summarizing a document, or translating a text, cannot be reduced to simple, rigid rules. In these cases, probabilistic flexibility is the only way.

Navigating Uncertainty

For now, non-determinism remains a logical ideal of supreme efficiency. However, what we actually have at our disposal is an extraordinary probabilistic tool that is not intended to replace traditional deterministic software, but rather to enhance it.

As developers and engineers, our task is not to eliminate AI's unpredictability, but rather to learn how to channel it. We must design deterministic systems around probabilistic engines that know when to be intuitive and imaginative and when to be precise.

Top comments (0)