# Token Classification Label order

**URL:** <https://discuss.huggingface.co/t/token-classification-label-order/25896>\
**Category:** Intermediate\
**Created:** [November 11, 2022, 1:16am UTC](https://discuss.huggingface.co/t/token-classification-label-order/25896 "2022-11-11T01:16:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lfcc](https://avatars.discourse-cdn.com/v4/letter/l/b5e925/32.png) [@lfcc](https://discuss.huggingface.co/u/lfcc)\
**Post date:** [November 11, 2022, 1:16am UTC](https://discuss.huggingface.co/t/token-classification-label-order/25896/1 "2022-11-11T01:16:29Z")

</div>

Hello,  
I have fine-tuned several BERT models in order to perform NER tasks.  
In order to do so, I basically used a dataset that was annotated in IOB format.

Before using Hugging face with BERT, I was performing the NER task with a BI-LSTM-CRF model implemented in TensorFlow.

With my BILSTM model, I had a recurrent problem with the order of the labels:

```auto
sequence = ["Bruno", "Garcia", "is","a","great","person"]
prediction = ["I-Person","B-Person","O","O","O","O"]

```

As you can see, the labels are wrong and “invalid” since I-Person should always have a B-Person before it.

Using the AutoModelForTokenClassification, the finne tunned model never made that mistake.

So, my question is, how is the AutoModelForTokenClassification avoiding this problem?
