# Customize pretrained model for model hub

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcustomize-pretrained-model-for-model-hub%2F6419%3E%5C
**Category:** Models\
**Created:** [May 27, 2021, 1:42pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcustomize-pretrained-model-for-model-hub%2F6419 "2021-05-27T13:42:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthieu](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/matthieu/32/3295_2.png) [@Matthieu](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FMatthieu)%5C
**Post date:** [May 27, 2021, 1:42pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcustomize-pretrained-model-for-model-hub%2F6419%2F1 "2021-05-27T13:42:02Z")

</div>

Hi community,

I would like to add mean pooling step inside a custom `SentenceTransformer` class derived from the model `sentence-transformers/stsb-xlm-r-multilingual`, in order to avoid to do this supplementary step after getting the tokens embeddings.

My aim is to push this custom model onto model hub. If not using this custom step, it is trivial as below:

from transformers import AutoTokenizer, AutoModel

#### Simple export

```
## Instanciate the model
model_name = "sentence-transformers/stsb-xlm-r-multilingual"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModel.from_pretrained(model_name)

## Save the model and tokenizer files into cloned repository
model.save_pretrained("path/to/repo/clone/your-model-name")
tokenizer.save_pretrained("path/to/repo/clone/your-model-name")

```

However, after defining my custom class `SentenceTransformerCustom` I can’t manage to push on model hub the definition of this class. Do I need to place this custom class definition inside a specific .py file ? Or is there anything to do in order to correctly import this custom class from model hub?

Thanks!
