# Change label names on inference API

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fchange-label-names-on-inference-api%2F3063%3E%5C
**Category:** Beginners\
**Created:** [January 5, 2021, 8:12am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fchange-label-names-on-inference-api%2F3063 "2021-01-05T08:12:54Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![lewtun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lewtun/32/30995_2.png) [@lewtun](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Flewtun)%5C
**Post date:** [February 10, 2021, 1:54pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fchange-label-names-on-inference-api%2F3063%2F3 "2021-02-10T13:54:56Z")

</div>

Hey @MoritzLaurer, the way I usually do this is by specifying the `label2id` and `id2label` dictionaries in the model’s config class, e.g. for a text classifier you can do this:

```auto
from transformers import AutoConfig, AutoModelForSequenceClassification

# define the mappings as dictionaries
label2id = ...
id2label = ...
# define model checkpoint - can be the same model that you already have on the hub
model_ckpt = ...
# define config
config = AutoConfig.from_pretrained(model_ckpt, label2id=label2id, id2label=id2label)
# load model with config
model = AutoModelForSequenceClassification.from_pretrained(model_ckpt, config=config)
# export model
model.save_pretrained(target_name_or_path)

```

Then you can push the files to the hub as usual. HTH!

---

_[View the full topic](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fchange-label-names-on-inference-api%2F3063)._
