As you know, there are several pre-trained models that we can use to extract word embeddings.
As an example, I can use the following codes to retrieve word2vec features of my text:
import gensim
from gensim.models import Word2Vec
word2vec_model = gensim.models.KeyedVectors.load_word2vec_format('./data/word_embeddings/GoogleNews-vectors-negative300.bin', binary=True)
def retrieve_word2vec(word):
return word2vec_model.wv[word]
Currently, I am interested to extract word features using pre-trained transformer-XL models. Is there any sample code to understand how to do that? (I couldn't find something useful by myself).
Thanks in advance