Minimal example for generating word embeddings #1495
Unanswered
abdullahfurquan
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
In RepresentationModel I was trying to get word embedding. Below is my code snippet and I have taken one sentence- as input. My sentence has 3 word. By default 2 tokens are for [CLS] & [SEP]. So total tokens should be :3+2=5.
But the shape of wordvectors from code is : (1, 6, 768) .So it has 6 word embedding. Now I am little confused ,how do I get the embedding of each word of my sentence (i.e. "dont stop go" ). Is there a way to map word and corresponding embedding
code snippets:-
from simpletransformers.language_representation import RepresentationModel
model = RepresentationModel(
model_type="bert",
model_name="bert-base-uncased",
use_cuda=False
)
sentences=["dont stop go"]
wordvectors = model.encode_sentences(sentences, combine_strategy=None)
wordvectors.shape
(1,6,768)
below is a image of it :

Beta Was this translation helpful? Give feedback.
All reactions