Skip to content
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

Example script for downstream task #3

Open
pribadihcr opened this issue Sep 10, 2020 · 3 comments
Open

Example script for downstream task #3

pribadihcr opened this issue Sep 10, 2020 · 3 comments
Assignees

Comments

@pribadihcr
Copy link

hi @timoschick,

Any plan to provide example code for the downstream tasks mentioned in the paper. Thanks.

@timoschick
Copy link
Owner

Hi @pribadihcr, yes, we definitely plan to release the example code. However, the code is still kind of messy and I am really busy right now so it might take a few weeks :(

@timoschick timoschick self-assigned this Sep 11, 2020
@pribadihcr
Copy link
Author

Hi @timoschick,

Could you give me some hint the classification task's procedure?.
e.g how to use bertram pretrained etc

@timoschick
Copy link
Owner

Sure, this is relatively straightforward. You can start from any of the examples found here, or you can use any other script that uses HuggingFace's Transformers for any downstream task. Before training/evaluating, you just need to load the BERTRAM model corresponding to the pretrained model used in the script and call:

 bertram.add_word_vectors_to_model(words_with_contexts, tokenizer, model)

where bertram is your BERTRAM model, tokenizer and model are the tokenizer and model used in your training/evaluation script, and words_with_contexts is a dictionary from rare words to a list of contexts in which they occur. For each rare word w, this will add a new token <BERTRAM:w> to the model's (and tokenizer's) embedding space. When processing examples for training/evaluation, you then simply need to replace each occurrence of a rare word w with <BERTRAM:w> (or with <BERTRAM:w> / w if you wish to use the "slash"-variant described in the paper).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants