pytorch / text

Models, data loaders and abstractions for language processing, powered by PyTorch
https://pytorch.org/text
BSD 3-Clause "New" or "Revised" License
3.51k stars 811 forks source link

torchtext.vocab.Vectors(..).__getitem__ does not work #2139

Closed saeeddhqan closed 1 year ago

saeeddhqan commented 1 year ago

❓ Questions and Help

I loaded a model:

vects = torchtext.vocab.Vectors('text5-emb.txt')

And when I want to know whether a vocab is in the dataset or not, I run this:

if "the" in vects:

and the code stops here. I waited for a long time but it does not do anything. Then, I loaded the model and set the unk_init to lambda x: False Now, I can use vects['the'] to know whether the vocab exists or not.

But why does not getitem work?