# Convert Pytorch Model to Huggingface Transformer?

**URL:** <https://discuss.huggingface.co/t/convert-pytorch-model-to-huggingface-transformer/16965>\
**Category:** 🤗Transformers\
**Created:** [April 19, 2022, 12:11pm UTC](https://discuss.huggingface.co/t/convert-pytorch-model-to-huggingface-transformer/16965 "2022-04-19T12:11:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sophiaaez](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sophiaaez/32/4526_2.png) [@sophiaaez](https://discuss.huggingface.co/u/sophiaaez)\
**Post date:** [April 19, 2022, 12:11pm UTC](https://discuss.huggingface.co/t/convert-pytorch-model-to-huggingface-transformer/16965/1 "2022-04-19T12:11:04Z")

</div>

Hi, is it at all possible (and if so, how) to convert a custom and already-trained PyTorch model to a huggingface transformer model?  
My main goal is to get a config.json file from all of this and I cannot refactor the model code, as I cannot train the model from scratch. (As suggested in this post [How to create a config.json after saving a model](https://discuss.huggingface.co/t/how-to-create-a-config-json-after-saving-a-model/10459) )

---

<div class="post-metadata">

**Author:** ![osanseviero](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/osanseviero/32/38738_2.png) [@osanseviero](https://discuss.huggingface.co/u/osanseviero)\
**Post date:** [April 20, 2022, 6:43pm UTC](https://discuss.huggingface.co/t/convert-pytorch-model-to-huggingface-transformer/16965/2 "2022-04-20T18:43:50Z")

</div>

Hey there! You might want to take a look at the following guide, which shows how to share custom configurations, custom models, and share the custom code for others to use.

> **[Sharing custom models](https://huggingface.co/docs/transformers/custom_models#sharing-custom-models)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

<div class="post-metadata">

**Author:** ![Kribaat](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/kribaat/32/26520_2.png) [@Kribaat](https://discuss.huggingface.co/u/Kribaat)\
**Post date:** [May 2, 2024, 9:24pm UTC](https://discuss.huggingface.co/t/convert-pytorch-model-to-huggingface-transformer/16965/3 "2024-05-02T21:24:47Z")

</div>

Very shitty documentation to understand, especially for beginners.
