Matching alphabetic labels with indices in a fine-tuned model

I have a multi-class dataset where label of each sample is one of [D, MD, N, MH, H]. Note that I just provided the dataset and I did not provide any specific order for labels. I fine-tuned a model and the model returns a tensor including five numbers. I know the label is the one whose number is larger than the others. The problem is that I do not know which index indicates to which label. I mean, if the second number, index=1, is the largest number, I do not know if it means class N, D, H or etc.
What do you suggest?

Hi! Welcome to the forum.

Well, let’s try to to find a solution systematically.
To match the indices of the tensor with their corresponding labels explore the dataset to determine if there are any inherent patterns or trends that might indicate label orders.

The best case would be to use distinctive samples: If there are some samples in your dataset that you can confidently say would only belong to one class (based on domain knowledge or other metrics), you can use those samples as test cases. Run these samples through your model and observe which indices consistently output the highest value for those samples.

Otherwise a cross referencing approach may become necessary. Like a frequency analysis.
It’s often the case that different classes might have different frequencies. For instance, one class might be much more common than the others. If you can get or calculate the frequency of each label in your dataset, you might be able to cross-reference it with the output of the model over multiple samples to identify some patterns.

And, maybe it would suffice to get the insight of a domain expert who can infer from the input and output which labels correspond to which index.

What do you think is going to work for your dataset?