Torchtext AG_NEWS dataset return (int, tensor)

Hello,

I’m new to torchtext and doing some tutorials with datasets. When I import the AG_NEWS dataset using the following:

import torchtext

train_set, test_set = torchtext.datasets.AG_NEWS(root='./data')

list(train_set)[0]

I get a tuple of an int and tensor:

(2,
 tensor([  432,   426,     2,  1606, 14839,   114,    67,     3,   849,    14,
            28,    15,    28,    16, 50726,     4,   432,   375,    17,    10,
         67508,     7, 52259,     4,    43,  4010,   784,   326,     2]))

I’m supposed to get a tuple of (int, str), so I’m not sure what am I doing wrong here? or if there is a more proper method to import datasets?

Appreciate any help

I cannot reproduce the issue using the last supported torchtext==0.18 release and see:

(3, "Wall St. Bears Claw Back Into the Black (Reuters) Reuters - Short-sellers, Wall Street's dwindling\\band of ultra-cynics, are seeing green again.")

as the output.

Thanks @ptrblck for the reply.
I running torchtext==0.6.0 on Macbook, which is installed by default when through conda install pytoruch::torchtext
I’ve tried to force install conda install pytorch::torchtext =0.18.0, but then when I run the above code I get this error AttributeError: module 'torchtext' has no attribute 'datasets'

I got the same error and needed to import torchtext.datasets first. After the import your code executed and returned the posted output.

I did import trochtext.datasets but then I got an error that torchdata is not installed. I did install it, to get the following error:
ImportError: cannot import name 'DILL_AVAILABLE' from 'torch.utils.data.datapipes.utils.common'