question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Where I can find official pretrained weights of SOP in Albert and NSP in Bert?

See original GitHub issue

Hi Guys,

I was checking for the pre-trained weights ( 2 layer classifier ) of SOP in Albert and NSP in Bert. Seems like it is initializing randomly every time.

Can we have the official weights loaded here or is it not available from official models? Can anyone clarify please.

Thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
LysandreJikcommented, Aug 11, 2021

Hi @s4sarath, sorry for the delayed response. If the checkpoints on the hub do not satisfy you (I see the SOP/NSP layers are indeed lacking), conversion scripts are available for each model:

I confirm this successfully exports the full model, including the NSP/SOP weights:

ALBERT

wget https://storage.googleapis.com/albert_models/albert_base_v2.tar.gz 
tar -xzf albert_base_v2.tar.gz 
python convert_albert_original_tf_checkpoint_to_pytorch.py --tf_checkpoint_path=albert_base/model.ckpt-best --albert_config_file=albert_base/albert_config.json --pytorch_dump_path=albert_base/pytorch_model.bin
cp albert_base/albert_config.json albert_base/config.json   
>>> from transformers import TFAlbertForPreTraining
>>> model = TFAlbertForPreTraining.from_pretrained("albert_base", from_pt=True)
[...]
All the weights of TFAlbertForPreTraining were initialized from the PyTorch model.
If your task is similar to the task the model of the checkpoint was trained on, you can already use TFAlbertForPreTraining for predictions without further training.

BERT

Same for BERT:

wget https://storage.googleapis.com/bert_models/2018_10_18/uncased_L-12_H-768_A-12.zip
unzip uncased_L-12_H-768_A-12.zip  
python convert_bert_original_tf_checkpoint_to_pytorch.py --tf_checkpoint_path=uncased_L-12_H-768_A-12/bert_model.ckpt --bert_config_file=uncased_L-12_H-768_A-12/bert_config.json --pytorch_dump_path=uncased_L-12_H-768_A-12/pytorch_model.bin
>>> from transformers import TFBertForPreTraining
>>> bert = TFBertForPreTraining.from_pretrained("uncased_L-12_H-768_A-12", from_pt=True)
[...[
All the weights of TFBertForPreTraining were initialized from the PyTorch model.
If your task is similar to the task the model of the checkpoint was trained on, you can already use TFBertForPreTraining for predictions without further training.

Hope that helps.

0reactions
github-actions[bot]commented, Sep 5, 2021

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ALBERT Model for Self-Supervised Learning - Analytics Vidhya
Like BERT, ALBERT was pre-trained on the English Wikipedia and Book CORPUS datasets containing 16 GB of uncompressed data. Due to the parametric ......
Read more >
ALBERT: A Lite BERT for Self-supervised Learning of ...
A new pretraining method that establishes new state-of-the-art results on the GLUE, RACE, and SQuAD benchmarks while having fewer parameters compared to ...
Read more >
BERT: Pre-training of Deep Bidirectional Transformers for ...
In this deep dive of BERT, we explore the powerful NLP model's history, break down the approach and architecture behind the model, and...
Read more >
is SOP(sentence order prediction) implemented? · Issue #2671
I can find NSP(Next Sentence Prediction) implementation from modeling_from src/transformers/modeling_bert.py. Is SOP inherited from here with ...
Read more >
Meet ALBERT: a new 'Lite BERT' from Google & Toyota with ...
Training changes — SOP, or Sentence Order Prediction:​​ ALBERT does use MLM (Masked Language Modeling), just like BERT, using up to 3 word...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found