Count what token follows each token. This is the complete sufficient statistic for a tiny bigram language model before probabilities or sampling.
Required APIdef bigram_counts(tokens):
return {token: {next_token: count}}BehaviorThink through the mechanism first if you want the extra reasoning step. It never blocks the editor.
bigram_counts(['a', 'b', 'a'])the model learns local next-token evidence
bigram_counts(['a', 'b', 'a', 'b'])counts preserve frequency, not just presence
2 hidden edge tests run after the visible contract passes.
Run Tests to see the contract verdicts here.