Definition

A stopping condition is a rule the generation runtime uses to end a model’s output. Common conditions are an end-of-sequence token generated by the model, a configured stop sequence appearing in the output, and a limit on how many tokens may be generated. Generation ends when one of the applicable conditions is met.

An end-of-sequence token is a special token with its own token ID. A stop sequence is text the runtime watches for, such as a delimiter supplied by the caller. A token limit is a length boundary, even if the model would have continued.

Simple example

Suppose an application asks for a short answer and configures \nEND as a stop sequence. If the model generates Approved\nEND, the runtime stops at that delimiter. If the model emits its end-of-sequence token after Approved, it stops without reaching the delimiter. If the output token allowance runs out after Approved. Reason: the request, the response ends mid-sentence.

Whether the delimiter appears in the returned text depends on the API.

Why it matters

Stopping conditions control where a response ends. A stop sequence can keep the model from continuing into another section. An output token limit bounds generation length and helps contain latency and cost, but it can cut off a response that your application needs in full.

Before accepting the output, check the finish reason if the API provides one. If generation hit a token limit, the response may be incomplete even when it ends with a plausible sentence. Some APIs report natural completion and a matched stop sequence the same way, so the reason may not identify the exact stopping condition.

One important nuance

The model emitting an end-of-sequence token and the runtime matching a text stop sequence are different events. Neither guarantees the answer meets your application’s requirements. Validate the content separately, especially when it must satisfy a schema or drive a later action.