Week 4 lab 1 code confusion

Why is [-choice] used instead of [choice]? Can anyone please help me understand that?

Hope this helps:

  1. Get model predictions.
  2. np.argsort will list the indices that correspond to the probabilities when sorted in ascending order.
  3. Select a token index based on these indices. When choice is negative, you’ll end up picking an index from the end. -1 corresponds to the last element in the list which has the highest value for the probability.
1 Like

It makes sense. Thanks!