# Convert Pytorch Model to Huggingface Transformer?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fconvert-pytorch-model-to-huggingface-transformer%2F16965%3E%5C
**Category:** 🤗Transformers\
**Created:** [April 19, 2022, 12:11pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fconvert-pytorch-model-to-huggingface-transformer%2F16965 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsophiaaez)%5C
**Post date:** [April 19, 2022, 12:11pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fconvert-pytorch-model-to-huggingface-transformer%2F16965%2F1 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-create-a-config-json-after-saving-a-model%2F10459) )

---

<div class="post-metadata">

**Author:** ![osanseviero](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/osanseviero/32/38738_2.png) [@osanseviero](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fosanseviero)%5C
**Post date:** [April 20, 2022, 6:43pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fconvert-pytorch-model-to-huggingface-transformer%2F16965%2F2 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FKribaat)%5C
**Post date:** [May 2, 2024, 9:24pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fconvert-pytorch-model-to-huggingface-transformer%2F16965%2F3 "2024-05-02T21:24:47Z")

</div>

Very shitty documentation to understand, especially for beginners.
