Repository: open-compass/opencompass
Issue: [Bug] 评测Lawbench数据集时，分数会出现-0的情况
Root cause: Algorithmic Error

### Prerequisite

- [X] I have searched [Issues](https://github.com/open-compass/opencompass/issues/) and [Discussions](https://github.com/open-compass/opencompass/discussions) but cannot get the expected help.
- [X] The bug has not been fixed in the [latest version](https://github.com/open-compass/opencompass).

### Type

I'm evaluating with the officially supported tasks/models/datasets.

### Environment

{'CUDA available': False,
 'GCC': 'Homebrew clang version 18.1.7',
 'MMEngine': '0.10.3',
 'MUSA available': False,
 'OpenCV': '4.9.0',
 'PyTorch': '2.2.1',
 'PyTorch compiling details': 'PyTorch built with:\n'
                              '  - GCC 4.2\n'
                              '  - C++ Version: 201703\n'
                              '  - clang 13.1.6\n'
                              '  - Intel(R) oneAPI Math Kernel Library Version '
                              '2022.2-Product Build 20220801 for Intel(R) 64 '
                              'architecture applications\n'
                              '  - Intel(R) MKL-DNN v3.3.2 (Git Hash '
                              '2dc95a2ad0841e29db8b22fbccaf3e5da7992b01)\n'
                              '  - OpenMP 201811\n'
                              '  - LAPACK is enabled (usually provided by '
                              'MKL)\n'
                              '  - NNPACK is enabled\n'
                              '  - CPU capability usage: AVX2\n'
                              '  - Build settings: BLAS_INFO=mkl, '
                              'BUILD_TYPE=Release, '
                              'CXX_COMPILER=/Applications/Xcode_13.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++, '
                              'CXX_FLAGS= -fvisibility-inlines-hidden '
                              '-DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO '
                              '-DLIBKINETO_NOCUPTI -DLIBKINETO_NOROCTRACER '
                              '-DUSE_FBGEMM -DUSE_QNNPACK '
                              '-DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK '
                              '-DUSE_PYTORCH_METAL_EXPORT '
                              '-DSYMBOLICATE_MOBILE_DEBUG_HANDLE '
                              '-DUSE_COREML_DELEGATE -O2 -fPIC -Wall -Wextra '
                              '-Werror=return-type -Werror=non-virtual-dtor '
                              '-Werror=braced-scalar-init '
                              '-Werror=range-loop-construct '
                              '-Werror=bool-operation -Wnarrowing '
                              '-Wno-missing-field-initializers '
                              '-Wno-type-limits -Wno-array-bounds '
                              '-Wno-unknown-pragmas -Wno-unused-parameter '
                              '-Wno-unused-function -Wno-unused-result '
                              '-Wno-strict-overflow -Wno-strict-aliasing '
                              '-Wvla-extension -Wsuggest-override '
                              '-Wnewline-eof -Winconsistent-missing-override '
                              '-Winconsistent-missing-destructor-override '
                              '-Wno-pass-failed -Wno-error=pedantic '
                              '-Wno-error=old-style-cast '
                              '-Wno-error=inconsistent-missing-override '
                              '-Wno-error=inconsistent-missing-destructor-override '
                              '-Wconstant-conversion '
                              '-Wno-invalid-partial-specialization '
                              '-Wno-missing-braces -Qunused-arguments '
                              '-fcolor-diagnostics -faligned-new '
                              '-Wno-unused-but-set-variable -fno-math-errno '
                              '-fno-trapping-math -Werror=format -DUSE_MPS '
                              '-Wno-unused-private-field -Wno-missing-braces, '
                              'LAPACK_INFO=mkl, PERF_WITH_AVX=1, '
                              'PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, '
                              'TORCH_VERSION=2.2.1, USE_CUDA=OFF, '
                              'USE_CUDNN=OFF, USE_EXCEPTION_PTR=1, '
                              'USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, '
                              'USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=OFF, '
                              'USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, '
                              'USE_ROCM_KERNEL_ASSERT=OFF, \n',
 'Python': '3.10.14 (main, Mar 21 2024, 11:24:58) [Clang 14.0.6 ]',
 'TorchVision': '0.17.1',
 'numpy_random_seed': 2147483648,
 'opencompass': '0.2.2+2d4323c',
 'sys.platform': 'darwin'}


### Reproduces the problem - code/configuration sample

from mmengine.config import read_base

from opencompass.models import KServeAPI
from opencompass.partitioners import NaivePartitioner
from opencompass.runners.hanhai_eval import HanhaiEvalRunner
from opencompass.runners.hanhai_infer import HanhaiInferRunner
from opencompass.summarizers import DefaultSummarizer
from opencompass.tasks import OpenICLEvalTask, OpenICLInferTask

with read_base():
    from .datasets.hanhai_lawbench.hanhai_lawbench_gen import hanhai_lawbench_datasets as hanhai_lawbench_gen_datasets
    from .summarizers.groups.lawbench import lawbench_summary_groups

datasets = [
    *hanhai_lawbench_gen_datasets,
]

summarizer = dict(
    type=DefaultSummarizer,
    summary_groups=[
        *lawbench_summary_groups,
        {'name': 'hanhai_lawbench', 'subsets': [dataset.get('abbr') for dataset in [*hanhai_lawbench_gen_datasets]]},
        {'name': 'all', 'subsets': [dataset.get('abbr') for dataset in [*hanhai_lawbench_gen_datasets]]},
    ]
)

api_meta_template = dict(
    round=[
        dict(role='HUMAN', api_role='HUMAN'),
        dict(role='BOT', api_role='BOT', generate=True),
    ],
)

models = [
    dict(
        type=KServeAPI,
        abbr='Qwen1.5-7B-Chat',
        path='Qwen1.5-7B-Chat',
        header={'Custom-Host': 't45m124et-7156.hanhai-inference.svc.cluster.local'},
        url='https://inference-test.ai.ksyun.com/v2/models/qwen1.5-7b-chat/infer',
        model_type='chat',
        meta_template=api_meta_template,
        query_per_second=1,
        max_tokens=0,
        max_seq_len=0,
        batch_size=1
    ),
]

infer = dict(
    partitioner=dict(type=NaivePartitioner),
    runner=dict(
        type=HanhaiInferRunner,
        max_num_workers=8,
        concurrent_users=4,
        task=dict(type=OpenICLInferTask)
    ),
)

eval = dict(
    partitioner=dict(type=NaivePartitioner),
    runner=dict(
        type=HanhaiEvalRunner,
        max_num_workers=8,
        max_workers_per_gpu=1,
        task=dict(type=OpenICLEvalTask)
    ),
)


### Reproduces the problem - command or script

/opt/anaconda3/envs/evaluation/bin/python /Users/kc/Documents/Code/AI/evaluation/executor/opencompass/run.py configs/eval_hanhai_api_140.py  --work-dir outputs/default/140 --dump-eval-details -r 


### Reproduces the problem - error message

1. 评测Lawbench数据集时，会出现分数都是负数的情况
<img width="1440" alt="xiezuo20240807-202350" src="https://github.com/user-attachments/assets/68b9184f-6c5c-4c75-a629-5099a18837ed">
2. 原因是，当所有结果都预测错误的时候  score_list的值均为 math.log(216)
![image](https://github.com/user-attachments/assets/38b6b916-484b-4a98-ba71-93bcda10289a)。
3. 当score_list的值均为 math.log(216)，最终算出来的log_distance非常小，且是负数，也是浮点数精度问题
<img width="1369" alt="image" src="https://github.com/user-attachments/assets/3c6d001c-430e-4978-97db-614ad499c70e">

4. 所有当所有值均为 math.log(216)时，即所有的预测都是处于abstentions是，结果因为0，也可以用浮点数进行处理


### Other information

_No response_

Fixed by #1403