Does eval mode of a nlp model remember previous state?

Going through:

Looking at the sample model method:

def sample_model(m, s, l=50):
    t = num_str(s)
    res,*_ = m(t)
    print('...', end='')

    for i in range(l):
        n = n[1] if[0]==0 else n[0]
        word = TEXT.vocab.itos[[0]]
        print(word, end=' ')
        if word=='<eos>': break
        res,*_ = m(n[0].unsqueeze(0))


Does the model remember previous words when going through sample model loop as it is generating the words? Does it some how remember the previous state until reset is called? If so where is that state being remembered in?

Yes, the state is stored in the hidden attribute in the model. Take a look at the stateful RNN we built in class to see how that works.