# Error in Question answering comput\_metrics

**URL:** <https://discuss.huggingface.co/t/error-in-question-answering-comput-metrics/126616>\
**Category:** 🤗Transformers\
**Created:** [November 21, 2024, 7:08pm UTC](https://discuss.huggingface.co/t/error-in-question-answering-comput-metrics/126616 "2024-11-21T19:08:40Z")\
**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:** [November 21, 2024, 7:08pm UTC](https://discuss.huggingface.co/t/error-in-question-answering-comput-metrics/126616/1 "2024-11-21T19:08:40Z")

</div>

i tried to provide a compute\_metrics for Trainer, but an error occurred during training

```auto
IndexError Traceback (most recent call last)
<ipython-input-59-73000f671fc2> in <cell line: 12>()
     10 )
     11 
---> 12 trainer.train()

12 frames
/usr/local/lib/python3.10/dist-packages/datasets/utils/py_utils.py in <genexpr>(.0)
    324 for key in unique_values(itertools.chain(*dicts)): # set merge all keys
    325 # Will raise KeyError if the dict don't have the same keys
--> 326 yield key, tuple(d[key] for d in dicts)
    327 
    328 

IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

```

```auto
from transformers import EvalPrediction
def compute_metrics(p: EvalPrediction):
    metric = evaluate.load( "squad_v2" )
    return metric.compute(predictions=p.predictions, references=p.label_ids)

```
