# Token classification metric

**URL:** <https://discuss.huggingface.co/t/token-classification-metric/110041>\
**Category:** 🤗Transformers\
**Created:** [October 3, 2024, 9:59pm UTC](https://discuss.huggingface.co/t/token-classification-metric/110041 "2024-10-03T21:59:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AbdulrahmanAhmed](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/abdulrahmanahmed/32/32380_2.png) [@AbdulrahmanAhmed](https://discuss.huggingface.co/u/AbdulrahmanAhmed)\
**Post date:** [October 3, 2024, 9:59pm UTC](https://discuss.huggingface.co/t/token-classification-metric/110041/1 "2024-10-03T21:59:29Z")

</div>

i tried to make a token classification task by fine-tuning distilbert and training with tensorflow.  
and I used accuracy as a metric in the compile method.  
i found the loss was decreasing but the accuracy didn’t increase so I realise that accuracy metric is not appropriate for NER tasks I searched and I found that f1-score is a good choose but I got an error  
ValueError Traceback (most recent call last)  
 in \<cell line: 1\>()  
----\> 1 history = model.fit(train\_dataset.take(1) , validation\_data = val\_dataset , epochs = training\_args[“epochs”], callbacks= metric\_callback)

5 frames  
/usr/local/lib/python3.10/dist-packages/evaluate/module.py in add\_batch(self, predictions, references, \*\*kwargs)  
544 f"Input references: {summarize\_if\_long\_list(references)}"  
545 )  
 → 546 raise ValueError(error\_msg) from None  
547  
548 def add(self, \*, prediction=None, reference=None, \*\*kwargs):

ValueError: Predictions and/or references don’t match the expected format.  
Expected format: {‘predictions’: Sequence(feature=Value(dtype=‘string’, id=‘label’), length=-1, id=‘sequence’), ‘references’: Sequence(feature=Value(dtype=‘string’, id=‘label’), length=-1, id=‘sequence’)},

so I need an metric for NER task
