Would share more details for using BERT?
ybdesire opened this issue · 3 comments
Would you share more detailed steps for using BERT as word embedding ?
It seems bert has not been suppoted ?
https://github.com/allanj/pytorch_lstmcrf/blob/master/trainer.py#L56
Since I'm actually working/debugging on another version (in another branch) that uses BERT (from Huggingface) as a direct encoder which allows us to fine-tune BERT, I did not provide more details on using BERT as static embedding.
The quick answer I will give is to use the BERT As Service repo: https://github.com/hanxiao/bert-as-service
You can extract the representations for your sentence and save them using pickle.
One thing you should keep in mind is the BERT-As-Service package gives you workpiece token representation instead of the word representation.
You have three options:
- Use the first workpiece representation of a word to represent the word
- Use the last workpiece representation of a word to represent the word
- Use the average workpiece representation of a word to represent the word
Since you have such a requirement, I will try to provide the script later on as well.