concept

Autoregressive generation

Generate a sequence using conditional next-token distributions. Greedy decoding and sampling are distinct choices. Use explicit stop conditions and output budgets. The example is a last-word transition baseline, not a neural model.

Formal Syntax & Structure

artificial-intelligence syntaxartificial-intelligence
P(t1,...,tn) = product_i P(ti | t1,...,t(i-1))

Working Example

Example Snippetartificial-intelligence
def generate(start, transitions, budget):    if budget < 0:        raise ValueError("budget must be nonnegative")    output = [start]    for _ in range(budget):        choices = transitions.get(output[-1], {})        if not choices:            break        if any(w <= 0 for w in choices.values()):            raise ValueError("weights must be positive")        token = min(choices, key=lambda t: (-choices[t], t))        if token == "<END>":            break        output.append(token)    return output
table = {"spring": {"seed": 3, "soil": 1},         "seed": {"guide": 2}, "guide": {"<END>": 1}}print(generate("spring", table, 5))print(generate("spring", table, 1))