Converting GloVe word Embedding .txt to .pt

Hello, I am new to python and pytorch. I am trying to use the DJL library to train an RNN to classify documents but I am missing a word embedding. I found the GloVe Word Embedding and I have downloaded it to my system as a .zip that contains the .txt file. However, when I direct DJL to load this word embedding it is throwing FileNotFoundException: glove_6B_50d.pt file not found in:… I am guessing that I need to take the .txt out of the zip and convert it to a .pt file but I am not sure on how to do that conversion. Is this the correct assumption or is my assumption wrong? If my assumption is correct, is there an example I can take a look at to perform this conversion?

There is no standard approach to convert any text file to a serialized PyTorch file.
The .pt ending is often used for files serialized via torch.save, but it also not a requirement.
You can save any objects via torch.save and it’s also unclear what exactly the text file contains, so we would need to get more details about its content and what is expected in the .pt file.

The file contains many lines that start with the word followed by x amount of floats and all are separated by a single space. So for example:
Hello -1.23242 0.21342134 … -0.1231

World 1.4354 -0.5432 … 0.7542

In regards to what the .pt needs, I am not sure. I will have to ask around to get that information.

You could use e.g. pandas to transform the text file to the desired numpy arrays and then convert them to tensors. However, you would still need to know what the target .pt is supposed to contain as e.g. strings are not a valid PyTorch dtype.