How does torchtext encode labels?

torchtext has a common way to map text and labels:

fields = [('text',TEXT), ('label',LABEL)]

In case I have string labels, is there a rule for encoding labels? For example, how does it encode this data:

text1   'AB'
text2   'AA'

Does it first sort labels and ‘AA’ gets label 0 and ‘AB’ gets 1 or ‘AB’ gets 0 and ‘AA’ gets 1? Also, in case of labels are already encoded (0,1,2…) does torchtext just take these labels? Thank you

Field is now part of torchtext.legacy. I personally won’t recommend it. It is better to create your own dataset/dataloader.