one move: define the contract
Count what token follows each token. This is the complete sufficient statistic for a tiny bigram language model before probabilities or sampling. In the Mini Transformer system, implement this level as a deterministic contract before composing it with the next service.
def bigram_counts(tokens):
return {token: {next_token: count}}