Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Reduce model size when using Bert Embedder #2897

Closed
faizan30 opened this issue May 28, 2019 · 3 comments
Closed

Reduce model size when using Bert Embedder #2897

faizan30 opened this issue May 28, 2019 · 3 comments

Comments

@faizan30
Copy link

System (please complete the following information):

  • OS: Linux
  • Python version: 3.7.1
  • AllenNLP version: 0.8.3

Question

  • I'm working on a text classification task and I'm using PretrainedBertEmbedder. The size of classification model is over 400Mb. How can I reduce the model size while still using Bert?

Token embedder:

"token_embedders": {
"bert": {
"type": "bert-pretrained",
"pretrained_model": "bert-base-uncased",
"top_layer_only": true
}
}

Token Indexer:
"token_indexers": {
"bert": {
"type": "bert-pretrained",
"pretrained_model": ".pretrained/bert/bert-base-uncased.tar.gz",
"do_lowercase": true,
"max_pieces": 100
}
}

@faizan30 faizan30 changed the title Reduce model size using Bert Embedder Reduce model size when using Bert Embedder May 29, 2019
@kernelmachine
Copy link
Contributor

I don't think you can reduce the model size beyond your classifier's parameters, unless you retrain a smaller BERT. If you need more efficient training, some tricks like mixed precision training (#2149) and gradient accumulation are in the works (#2721)

@faizan30
Copy link
Author

Are BERT embeddings being saved as part of weights file? If yes is there a way to seperate my model weights and bert weights?

@faizan30
Copy link
Author

Thanks for the response @kernelmachine .

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

No branches or pull requests

2 participants