-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract Contextual Word Embeddings #151
base: master
Are you sure you want to change the base?
Conversation
Add extract_features.py script
Hello, i write corpus.txt 1 sentence. When i run |
@3NFBAGDU Thanks for pointing this out. |
remove pooled vector from the output
Hi, thank you for answering. as i have tested it, Euclidean distance is better than cosine distance for words. And do you have any idea how to get sentence_embedding vector from here? |
Thanks for sharing the results. Please note that some word are the padding tokens (actually most of them), so you should ignore them in the pooling strategy and perform the pooling with only real tokens. |
Hi, if i give 'Hello, how are you', there should be this output: |
Apparently, when giving the sentence |
estimator.predict() works to slowly. I want to predict some text in my model in every 2 seconds. Everytime I call the estimator.predict() function, it loads the model all over again. I want to load the model just once and after that use estimator.predict() every 2 seconds on this same model to get the faster prediction. Can you help me ? |
Hi @zihangdai @kimiyoung , since issue #39 was closed, can you please merge this to master? |
@Hazoom Hi sir, How to modify vector dimensions? |
Hi Hazoom, |
No, it can be run on CPU as well, just a little bit slower than GPU. |
Thank you, Hazoom. I use tensorflow v1.15. Is it the tensorflow version you used? |
I used Tensorflow v1.14, but it should be the same, I hope. |
It seems that I don't get the expected results. I copied some messages below. Could you please take a look and let me know what the problem is? 2020-02-16 15:03:13.502591: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA |
Hi Hazoom, |
Add the ability to extract contextual word embeddings from a given list of sentences using XLNet, same like in BERT.
The script extracts a fixed length vector for each token in the sentence.
First, one needs to create an input text file as following:
After that, the script
extract_features.py
can be used like this, which will create vectors of length 64 for each token in the sentence:Or use the
scripts/gpu_extract_features.sh
script for running it easily.This will create a JSON file (one line per line of input) containing the contextual word embeddings from XLNet.
#39
Hi @zihangdai @kimiyoung, can you please take a look?