Algorithm · Google · Medium
Implement a next-token predictor from tokenized sentences. You are given a corpus as List >, where each inner list represents one tokenized sentence. Train a first-order Markov model by counting every adjacent pair (u, v) so that, for each token u, you know how often each distinct token appears immediately after u. At inference time, accept a query token u and return one following token randomly. The probability of returning a candidate v must match the empirical bigram…
Checking your access…