Transformers: How to train from scratch

Created on 3 Nov 2019  路  4Comments  路  Source: huggingface/transformers

I would like to train the model from scratch.
How can I drop the trained weight? using the same architecture for Gpt2

Most helpful comment

If you want to randomly initialize a model simply initialize it via its constructor rather than from the from_pretrained method:

from transformers import GPT2Config, GPT2Model

config = GPT2Config()  # define your configuration here
model = GPT2Model(config)  # Initialize your model from your config

All 4 comments

If you want to randomly initialize a model simply initialize it via its constructor rather than from the from_pretrained method:

from transformers import GPT2Config, GPT2Model

config = GPT2Config()  # define your configuration here
model = GPT2Model(config)  # Initialize your model from your config

@LysandreJik Thanks for the input.
I did something like this

    config = GPT2Config(vocab_size)
    model = GPT2Model(config)

Apart from vocab size, I'm keeping everything else to default value how do I make sure that it doesn't have any pre-trained value?

The values are only loaded if your instantiate the model by calling 藡GPT2Model.from_pretrained`, so you鈥檙e fine 馃檪

@rlouf Thanks

Was this page helpful?
0 / 5 - 0 ratings