In # UNQ_C6, shouldn't we be using NMTAttn in `eval` mode?

When we implement def next_symbol(NMTAttn, input_tokens, cur_output_tokens, temperature) , we use the NMTAttn as is. Shouldn’t we be using NMTAttn(mode="eval") here?

I agree with you, and I tried to change the test function to ‘model’ (as defined in the cell right below ‘PART 4: Testing’, but it doesn’t work. Curious to know an answer to this too.

Hi @mazatov and @sylviasc .
You can check the cell just below #UNQ_C7, in which you execute the sampling_decode function (sampling_decode("I love languages.", NMTAttn=model, temperature=0.0, vocab_file=VOCAB_FILE, vocab_dir=VOCAB_DIR)). You can see that the parameter NMTAttn receives as value the model that was instantiated as model = NMTAttn(mode='eval') before. The sampling_decode passes this same object to the next_symbol function also through a parameter with the same name NMTAttn, so the model will be in ‘eval’ mode.

Hope it helps.

1 Like

Hi @darivadi, thanks for the explanation. My confusion comes from the tests for next_symbol, in this line “w1_unittest.test_next_symbol(next_symbol, NMTAttn)” . So the test cases are running on NMTAttn, not in eval mode. To me, logically, after Part 4, I’m expecting running on a test model, which is loaded from a file. If not, I have to rerun everything prior to that if I need to continue working on it after a break, which take a long time.

HI @sylviasc .

In the case of the test given inw1_unittest.test_next_symbol(next_symbol, NMTAttn), inside the public test file the object NMTAttn is initialized in ‘eval’ model inside the test function.

Hope it helps.


@darivadi Thanks for the explanation!