How to output a vector
How to use BertModel to output a word's vector which like a vector in word2vec?
Hi, you can use the BertModel to give you the encoded representation of the word ids you have as input. The tensor output by the model’s last layer (of dimension `(batch_size, sequence_length, 768)` for the BertModel) can be considered as the BERT-encoded representation of your input and then be used as input for a downstream task. Is this what you were looking for?<|||||>I want to get the word embedding.
Is the following code correct?
    model = BertModel.from_pretrained('ms')
    embedding = model.embeddings.word_embeddings
‘ms’ is my pretrained bert model path<|||||>Yes, that works!<|||||>thanks!