# Inference API - Sub-words display for Token Classification

**URL:** <https://discuss.huggingface.co/t/inference-api-sub-words-display-for-token-classification/44502>\
**Category:** 🤗Hub\
**Created:** [June 25, 2023, 6:15pm UTC](https://discuss.huggingface.co/t/inference-api-sub-words-display-for-token-classification/44502 "2023-06-25T18:15:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AkimfromParis](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/akimfromparis/32/27209_2.png) [@AkimfromParis](https://discuss.huggingface.co/u/AkimfromParis)\
**Post date:** [June 25, 2023, 6:15pm UTC](https://discuss.huggingface.co/t/inference-api-sub-words-display-for-token-classification/44502/1 "2023-06-25T18:15:40Z")

</div>

Hello everyone,

I am following the great notebook about Token Classification on BERT made by Hugging Face @nielsr

> **[Google Colaboratory](https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/BERT/Custom_Named_Entity_Recognition_with_BERT_only_first_wordpiece.ipynb)**

It’s working perfectly fine. The WordPiece tokenizer seems good with sub-works ## and -100. Similarly, the local inference at the end is good between sentences and predictions with IOB labels.

My only change is in the variable names. : )

label2id = {k: v for v, k in enumerate(data.Tag.unique())}  
id2label = {v: k for v, k in enumerate(data.Tag.unique())}  
label2id

Unfortunately, when I upload the model on the Hub and I test via the Host inference API, the labels are making mistakes on the entity cut in subwords. It’s cut without merging the subwords…

to take the example of Niels:

[CLS] -100  
za 3  
##hee -100  
##r -100  
khan 8  
was 0  
mar 0

I got the following labels…

Za (Per) hee (Per) r (Per) Khan (Per) was mar

Do you have any idea? Thank you in advance guys!

Akim
