# .pt PyTorch Model -\>PreTrainedModel

**URL:** <https://discuss.huggingface.co/t/pt-pytorch-model-pretrainedmodel/35423>\
**Category:** Beginners\
**Created:** [April 3, 2023, 3:53pm UTC](https://discuss.huggingface.co/t/pt-pytorch-model-pretrainedmodel/35423 "2023-04-03T15:53:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kbmmoran](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@kbmmoran](https://discuss.huggingface.co/u/kbmmoran)\
**Post date:** [April 3, 2023, 3:53pm UTC](https://discuss.huggingface.co/t/pt-pytorch-model-pretrainedmodel/35423/1 "2023-04-03T15:53:29Z")

</div>

Similar to ([How can I share a pytorch saved model on huggingFace hub](https://discuss.huggingface.co/t/how-can-i-share-a-pytorch-saved-model-on-huggingface-hub/17523)), I am attempting to convert/utilize a PyTorch model with the .pt extension with Huggingface.

I have been reading through the docs on the ‘PreTrainedModel’ class, but have Not found a one-for-one solution. The model is a GPT based on this repository ([GitHub - karpathy/nanoGPT: The simplest, fastest repository for training/finetuning medium-sized GPTs.](https://github.com/karpathy/nanoGPT)).

---

<div class="post-metadata">

**Author:** ![sgugger](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sgugger/32/2291_2.png) [@sgugger](https://discuss.huggingface.co/u/sgugger)\
**Post date:** [April 3, 2023, 5:29pm UTC](https://discuss.huggingface.co/t/pt-pytorch-model-pretrainedmodel/35423/2 "2023-04-03T17:29:02Z")

</div>

You can’t use model written in other libraries inside Transformers.

---

<div class="post-metadata">

**Author:** ![kbmmoran](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@kbmmoran](https://discuss.huggingface.co/u/kbmmoran)\
**Post date:** [April 3, 2023, 5:45pm UTC](https://discuss.huggingface.co/t/pt-pytorch-model-pretrainedmodel/35423/3 "2023-04-03T17:45:54Z")

</div>

Ah okay, thank you !

---

<div class="post-metadata">

**Author:** ![eigenfelix](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/eigenfelix/32/24694_2.png) [@eigenfelix](https://discuss.huggingface.co/u/eigenfelix)\
**Post date:** [May 1, 2024, 10:47am UTC](https://discuss.huggingface.co/t/pt-pytorch-model-pretrainedmodel/35423/4 "2024-05-01T10:47:08Z")

</div>

But is there no way to convert at all?

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](https://discuss.huggingface.co/u/nielsr)\
**Post date:** [May 1, 2024, 1:05pm UTC](https://discuss.huggingface.co/t/pt-pytorch-model-pretrainedmodel/35423/5 "2024-05-01T13:05:06Z")

</div>

Technically you can convert models to the Transformers format, if the model exists in the Transformers library and all parameters can be converted.

e.g. to convert llama from the original repository to the Transformers format =\> [transformers/src/transformers/models/llama/convert\_llama\_weights\_to\_hf.py at main · huggingface/transformers · GitHub](https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/convert_llama_weights_to_hf.py). Each model folder in the Transformers library has this so-called conversion script to convert weights from the original format to the Transformers format.
