How to use spacy word vectors in torchtext

spacy provides german word vectors spacy model de, so I want to make use of them with pytorch and torchtext.

word_vectors = torch.FloatTensor(spacy_de.vocab.vectors.data)
emb = nn.Embedding.from_pretrained(word_vectors)
TEXT = data.Field(tokenize=tokenize,lower=True)
TEXT.build_vocab(vocab,vectors=word_vectors)

However when i try to build TEXT.build_vocab I get the following error message:

ValueError: Got input vectors of type <class 'torch.Tensor'>, expected str or Vectors object

So i looked Vector up in the torchtext documentation torchtext vectors and it seems I need to load them first. Is there a solution where I do not have to save the spacy word vectors to a file first? And if not, what is the correct way to save spacy word vectors that later I can load them ?

wondering, whether have you tried loading vectors directly instead of converting into tensors?

No this this does not work because spacy word vectors are of type spacy.vectors.Vectors which is a different class than torchtext’s Vector class