Create a transformer model from a pytorch model (model.bin))
How to go from a model created from Bert and trained in a specific domain stored as model.bin to generate a transformer, tokenizer, model and optimizer??Sorry if it is very easy but I’m getting crazy!!!ck=torch.load(’/content/drive/MyDrive/saved_models/pytorch_model.bin’)print(ck.keys())odict_keys([‘bert.embeddings.word_embeddings.weight’, ‘bert.embeddings.position_embeddings.weight’, ‘bert.embeddings.token_type_embeddings.weight’, ‘bert.embeddings.LayerNorm.weight’, ‘bert.embeddings.LayerNorm.bias’, ‘bert.encoder.layer.0.attention.self.query.weight’, ‘bert.encoder.layer.0.attention.self.query.bias’, ‘bert.encoder.layer.0.attention.self.key.weight’, ‘bert.encoder.layer.0.attention.self.key.bias’, ‘bert.encoder.layer.0.attention.self.value.weight’, ‘bert.encoder.layer.0.attention.self.value.bias’, ‘bert.encoder.layer.0.attention.output.dense.weight’, ‘bert.encoder.layer.0.attention.output.dense.bias’, ‘bert.encoder.layer.0.attention.output.LayerNorm.weight’, ‘bert.encoder.layer.0.attention.output.LayerNorm.bias’, ‘bert.encoder.layer.0.intermediate.dense.weight’, ‘bert.encoder.layer.0.intermediate.dense.bias’, ‘bert.encoder.layer.0.output.dense.weight’, ‘bert.encoder.layer.0.output.dense.bias’, ‘bert.encoder.layer.0.output.LayerNorm.weight’, ‘bert.encoder.layer.0.output.LayerNorm.bias’, ‘bert.encoder.layer.1.attention.self.query.weight’, ‘bert.encoder.layer.1.attention.self.query.bias’, ‘bert.encoder.layer.1.attention.self.key.weight’, ‘bert.encoder.layer.1.attention.self.key.bias’, ‘bert.encoder.layer.1.attention.self.value.weight’, ‘bert.encoder.layer.1.attention.self.value.bias’, ‘bert.encoder.layer.1.attention.output.dense.weight’, ‘bert.encoder.layer.1.attention.output.dense.bias’, ‘bert.encoder.layer.1.attention.output.LayerNorm.weight’, ‘bert.encoder.layer.1.attention.output.LayerNorm.bias’, ‘bert.encoder.layer.1.intermediate.dense.weight’, ‘bert.encoder.layer.1.intermediate.dense.bias’, ‘bert.encoder.layer.1.output.dense.weight’, ‘bert.encoder.layer.1.output.dense.bias’, ‘bert.encoder.layer.1.output.LayerNorm.weight’, ‘bert.encoder.layer.1.output.LayerNorm.bias’, ‘bert.encoder.layer.2.attention.self.query.weight’, ‘bert.encoder.layer.2.attention.self.query.bias’, ‘bert.encoder.layer.2.attention.self.key.weight’, ‘bert.encoder.layer.2.attention.self.key.bias’, ‘bert.encoder.layer.2.attention.self.value.weight’, ‘bert.encoder.layer.2.attention.self.value.bias’, ‘bert.encoder.layer.2.attention.output.dense.weight’, ‘bert.encoder.layer.2.attention.output.dense.bias’, ‘bert.encoder.layer.2.attention.output.LayerNorm.weight’, ‘bert.encoder.layer.2.attention.output.LayerNorm.bias’, ‘bert.encoder.layer.2.intermediate.dense.weight’, ‘bert.encoder.layer.2.intermediate.dense.bias’, ‘bert.encoder.layer.2.output.dense.weight’, ‘bert.encoder.layer.2.output.dense.bias’, ‘bert.encoder.layer.2.output.LayerNorm.weight’, ‘bert.encoder.layer.2.output.LayerNorm.bias’, ‘bert.encoder.layer.3.attention.self.query.weight’, ‘bert.encoder.layer.3.attention.self.query.bias’, ‘bert.encoder.layer.3.attention.self.key.weight’, ‘bert.encoder.layer.3.attention.self.key.bias’, ‘bert.encoder.layer.3.attention.self.value.weight’, ‘bert.encoder.layer.3.attention.self.value.bias’, ‘bert.encoder.layer.3.attention.output.dense.weight’, ‘bert.encoder.layer.3.attention.output.dense.bias’, ‘bert.encoder.layer.3.attention.output.LayerNorm.weight’, ‘bert.encoder.layer.3.attention.output.LayerNorm.bias’, ‘bert.encoder.layer.3.intermediate.dense.weight’, ‘bert.encoder.layer.3.intermediate.dense.bias’, ‘bert.encoder.layer.3.output.dense.weight’, ‘bert.encoder.layer.3.output.dense.bias’, ‘bert.encoder.layer.3.output.LayerNorm.weight’, ‘bert.encoder.layer.3.output.LayerNorm.bias’, ‘bert.encoder.layer.4.attention.self.query.weight’, ‘bert.encoder.layer.4.attention.self.query.bias’, ‘bert.encoder.layer.4.attention.self.key.weight’, ‘bert.encoder.layer.4.attention.self.key.bias’, ‘bert.encoder.layer.4.attention.self.value.weight’, ‘bert.encoder.layer.4.attention.self.value.bias’, ‘bert.encoder.layer.4.attention.output.dense.weight’, ‘bert.encoder.layer.4.attention.output.dense.bias’, ‘bert.encoder.layer.4.attention.output.LayerNorm.weight’, ‘bert.encoder.layer.4.attention.output.LayerNorm.bias’, ‘bert.encoder.layer.4.intermediate.dense.weight’, ‘bert.encoder.layer.4.intermediate.dense.bias’, ‘bert.encoder.layer.4.output.dense.weight’, ‘bert.encoder.layer.4.output.dense.bias’, ‘bert.encoder.layer.4.output.LayerNorm.weight’, ‘bert.encoder.layer.4.output.LayerNorm.bias’, ‘bert.encoder.layer.5.attention.self.query.weight’, ‘bert.encoder.layer.5.attention.self.query.bias’, ‘bert.encoder.layer.5.attention.self.key.weight’, ‘bert.encoder.layer.5.attention.self.key.bias’, ‘bert.encoder.layer.5.attention.self.value.weight’, ‘bert.encoder.layer.5.attention.self.value.bias’, ‘bert.encoder.layer.5.attention.output.dense.weight’, ‘bert.encoder.layer.5.attention.output.dense.bias’, ‘bert.encoder.layer.5.attention.output.LayerNorm.weight’, ‘bert.encoder.layer.5.attention.output.LayerNorm.bias’, ‘bert.encoder.layer.5.intermediate.dense.weight’, ‘bert.encoder.layer.5.intermediate.dense.bias’, ‘bert.encoder.layer.5.output.dense.weight’, ‘bert.encoder.layer.5.output.dense.bias’, ‘bert.encoder.layer.5.output.LayerNorm.weight’, ‘bert.encoder.layer.5.output.LayerNorm.bias’, ‘bert.encoder.layer.6.attention.self.query.weight’, ‘bert.encoder.layer.6.attention.self.query.bias’, ‘bert.encoder.layer.6.attention.self.key.weight’, ‘bert.encoder.layer.6.attention.self.key.bias’, ‘bert.encoder.layer.6.attention.self.value.weight’, ‘bert.encoder.layer.6.attention.self.value.bias’, ‘bert.encoder.layer.6.attention.output.dense.weight’, ‘bert.encoder.layer.6.attention.output.dense.bias’, ‘bert.encoder.layer.6.attention.output.LayerNorm.weight’, ‘bert.encoder.layer.6.attention.output.LayerNorm.bias’, ‘bert.encoder.layer.6.intermediate.dense.weight’, ‘bert.encoder.layer.6.intermediate.dense.bias’, ‘bert.encoder.layer.6.output.dense.weight’, ‘bert.encoder.layer.6.output.dense.bias’, ‘bert.encoder.layer.6.output.LayerNorm.weight’, ‘bert.encoder.layer.6.output.LayerNorm.bias’, ‘bert.encoder.layer.7.attention.self.query.weight’, ‘bert.encoder.layer.7.attention.self.query.bias’, ‘bert.encoder.layer.7.attention.self.key.weight’, ‘bert.encoder.layer.7.attention.self.key.bias’, ‘bert.encoder.layer.7.attention.self.value.weight’, ‘bert.encoder.layer.7.attention.self.value.bias’, ‘bert.encoder.layer.7.attention.output.dense.weight’, ‘bert.encoder.layer.7.attention.output.dense.bias’, ‘bert.encoder.layer.7.attention.output.LayerNorm.weight’, ‘bert.encoder.layer.7.attention.output.LayerNorm.bias’, ‘bert.encoder.layer.7.intermediate.dense.weight’, ‘bert.encoder.layer.7.intermediate.dense.bias’, ‘bert.encoder.layer.7.output.dense.weight’, ‘bert.encoder.layer.7.output.dense.bias’, ‘bert.encoder.layer.7.output.LayerNorm.weight’, ‘bert.encoder.layer.7.output.LayerNorm.bias’, ‘bert.encoder.layer.8.attention.self.query.weight’, ‘bert.encoder.layer.8.attention.self.query.bias’, ‘bert.encoder.layer.8.attention.self.key.weight’, ‘bert.encoder.layer.8.attention.self.key.bias’, ‘bert.encoder.layer.8.attention.self.value.weight’, ‘bert.encoder.layer.8.attention.self.value.bias’, ‘bert.encoder.layer.8.attention.output.dense.weight’, ‘bert.encoder.layer.8.attention.output.dense.bias’, ‘bert.encoder.layer.8.attention.output.LayerNorm.weight’, ‘bert.encoder.layer.8.attention.output.LayerNorm.bias’, ‘bert.encoder.layer.8.intermediate.dense.weight’, ‘bert.encoder.layer.8.intermediate.dense.bias’, ‘bert.encoder.layer.8.output.dense.weight’, ‘bert.encoder.layer.8.output.dense.bias’, ‘bert.encoder.layer.8.output.LayerNorm.weight’, ‘bert.encoder.layer.8.output.LayerNorm.bias’, ‘bert.encoder.layer.9.attention.self.query.weight’, ‘bert.encoder.layer.9.attention.self.query.bias’, ‘bert.encoder.layer.9.attention.self.key.weight’, ‘bert.encoder.layer.9.attention.self.key.bias’, ‘bert.encoder.layer.9.attention.self.value.weight’, ‘bert.encoder.layer.9.attention.self.value.bias’, ‘bert.encoder.layer.9.attention.output.dense.weight’, ‘bert.encoder.layer.9.attention.output.dense.bias’, ‘bert.encoder.layer.9.attention.output.LayerNorm.weight’, ‘bert.encoder.layer.9.attention.output.LayerNorm.bias’, ‘bert.encoder.layer.9.intermediate.dense.weight’, ‘bert.encoder.layer.9.intermediate.dense.bias’, ‘bert.encoder.layer.9.output.dense.weight’, ‘bert.encoder.layer.9.output.dense.bias’, ‘bert.encoder.layer.9.output.LayerNorm.weight’, ‘bert.encoder.layer.9.output.LayerNorm.bias’, ‘bert.encoder.layer.10.attention.self.query.weight’, ‘bert.encoder.layer.10.attention.self.query.bias’, ‘bert.encoder.layer.10.attention.self.key.weight’, ‘bert.encoder.layer.10.attention.self.key.bias’, ‘bert.encoder.layer.10.attention.self.value.weight’, ‘bert.encoder.layer.10.attention.self.value.bias’, ‘bert.encoder.layer.10.attention.output.dense.weight’, ‘bert.encoder.layer.10.attention.output.dense.bias’, ‘bert.encoder.layer.10.attention.output.LayerNorm.weight’, ‘bert.encoder.layer.10.attention.output.LayerNorm.bias’, ‘bert.encoder.layer.10.intermediate.dense.weight’, ‘bert.encoder.layer.10.intermediate.dense.bias’, ‘bert.encoder.layer.10.output.dense.weight’, ‘bert.encoder.layer.10.output.dense.bias’, ‘bert.encoder.layer.10.output.LayerNorm.weight’, ‘bert.encoder.layer.10.output.LayerNorm.bias’, ‘bert.encoder.layer.11.attention.self.query.weight’, ‘bert.encoder.layer.11.attention.self.query.bias’, ‘bert.encoder.layer.11.attention.self.key.weight’, ‘bert.encoder.layer.11.attention.self.key.bias’, ‘bert.encoder.layer.11.attention.self.value.weight’, ‘bert.encoder.layer.11.attention.self.value.bias’, ‘bert.encoder.layer.11.attention.output.dense.weight’, ‘bert.encoder.layer.11.attention.output.dense.bias’, ‘bert.encoder.layer.11.attention.output.LayerNorm.weight’, ‘bert.encoder.layer.11.attention.output.LayerNorm.bias’, ‘bert.encoder.layer.11.intermediate.dense.weight’, ‘bert.encoder.layer.11.intermediate.dense.bias’, ‘bert.encoder.layer.11.output.dense.weight’, ‘bert.encoder.layer.11.output.dense.bias’, ‘bert.encoder.layer.11.output.LayerNorm.weight’, ‘bert.encoder.layer.11.output.LayerNorm.bias’, ‘bert.pooler.dense.weight’, ‘bert.pooler.dense.bias’, ‘cls.predictions.bias’, ‘cls.predictions.transform.dense.weight’, ‘cls.predictions.transform.dense.bias’, ‘cls.predictions.transform.LayerNorm.weight’, ‘cls.predictions.transform.LayerNorm.bias’, ‘cls.predictions.decoder.weight’, ‘cls.seq_relationship.weight’, ‘cls.seq_relationship.bias’])Thanks a lot
2021-01-19T05:48:42Z
Not sure what you mean could please rephrase the question?What do you mean bygenerate a transformer, tokenizer, model and optimizer
2021-01-19T08:27:45Z
Hi valhallaI found a bert language model , model.bin (I posted) and I would like to use it with the transfome libray for after training in QA squad mode. This bert language model is focus in finance domain.sorry for my explanation, I’m starting to do some things in nlpThanks a lot for the reply!!!
2021-01-20T07:58:00Z
Is it atransformersmodel ? if yes you should be able to load the model using thefrom_pretrainedmethod. Same for tokenizer.To fine-tune the model for qa, you could use therun_qa.pyscript from heretransformers/examples/question-answering at master · huggingface/transformers · GitHub
2021-01-20T08:58:01Z
Hiit isn’t a transformer model, I don’t have the tokenizer, I have the file model with the extension bin that contains that I send in my at the begging a file with a sorted dicionary where you can find the layers, weithgs, …With only that file, can I do something to use the hugginf faces modules (classes) and script’s to get the tokenizer, … and after use the script that you recomend to me??Thanks a lot for your replies and time!!!Regards