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

Add conversion of lm_finetuned to HF transformers #290

Merged
merged 2 commits into from Mar 24, 2020

Conversation

brandenchan
Copy link
Contributor

This allows for models that have been lm finetuned in FARM to be converted to a HuggingFace Transformers model

@brandenchan brandenchan requested a review from tholor March 23, 2020 15:29
ph_state_dict["transform.dense.bias"] = ph_state_dict.pop("dense.bias")
ph_state_dict["transform.LayerNorm.weight"] = ph_state_dict.pop("LayerNorm.weight")
ph_state_dict["transform.LayerNorm.bias"] = ph_state_dict.pop("LayerNorm.bias")
transformers_model.cls.predictions.load_state_dict(ph_state_dict)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are converting here to a model with an MLM head but no NSP. AutoModelForPreTraining would give you a transformers model with both. I think for now we can keep it like this, as NSP is not that popular anymore these days and the FARM models might also only have the MLM head. However, please log an info message here like: "Converted to Transformer's 'AutoModelWithLMHead' with an MLM head only. No next sentence prediction head!"

@brandenchan brandenchan merged commit 17c6731 into master Mar 24, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants