Skip to content
ml-recall

#language-model

6 questions from Search & Planning, Recurrent Neural Networks, Language Modeling, NLP Tasks

Timed test

6 questions · 6 min · score and explanations at the end

Take a test
Q 1 / 6Score 0 / 0

Question 1: Single choice

easyAI-checkedSearch & Planning

This loop generates text from a trained character-level RNN language model after reading a user-supplied prefix:

for i in range(len(prefix) + num_preds - 1):
    X = torch.tensor([[outputs[-1]]])
    rnn_outputs, state = self.rnn(self.one_hot(X), state)
    if i < len(prefix) - 1:      # warm-up: feed the prefix
        outputs.append(vocab[prefix[i + 1]])
    else:                        # generate the next character
        Y = self.output_layer(rnn_outputs)
        outputs.append(int(Y.argmax(dim=2).reshape(1)))

Which decoding strategy does it use?

Choose one option