# How pretrained models are trained?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-pretrained-models-are-trained%2F1343%3E%5C
**Category:** Beginners\
**Created:** [October 2, 2020, 7:06am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-pretrained-models-are-trained%2F1343 "2020-10-02T07:06:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![al31415](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/al31415/32/399_2.png) [@al31415](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fal31415)%5C
**Post date:** [October 2, 2020, 7:06am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-pretrained-models-are-trained%2F1343%2F1 "2020-10-02T07:06:40Z")

</div>

Hello,

How pre-trained are obtained?  
In the library there is always some pre-trained model downloaded from the server, but how is it originally trained? Is it also trained using transformers library?

---

<div class="post-metadata">

**Author:** ![BramVanroy](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/bramvanroy/32/47360_2.png) [@BramVanroy](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FBramVanroy)%5C
**Post date:** [October 2, 2020, 8:10am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-pretrained-models-are-trained%2F1343%2F2 "2020-10-02T08:10:54Z")

</div>

In most if not all built-in cases (e.g. `bert-base-cased`), the original paper implementations are _ported_ to the `transformers` architecture. (you can have a look at conversion scripts, e.g. [https://github.com/huggingface/transformers/blob/77cd0e13d2d09f60d2f6d8fb8b08f493d7ca51fe/src/transformers/convert\_pytorch\_checkpoint\_to\_tf2.py](https://github.com/huggingface/transformers/blob/77cd0e13d2d09f60d2f6d8fb8b08f493d7ca51fe/src/transformers/convert_pytorch_checkpoint_to_tf2.py), [https://github.com/huggingface/transformers/blob/d155b38d6ea70fef3dec2e1f678269e713672bb7/src/transformers/commands/convert.py](https://github.com/huggingface/transformers/blob/d155b38d6ea70fef3dec2e1f678269e713672bb7/src/transformers/commands/convert.py))

User models (e.g. `username/mymodel-uncased`) may have been trained in other ways or ported to the `transformers` architecture manually, with custom scripts, or they are trained by using the `transformers` library directly.

---

<div class="post-metadata">

**Author:** ![al31415](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/al31415/32/399_2.png) [@al31415](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fal31415)%5C
**Post date:** [October 2, 2020, 8:14am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-pretrained-models-are-trained%2F1343%2F3 "2020-10-02T08:14:34Z")

</div>

Thanks for reply.  
How can I train my own model from scratch using transformers?

---

<div class="post-metadata">

**Author:** ![BramVanroy](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/bramvanroy/32/47360_2.png) [@BramVanroy](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FBramVanroy)%5C
**Post date:** [October 2, 2020, 8:30am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-pretrained-models-are-trained%2F1343%2F4 "2020-10-02T08:30:48Z")

</div>

You can have a look here: [https://colab.research.google.com/github/huggingface/blog/blob/master/notebooks/01\_how\_to\_train.ipynb](https://colab.research.google.com/github/huggingface/blog/blob/master/notebooks/01_how_to_train.ipynb)
