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.

Albert pretrained weights change across runs.

See original GitHub issue

🐛 Bug

Information

Model I am using (Bert, XLNet …): TFAlbertModel

Language I am using the model on (English, Chinese …): English

The problem arises when using:

  • the official example scripts: (give details below)
  • my own modified scripts: (give details below)
import tensorflow as tf
from transformers import AlbertTokenizer, TFAlbertModel

tokenizer = AlbertTokenizer.from_pretrained('albert-base-v2')
model = TFAlbertModel.from_pretrained('albert-base-v2')
model.summary()

print(len(model.trainable_weights))

print(model.trainable_weights[23])

input_ids = tf.constant(tokenizer.encode("Hello, my dog is cute"))[None, :]

outputs = model(input_ids)

print(outputs[0].shape, outputs[1].shape, len(outputs))
last_hidden_states = outputs[0]

print(last_hidden_states)

The tasks I am working on is:

  • an official GLUE/SQUaD task: (give the name)
  • my own task or dataset: (give details below) Trying to load pre-trained weights

To reproduce

Run the code above two times and you will see that the weights of the model are not the same across the two runs Steps to reproduce the behavior:

  1. Run the code the first time and log the output
  2. Run the code a second time and log the output
  3. Check that the two logs are not the same.

Expected behavior

Since the model is loading pre-trained weights the results should be the same across runs.

Environment info

  • transformers version: 2.11.0
  • Platform: Linux-4.4.0-179-generic-x86_64-with-debian-stretch-sid
  • Python version: 3.6.9
  • PyTorch version (GPU?): 1.4.0 (True)
  • Tensorflow version (GPU?): 2.0.1 (True)
  • Using GPU in script?: Yes
  • Using distributed or parallel set-up in script?: No

I apologize if the issue is due to me misusing your library, first time using Albert.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
LysandreJikcommented, Jun 22, 2020

This should work now, the weights have been changed to use the with-prefix weights.

2reactions
LysandreJikcommented, Jun 6, 2020

Hi, I can reproduce. This is due to the archive maps not being available anymore, and therefore the wrong ALBERT models are linked.

Thanks for raising the issue, this is quite a bug.

cc @julien-c

Read more comments on GitHub >

github_iconTop Results From Across the Web

ALBERT - Hugging Face
The ALBERT model was proposed in ALBERT: A Lite BERT for Self-supervised ... Increasing model size when pretraining natural language representations often ...
Read more >
huggingface-imported ALBERT model doesn't train at all #3013
Issue I'm trying to use huggingface's ALBERT encoder in fairseq, ... Checked the pretrained ALBERT weights are being loaded properly.
Read more >
Fine-tune Albert with Pre-training on Custom Corpus
Run the below command using custom corpus and vocabulary files used/created in Build Vocab step. This step first tokenizes and encodes the ...
Read more >
Fine-Tuning Pretrained Language Models:Weight ... - arXiv
Changing only training data order and the weight initialization of the fine-tuning layer—which contains only 0.0006% of the total number of.
Read more >
Should you switch from BERT to ALBERT? - YouTube
From the summaries you'll find online, it sounds like ALBERT is both faster and more accurate than BERT--so we should probably switch over...
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