We have to start with declaring fields
from torchtext.data import Field, LabelField
TEXT = Field(tokenize=word_tokenize) # converting strings to int
LABEL = LabelField(dtype=torch.float)
Then construct dataset, this step will tell fields what data to work on
datafields = [(“text”, TEXT), (“labels”, LABEL)]
trn, tst = torchtext.data.TabularDataset.splits(path = ‘Data’,train = ‘train.csv’,
test = ‘test.csv’,
format = ‘csv’,
skip_header = True,
fields = datafields)
After you follow these steps, you have your datasets ready, next steps would be building vocab using TEXT.build_vocab(trn)
Then you will define your batch size and construct iterators.
Hope this will help!!