evalscope 1.0.0__py3-none-any.whl → 1.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (324) hide show
  1. evalscope/api/benchmark/__init__.py +9 -1
  2. evalscope/api/benchmark/adapters/__init__.py +4 -0
  3. evalscope/api/benchmark/adapters/agent_adapter.py +8 -0
  4. evalscope/api/benchmark/adapters/default_data_adapter.py +75 -4
  5. evalscope/api/benchmark/adapters/image_edit_adapter.py +82 -0
  6. evalscope/api/benchmark/adapters/multi_choice_adapter.py +5 -2
  7. evalscope/api/benchmark/adapters/ner_adapter.py +212 -0
  8. evalscope/api/benchmark/adapters/text2image_adapter.py +12 -10
  9. evalscope/api/benchmark/adapters/vision_language_adapter.py +8 -0
  10. evalscope/api/benchmark/benchmark.py +85 -2
  11. evalscope/api/benchmark/meta.py +10 -1
  12. evalscope/api/dataset/dataset.py +27 -6
  13. evalscope/api/dataset/loader.py +8 -3
  14. evalscope/api/evaluator/cache.py +31 -4
  15. evalscope/api/evaluator/evaluator.py +5 -0
  16. evalscope/api/evaluator/state.py +17 -1
  17. evalscope/api/messages/__init__.py +1 -0
  18. evalscope/api/messages/chat_message.py +52 -2
  19. evalscope/api/metric/__init__.py +1 -1
  20. evalscope/api/metric/metric.py +6 -1
  21. evalscope/api/metric/scorer.py +15 -7
  22. evalscope/api/mixin/__init__.py +1 -1
  23. evalscope/api/mixin/llm_judge_mixin.py +2 -0
  24. evalscope/api/mixin/sandbox_mixin.py +182 -0
  25. evalscope/api/model/generate_config.py +10 -6
  26. evalscope/api/model/model.py +5 -2
  27. evalscope/api/tool/tool_info.py +1 -1
  28. evalscope/app/app.py +3 -0
  29. evalscope/app/ui/multi_model.py +6 -1
  30. evalscope/app/ui/single_model.py +11 -5
  31. evalscope/app/utils/data_utils.py +8 -7
  32. evalscope/app/utils/env_utils.py +12 -0
  33. evalscope/app/utils/text_utils.py +14 -12
  34. evalscope/app/utils/visualization.py +2 -2
  35. evalscope/arguments.py +8 -4
  36. evalscope/backend/opencompass/backend_manager.py +0 -2
  37. evalscope/backend/rag_eval/utils/embedding.py +9 -1
  38. evalscope/benchmarks/aa_lcr/aa_lcr_adapter.py +205 -0
  39. evalscope/benchmarks/ai2d/ai2d_adapter.py +54 -0
  40. evalscope/benchmarks/aime/aime24_adapter.py +5 -0
  41. evalscope/benchmarks/aime/aime25_adapter.py +136 -1
  42. evalscope/benchmarks/aime/grader.py +307 -0
  43. evalscope/benchmarks/aime/math_normalize.py +189 -0
  44. evalscope/benchmarks/amc/amc_adapter.py +51 -0
  45. evalscope/benchmarks/arena_hard/arena_hard_adapter.py +1 -0
  46. evalscope/benchmarks/bbh/bbh_adapter.py +43 -17
  47. evalscope/benchmarks/bfcl/{bfcl_adapter.py → v3/bfcl_v3_adapter.py} +131 -19
  48. evalscope/benchmarks/bfcl/{generation.py → v3/generation.py} +9 -9
  49. evalscope/benchmarks/bfcl/v3/utils.py +23 -0
  50. evalscope/benchmarks/bfcl/v4/__init__.py +0 -0
  51. evalscope/benchmarks/bfcl/v4/bfcl_v4_adapter.py +229 -0
  52. evalscope/benchmarks/bfcl/v4/utils.py +410 -0
  53. evalscope/benchmarks/biomix_qa/__init__.py +0 -0
  54. evalscope/benchmarks/biomix_qa/biomix_qa_adapter.py +36 -0
  55. evalscope/benchmarks/blink/__init__.py +0 -0
  56. evalscope/benchmarks/blink/blink_adapter.py +61 -0
  57. evalscope/benchmarks/ceval/ceval_adapter.py +1 -2
  58. evalscope/benchmarks/chartqa/__init__.py +0 -0
  59. evalscope/benchmarks/chartqa/chartqa_adapter.py +80 -0
  60. evalscope/benchmarks/chartqa/utils.py +38 -0
  61. evalscope/benchmarks/coin_flip/__init__.py +0 -0
  62. evalscope/benchmarks/coin_flip/coin_flip_adapter.py +128 -0
  63. evalscope/benchmarks/commonsense_qa/__init__.py +0 -0
  64. evalscope/benchmarks/commonsense_qa/commonsense_qa_adapter.py +32 -0
  65. evalscope/benchmarks/competition_math/competition_math_adapter.py +5 -0
  66. evalscope/benchmarks/data_collection/data_collection_adapter.py +24 -19
  67. evalscope/benchmarks/docvqa/__init__.py +0 -0
  68. evalscope/benchmarks/docvqa/docvqa_adapter.py +67 -0
  69. evalscope/benchmarks/drivelology/__init__.py +0 -0
  70. evalscope/benchmarks/drivelology/drivelology_binary_adapter.py +170 -0
  71. evalscope/benchmarks/drivelology/drivelology_multilabel_adapter.py +254 -0
  72. evalscope/benchmarks/drivelology/drivelology_selection_adapter.py +49 -0
  73. evalscope/benchmarks/drivelology/drivelology_writing_adapter.py +218 -0
  74. evalscope/benchmarks/drop/drop_adapter.py +15 -44
  75. evalscope/benchmarks/drop/utils.py +97 -0
  76. evalscope/benchmarks/frames/frames_adapter.py +2 -1
  77. evalscope/benchmarks/general_arena/general_arena_adapter.py +7 -2
  78. evalscope/benchmarks/general_arena/utils.py +2 -1
  79. evalscope/benchmarks/general_mcq/general_mcq_adapter.py +1 -1
  80. evalscope/benchmarks/general_qa/general_qa_adapter.py +1 -1
  81. evalscope/benchmarks/gsm8k/gsm8k_adapter.py +25 -9
  82. evalscope/benchmarks/hallusion_bench/__init__.py +0 -0
  83. evalscope/benchmarks/hallusion_bench/hallusion_bench_adapter.py +159 -0
  84. evalscope/benchmarks/halu_eval/__init__.py +0 -0
  85. evalscope/benchmarks/halu_eval/halu_eval_adapter.py +128 -0
  86. evalscope/benchmarks/halu_eval/halu_eval_instructions.py +84 -0
  87. evalscope/benchmarks/healthbench/__init__.py +0 -0
  88. evalscope/benchmarks/healthbench/healthbench_adapter.py +282 -0
  89. evalscope/benchmarks/healthbench/utils.py +102 -0
  90. evalscope/benchmarks/hle/hle_adapter.py +3 -2
  91. evalscope/benchmarks/humaneval/humaneval_adapter.py +24 -52
  92. evalscope/benchmarks/humaneval/utils.py +235 -0
  93. evalscope/benchmarks/ifeval/instructions_util.py +2 -3
  94. evalscope/benchmarks/image_edit/__init__.py +0 -0
  95. evalscope/benchmarks/image_edit/gedit/__init__.py +0 -0
  96. evalscope/benchmarks/image_edit/gedit/gedit_adapter.py +138 -0
  97. evalscope/benchmarks/image_edit/gedit/utils.py +372 -0
  98. evalscope/benchmarks/image_edit/gedit/vie_prompts.py +406 -0
  99. evalscope/benchmarks/infovqa/__init__.py +0 -0
  100. evalscope/benchmarks/infovqa/infovqa_adapter.py +66 -0
  101. evalscope/benchmarks/live_code_bench/evaluate_utils.py +13 -6
  102. evalscope/benchmarks/live_code_bench/live_code_bench_adapter.py +66 -54
  103. evalscope/benchmarks/live_code_bench/sandbox_evaluate_utils.py +220 -0
  104. evalscope/benchmarks/logi_qa/__int__.py +0 -0
  105. evalscope/benchmarks/logi_qa/logi_qa_adapter.py +41 -0
  106. evalscope/benchmarks/math_500/math_500_adapter.py +5 -1
  107. evalscope/benchmarks/math_qa/__init__.py +0 -0
  108. evalscope/benchmarks/math_qa/math_qa_adapter.py +35 -0
  109. evalscope/benchmarks/math_verse/__init__.py +0 -0
  110. evalscope/benchmarks/math_verse/math_verse_adapter.py +105 -0
  111. evalscope/benchmarks/math_vision/__init__.py +0 -0
  112. evalscope/benchmarks/math_vision/math_vision_adapter.py +116 -0
  113. evalscope/benchmarks/math_vista/__init__.py +0 -0
  114. evalscope/benchmarks/math_vista/math_vista_adapter.py +114 -0
  115. evalscope/benchmarks/med_mcqa/__init__.py +0 -0
  116. evalscope/benchmarks/med_mcqa/med_mcqa_adapter.py +32 -0
  117. evalscope/benchmarks/minerva_math/__init__.py +0 -0
  118. evalscope/benchmarks/minerva_math/minerva_math_adapter.py +53 -0
  119. evalscope/benchmarks/mm_bench/__init__.py +0 -0
  120. evalscope/benchmarks/mm_bench/mm_bench_adapter.py +99 -0
  121. evalscope/benchmarks/mm_star/__init__.py +0 -0
  122. evalscope/benchmarks/mm_star/mm_star_adapter.py +73 -0
  123. evalscope/benchmarks/mmlu_pro/mmlu_pro_adapter.py +1 -1
  124. evalscope/benchmarks/mmmu/__init__.py +0 -0
  125. evalscope/benchmarks/mmmu/mmmu_adapter.py +159 -0
  126. evalscope/benchmarks/mmmu_pro/__init__.py +0 -0
  127. evalscope/benchmarks/mmmu_pro/mmmu_pro_adapter.py +124 -0
  128. evalscope/benchmarks/mri_mcqa/__init__.py +0 -0
  129. evalscope/benchmarks/mri_mcqa/mri_mcqa_adapter.py +34 -0
  130. evalscope/benchmarks/multi_if/__init__.py +0 -0
  131. evalscope/benchmarks/multi_if/ifeval.py +3354 -0
  132. evalscope/benchmarks/multi_if/metrics.py +120 -0
  133. evalscope/benchmarks/multi_if/multi_if_adapter.py +161 -0
  134. evalscope/benchmarks/music_trivia/__init__.py +0 -0
  135. evalscope/benchmarks/music_trivia/music_trivia_adapter.py +36 -0
  136. evalscope/benchmarks/needle_haystack/needle_haystack_adapter.py +7 -6
  137. evalscope/benchmarks/ner/__init__.py +0 -0
  138. evalscope/benchmarks/ner/broad_twitter_corpus_adapter.py +52 -0
  139. evalscope/benchmarks/ner/conll2003_adapter.py +48 -0
  140. evalscope/benchmarks/ner/copious_adapter.py +85 -0
  141. evalscope/benchmarks/ner/cross_ner_adapter.py +120 -0
  142. evalscope/benchmarks/ner/cross_ner_entities/__init__.py +0 -0
  143. evalscope/benchmarks/ner/cross_ner_entities/ai.py +54 -0
  144. evalscope/benchmarks/ner/cross_ner_entities/literature.py +36 -0
  145. evalscope/benchmarks/ner/cross_ner_entities/music.py +39 -0
  146. evalscope/benchmarks/ner/cross_ner_entities/politics.py +37 -0
  147. evalscope/benchmarks/ner/cross_ner_entities/science.py +58 -0
  148. evalscope/benchmarks/ner/genia_ner_adapter.py +66 -0
  149. evalscope/benchmarks/ner/harvey_ner_adapter.py +58 -0
  150. evalscope/benchmarks/ner/mit_movie_trivia_adapter.py +74 -0
  151. evalscope/benchmarks/ner/mit_restaurant_adapter.py +66 -0
  152. evalscope/benchmarks/ner/ontonotes5_adapter.py +87 -0
  153. evalscope/benchmarks/ner/wnut2017_adapter.py +61 -0
  154. evalscope/benchmarks/ocr_bench/__init__.py +0 -0
  155. evalscope/benchmarks/ocr_bench/ocr_bench/__init__.py +0 -0
  156. evalscope/benchmarks/ocr_bench/ocr_bench/ocr_bench_adapter.py +101 -0
  157. evalscope/benchmarks/ocr_bench/ocr_bench_v2/IoUscore_metric.py +87 -0
  158. evalscope/benchmarks/ocr_bench/ocr_bench_v2/TEDS_metric.py +963 -0
  159. evalscope/benchmarks/ocr_bench/ocr_bench_v2/__init__.py +0 -0
  160. evalscope/benchmarks/ocr_bench/ocr_bench_v2/ocr_bench_v2_adapter.py +161 -0
  161. evalscope/benchmarks/ocr_bench/ocr_bench_v2/page_ocr_metric.py +50 -0
  162. evalscope/benchmarks/ocr_bench/ocr_bench_v2/parallel.py +46 -0
  163. evalscope/benchmarks/ocr_bench/ocr_bench_v2/spotting_eval/__init__.py +0 -0
  164. evalscope/benchmarks/ocr_bench/ocr_bench_v2/spotting_eval/readme.txt +26 -0
  165. evalscope/benchmarks/ocr_bench/ocr_bench_v2/spotting_eval/rrc_evaluation_funcs_1_1.py +537 -0
  166. evalscope/benchmarks/ocr_bench/ocr_bench_v2/spotting_eval/script.py +481 -0
  167. evalscope/benchmarks/ocr_bench/ocr_bench_v2/spotting_metric.py +179 -0
  168. evalscope/benchmarks/ocr_bench/ocr_bench_v2/utils.py +433 -0
  169. evalscope/benchmarks/ocr_bench/ocr_bench_v2/vqa_metric.py +254 -0
  170. evalscope/benchmarks/olympiad_bench/__init__.py +0 -0
  171. evalscope/benchmarks/olympiad_bench/olympiad_bench_adapter.py +163 -0
  172. evalscope/benchmarks/olympiad_bench/utils.py +565 -0
  173. evalscope/benchmarks/omni_bench/__init__.py +0 -0
  174. evalscope/benchmarks/omni_bench/omni_bench_adapter.py +86 -0
  175. evalscope/benchmarks/omnidoc_bench/__init__.py +0 -0
  176. evalscope/benchmarks/omnidoc_bench/end2end_eval.py +349 -0
  177. evalscope/benchmarks/omnidoc_bench/metrics.py +547 -0
  178. evalscope/benchmarks/omnidoc_bench/omnidoc_bench_adapter.py +135 -0
  179. evalscope/benchmarks/omnidoc_bench/utils.py +1937 -0
  180. evalscope/benchmarks/piqa/__init__.py +0 -0
  181. evalscope/benchmarks/piqa/piqa_adapter.py +32 -0
  182. evalscope/benchmarks/poly_math/__init__.py +0 -0
  183. evalscope/benchmarks/poly_math/poly_math_adapter.py +132 -0
  184. evalscope/benchmarks/poly_math/utils/instruction.py +105 -0
  185. evalscope/benchmarks/pope/__init__.py +0 -0
  186. evalscope/benchmarks/pope/pope_adapter.py +112 -0
  187. evalscope/benchmarks/process_bench/process_bench_adapter.py +1 -0
  188. evalscope/benchmarks/pumed_qa/__init__.py +0 -0
  189. evalscope/benchmarks/pumed_qa/pubmed_qa_adapter.py +175 -0
  190. evalscope/benchmarks/qasc/__init__.py +0 -0
  191. evalscope/benchmarks/qasc/qasc_adapter.py +35 -0
  192. evalscope/benchmarks/real_world_qa/__init__.py +0 -0
  193. evalscope/benchmarks/real_world_qa/real_world_qa_adapter.py +64 -0
  194. evalscope/benchmarks/sciq/__init__.py +0 -0
  195. evalscope/benchmarks/sciq/sciq_adapter.py +36 -0
  196. evalscope/benchmarks/seed_bench_2_plus/__init__.py +0 -0
  197. evalscope/benchmarks/seed_bench_2_plus/seed_bench_2_plus_adapter.py +72 -0
  198. evalscope/benchmarks/simple_qa/simple_qa_adapter.py +1 -1
  199. evalscope/benchmarks/simple_vqa/__init__.py +0 -0
  200. evalscope/benchmarks/simple_vqa/simple_vqa_adapter.py +169 -0
  201. evalscope/benchmarks/siqa/__init__.py +0 -0
  202. evalscope/benchmarks/siqa/siqa_adapter.py +39 -0
  203. evalscope/benchmarks/tau_bench/tau2_bench/__init__.py +0 -0
  204. evalscope/benchmarks/tau_bench/tau2_bench/generation.py +158 -0
  205. evalscope/benchmarks/tau_bench/tau2_bench/tau2_bench_adapter.py +146 -0
  206. evalscope/benchmarks/tau_bench/tau_bench/__init__.py +0 -0
  207. evalscope/benchmarks/tau_bench/{generation.py → tau_bench/generation.py} +1 -1
  208. evalscope/benchmarks/tau_bench/{tau_bench_adapter.py → tau_bench/tau_bench_adapter.py} +29 -29
  209. evalscope/benchmarks/text2image/__init__.py +0 -0
  210. evalscope/benchmarks/{aigc/t2i → text2image}/evalmuse_adapter.py +3 -1
  211. evalscope/benchmarks/{aigc/t2i → text2image}/genai_bench_adapter.py +2 -2
  212. evalscope/benchmarks/{aigc/t2i → text2image}/general_t2i_adapter.py +1 -1
  213. evalscope/benchmarks/{aigc/t2i → text2image}/hpdv2_adapter.py +7 -2
  214. evalscope/benchmarks/{aigc/t2i → text2image}/tifa_adapter.py +1 -0
  215. evalscope/benchmarks/tool_bench/tool_bench_adapter.py +3 -3
  216. evalscope/benchmarks/truthful_qa/truthful_qa_adapter.py +1 -2
  217. evalscope/benchmarks/visu_logic/__init__.py +0 -0
  218. evalscope/benchmarks/visu_logic/visu_logic_adapter.py +75 -0
  219. evalscope/benchmarks/wmt/__init__.py +0 -0
  220. evalscope/benchmarks/wmt/wmt24_adapter.py +294 -0
  221. evalscope/benchmarks/zerobench/__init__.py +0 -0
  222. evalscope/benchmarks/zerobench/zerobench_adapter.py +64 -0
  223. evalscope/cli/start_app.py +7 -1
  224. evalscope/cli/start_perf.py +7 -1
  225. evalscope/config.py +103 -18
  226. evalscope/constants.py +18 -0
  227. evalscope/evaluator/evaluator.py +138 -82
  228. evalscope/metrics/bert_score/__init__.py +0 -0
  229. evalscope/metrics/bert_score/scorer.py +338 -0
  230. evalscope/metrics/bert_score/utils.py +697 -0
  231. evalscope/metrics/llm_judge.py +19 -7
  232. evalscope/metrics/math_parser.py +14 -0
  233. evalscope/metrics/metric.py +317 -13
  234. evalscope/metrics/metrics.py +37 -0
  235. evalscope/metrics/t2v_metrics/models/vqascore_models/lavis/common/config.py +0 -0
  236. evalscope/metrics/t2v_metrics/models/vqascore_models/lavis/common/dist_utils.py +0 -0
  237. evalscope/metrics/t2v_metrics/models/vqascore_models/lavis/common/gradcam.py +0 -0
  238. evalscope/metrics/t2v_metrics/models/vqascore_models/lavis/common/logger.py +0 -0
  239. evalscope/metrics/t2v_metrics/models/vqascore_models/lavis/common/optims.py +0 -0
  240. evalscope/metrics/t2v_metrics/models/vqascore_models/lavis/common/registry.py +0 -0
  241. evalscope/metrics/t2v_metrics/models/vqascore_models/lavis/common/utils.py +0 -0
  242. evalscope/metrics/t2v_metrics/models/vqascore_models/lavis/common/vqa_tools/__init__.py +0 -0
  243. evalscope/metrics/t2v_metrics/models/vqascore_models/lavis/common/vqa_tools/vqa.py +0 -0
  244. evalscope/metrics/t2v_metrics/models/vqascore_models/lavis/common/vqa_tools/vqa_eval.py +0 -0
  245. evalscope/metrics/t2v_metrics/models/vqascore_models/lavis/models/blip2_models/Qformer.py +2 -6
  246. evalscope/metrics/t2v_metrics/models/vqascore_models/lavis/models/blip_models/nlvr_encoder.py +2 -6
  247. evalscope/metrics/t2v_metrics/models/vqascore_models/lavis/models/med.py +2 -6
  248. evalscope/models/image_edit_model.py +125 -0
  249. evalscope/models/model_apis.py +22 -0
  250. evalscope/models/openai_compatible.py +21 -0
  251. evalscope/models/text2image_model.py +2 -2
  252. evalscope/models/utils/openai.py +16 -6
  253. evalscope/perf/arguments.py +26 -4
  254. evalscope/perf/benchmark.py +76 -89
  255. evalscope/perf/http_client.py +31 -16
  256. evalscope/perf/main.py +15 -2
  257. evalscope/perf/plugin/api/base.py +9 -7
  258. evalscope/perf/plugin/api/custom_api.py +13 -58
  259. evalscope/perf/plugin/api/default_api.py +188 -79
  260. evalscope/perf/plugin/api/openai_api.py +85 -20
  261. evalscope/perf/plugin/datasets/base.py +21 -0
  262. evalscope/perf/plugin/datasets/custom.py +2 -3
  263. evalscope/perf/plugin/datasets/flickr8k.py +2 -2
  264. evalscope/perf/plugin/datasets/kontext_bench.py +2 -2
  265. evalscope/perf/plugin/datasets/line_by_line.py +2 -3
  266. evalscope/perf/plugin/datasets/longalpaca.py +2 -3
  267. evalscope/perf/plugin/datasets/openqa.py +2 -4
  268. evalscope/perf/plugin/datasets/random_dataset.py +1 -3
  269. evalscope/perf/plugin/datasets/random_vl_dataset.py +2 -2
  270. evalscope/perf/utils/benchmark_util.py +43 -27
  271. evalscope/perf/utils/db_util.py +14 -19
  272. evalscope/perf/utils/local_server.py +3 -44
  273. evalscope/perf/utils/log_utils.py +21 -6
  274. evalscope/report/__init__.py +13 -3
  275. evalscope/report/combinator.py +91 -20
  276. evalscope/report/generator.py +8 -87
  277. evalscope/report/report.py +8 -4
  278. evalscope/run.py +13 -5
  279. evalscope/third_party/toolbench_static/llm/swift_infer.py +0 -4
  280. evalscope/utils/argument_utils.py +1 -1
  281. evalscope/utils/chat_service.py +1 -1
  282. evalscope/utils/function_utils.py +249 -12
  283. evalscope/utils/import_utils.py +73 -1
  284. evalscope/utils/io_utils.py +132 -7
  285. evalscope/utils/json_schema.py +25 -2
  286. evalscope/utils/logger.py +69 -18
  287. evalscope/utils/model_utils.py +4 -3
  288. evalscope/utils/multi_choices.py +39 -7
  289. evalscope/utils/ner.py +377 -0
  290. evalscope/version.py +2 -2
  291. {evalscope-1.0.0.dist-info → evalscope-1.2.0.dist-info}/METADATA +252 -408
  292. {evalscope-1.0.0.dist-info → evalscope-1.2.0.dist-info}/RECORD +290 -154
  293. {evalscope-1.0.0.dist-info → evalscope-1.2.0.dist-info}/WHEEL +1 -1
  294. {evalscope-1.0.0.dist-info → evalscope-1.2.0.dist-info}/top_level.txt +0 -1
  295. evalscope/api/mixin/dataset_mixin.py +0 -105
  296. evalscope/benchmarks/aigc/i2i/general_i2i_adapter.py +0 -44
  297. tests/__init__.py +0 -1
  298. tests/aigc/__init__.py +0 -1
  299. tests/aigc/test_t2i.py +0 -142
  300. tests/benchmark/__init__.py +0 -1
  301. tests/benchmark/test_eval.py +0 -386
  302. tests/cli/__init__.py +0 -1
  303. tests/cli/test_all.py +0 -229
  304. tests/cli/test_collection.py +0 -96
  305. tests/cli/test_custom.py +0 -268
  306. tests/perf/__init__.py +0 -1
  307. tests/perf/test_perf.py +0 -176
  308. tests/rag/test_clip_benchmark.py +0 -90
  309. tests/rag/test_mteb.py +0 -213
  310. tests/rag/test_ragas.py +0 -128
  311. tests/swift/__init__.py +0 -1
  312. tests/swift/test_run_swift_eval.py +0 -146
  313. tests/swift/test_run_swift_vlm_eval.py +0 -128
  314. tests/swift/test_run_swift_vlm_jugde_eval.py +0 -157
  315. tests/test_run_all.py +0 -12
  316. tests/utils.py +0 -13
  317. tests/vlm/__init__.py +0 -1
  318. tests/vlm/test_vlmeval.py +0 -102
  319. /evalscope/benchmarks/{aigc → aa_lcr}/__init__.py +0 -0
  320. /evalscope/benchmarks/{aigc/i2i → ai2d}/__init__.py +0 -0
  321. /evalscope/benchmarks/{aigc/t2i → amc}/__init__.py +0 -0
  322. {tests/rag → evalscope/benchmarks/bfcl/v3}/__init__.py +0 -0
  323. {evalscope-1.0.0.dist-info → evalscope-1.2.0.dist-info}/entry_points.txt +0 -0
  324. {evalscope-1.0.0.dist-info → evalscope-1.2.0.dist-info/licenses}/LICENSE +0 -0
@@ -1,5 +1,7 @@
1
+ import numpy as np
1
2
  import re
2
3
  import string
4
+ from typing import List
3
5
 
4
6
  _ARTICLES = re.compile(r'\b(a|an|the)\b', re.UNICODE)
5
7
 
@@ -57,3 +59,98 @@ def _normalize(answer):
57
59
  tokens = [token for token in tokens if token.strip()]
58
60
  normalized = ' '.join(tokens).strip()
59
61
  return normalized
62
+
63
+
64
+ def _compute_f1(predicted_bag, gold_bag):
65
+ intersection = len(gold_bag.intersection(predicted_bag))
66
+ if not predicted_bag:
67
+ precision = 1.0
68
+ else:
69
+ precision = intersection / float(len(predicted_bag))
70
+ if not gold_bag:
71
+ recall = 1.0
72
+ else:
73
+ recall = intersection / float(len(gold_bag))
74
+ f1 = ((2 * precision * recall) / (precision + recall) if not (precision == 0.0 and recall == 0.0) else 0.0)
75
+ return f1
76
+
77
+
78
+ def _match_numbers_if_present(gold_bag, predicted_bag):
79
+ gold_numbers = {word for word in gold_bag if _is_number(word)}
80
+ predicted_numbers = {word for word in predicted_bag if _is_number(word)}
81
+ if (not gold_numbers) or gold_numbers.intersection(predicted_numbers):
82
+ return True
83
+ return False
84
+
85
+
86
+ def _align_bags(predicted, gold):
87
+ """
88
+ Takes gold and predicted answer sets and first finds the optimal 1-1 alignment
89
+ between them and gets maximum metric values over all the answers.
90
+ """
91
+ from scipy.optimize import linear_sum_assignment
92
+
93
+ scores = np.zeros([len(gold), len(predicted)])
94
+ for gold_index, gold_item in enumerate(gold):
95
+ for pred_index, pred_item in enumerate(predicted):
96
+ if _match_numbers_if_present(gold_item, pred_item):
97
+ scores[gold_index, pred_index] = _compute_f1(pred_item, gold_item)
98
+ row_ind, col_ind = linear_sum_assignment(-scores)
99
+
100
+ max_scores = np.zeros([max(len(gold), len(predicted))])
101
+ for row, column in zip(row_ind, col_ind):
102
+ max_scores[row] = max(max_scores[row], scores[row, column])
103
+ return max_scores
104
+
105
+
106
+ def parse_answer(answer):
107
+ # NOTE: Everything is returned as a tuple for uniformity and hashability.
108
+ if answer['number'] != '':
109
+ return (str(answer['number']), )
110
+ if answer['spans'] != []:
111
+ return tuple(answer['spans'])
112
+ return (' '.join([answer['date']['day'], answer['date']['month'], answer['date']['year']]).strip(), )
113
+
114
+
115
+ def _get_gold_answers(input_d: dict) -> List[str]:
116
+ """
117
+ Parse the raw input labels (gold).
118
+ """
119
+
120
+ def _flatten_validated_answers(validated_answers: dict) -> List[dict]:
121
+ """
122
+ Flatten the validated_answers structure into a list of answer dictionaries.
123
+
124
+ Expected input:
125
+ validated_answers: {
126
+ 'number': [...],
127
+ 'date': [...],
128
+ 'spans': [...]
129
+ }
130
+
131
+ Each returned dict has keys: 'number', 'date', 'spans'.
132
+ If the input lists have different lengths, iteration stops at the shortest.
133
+ """
134
+ # Safely read lists from the input dict (default to empty lists)
135
+ numbers = validated_answers.get('number', [])
136
+ dates = validated_answers.get('date', [])
137
+ spans = validated_answers.get('spans', [])
138
+
139
+ # Ensure we only iterate as far as the shortest sequence to avoid IndexError
140
+ length = min(len(numbers), len(dates), len(spans))
141
+
142
+ flattened: List[dict] = []
143
+ for num, date, sp in zip(numbers[:length], dates[:length], spans[:length]):
144
+ flattened.append({'number': num, 'date': date, 'spans': sp})
145
+ return flattened
146
+
147
+ answers = []
148
+ answers_set = set()
149
+ candidates = [input_d['answer']] + _flatten_validated_answers(input_d['validated_answers'])
150
+ for candidate in candidates:
151
+ answer = parse_answer(candidate)
152
+ if answer in answers_set:
153
+ continue
154
+ answers_set.add(answer)
155
+ answers.append(answer)
156
+ return answers
@@ -61,7 +61,8 @@ class FramesAdapter(DefaultDataAdapter):
61
61
  sample_fields=self.record_to_sample,
62
62
  subset='test',
63
63
  limit=self.limit,
64
- repeats=self.repeats
64
+ repeats=self.repeats,
65
+ shuffle=self.shuffle,
65
66
  ).load()
66
67
 
67
68
  test_dataset = DatasetDict({'test': dataset})
@@ -31,9 +31,10 @@ GRADER_TEMPLATE = "<|User Prompt|>\n{question}\n\n<|The Start of Assistant A's A
31
31
  'GeneralArena is a custom benchmark designed to evaluate the performance of large language models in a competitive setting, '
32
32
  'where models are pitted against each other in custom tasks to determine their relative strengths and weaknesses. You should '
33
33
  'provide the model outputs in the format of a list of dictionaries, where each dictionary contains the model name and its report path. '
34
- 'For detailed instructions on how to use this benchmark, please refer to the [Arena User Guide](https://evalscope.readthedocs.io/zh-cn/latest/user_guides/arena.html).',
34
+ 'For detailed instructions on how to use this benchmark, please refer to the [Arena User Guide](https://evalscope.readthedocs.io/en/latest/user_guides/arena.html).',
35
35
  dataset_id='general_arena',
36
36
  metric_list=['winrate'],
37
+ aggregation='elo',
37
38
  few_shot_num=0,
38
39
  train_split=None,
39
40
  eval_split='test',
@@ -75,7 +76,11 @@ class GeneralArenaAdapter(DefaultDataAdapter):
75
76
  dataset_dict = {}
76
77
  for subset_name, samples in datasets.items():
77
78
  dataset = DictDataLoader(
78
- dict_list=samples, limit=self.limit, repeats=self.repeats, sample_fields=self.record_to_sample
79
+ dict_list=samples,
80
+ limit=self.limit,
81
+ shuffle=self.shuffle,
82
+ repeats=self.repeats,
83
+ sample_fields=self.record_to_sample
79
84
  ).load()
80
85
  dataset_dict[subset_name] = dataset
81
86
 
@@ -34,7 +34,8 @@ def process_review_item(review_result: ReviewResult) -> list:
34
34
  'Index': str(review_result.index),
35
35
  'Input': review_result.input,
36
36
  'Question': review_result.input, # Use input as question
37
- 'Generated': prediction if prediction != extracted_prediction else extracted_prediction,
37
+ 'Generated':
38
+ prediction if prediction != extracted_prediction else extracted_prediction or '', # Ensure no None value
38
39
  'Gold': target,
39
40
  'Pred': extracted_prediction,
40
41
  'Score': sample_score.score.model_dump(exclude_none=True),
@@ -20,7 +20,7 @@ logger = get_logger()
20
20
  name='general_mcq',
21
21
  pretty_name='General-MCQ',
22
22
  description='A general multiple-choice question answering dataset for custom evaluation. '
23
- 'For detailed instructions on how to use this benchmark, please refer to the [User Guide](https://evalscope.readthedocs.io/zh-cn/latest/advanced_guides/custom_dataset/llm.html#mcq).',
23
+ 'For detailed instructions on how to use this benchmark, please refer to the [User Guide](https://evalscope.readthedocs.io/en/latest/advanced_guides/custom_dataset/llm.html#mcq).',
24
24
  tags=[Tags.MULTIPLE_CHOICE, Tags.CUSTOM],
25
25
  dataset_id='general_mcq',
26
26
  subset_list=['default'],
@@ -20,7 +20,7 @@ PROMPT_TEMPLATE = '请回答问题\n{question}'
20
20
  name='general_qa',
21
21
  pretty_name='General-QA',
22
22
  description='A general question answering dataset for custom evaluation. '
23
- 'For detailed instructions on how to use this benchmark, please refer to the [User Guide](https://evalscope.readthedocs.io/zh-cn/latest/advanced_guides/custom_dataset/llm.html#qa).', # noqa: E501
23
+ 'For detailed instructions on how to use this benchmark, please refer to the [User Guide](https://evalscope.readthedocs.io/en/latest/advanced_guides/custom_dataset/llm.html#qa).', # noqa: E501
24
24
  tags=[Tags.QA, Tags.CUSTOM],
25
25
  dataset_id='general_qa',
26
26
  metric_list=['BLEU', 'Rouge'],
@@ -1,5 +1,6 @@
1
1
  # Copyright (c) Alibaba, Inc. and its affiliates.
2
2
 
3
+ import re
3
4
  from typing import Any, Dict
4
5
 
5
6
  from evalscope.api.benchmark import BenchmarkMeta, DefaultDataAdapter
@@ -12,13 +13,26 @@ from evalscope.utils.logger import get_logger
12
13
  logger = get_logger()
13
14
 
14
15
  PROMPT_TEMPLATE = """
15
- Solve the following math problem step by step. The last line of your response should be of the form "ANSWER: $ANSWER" (without quotes) where $ANSWER is the answer to the problem.
16
+ Solve the following math problem step by step. The last line of your response should display the answer enclosed within \\boxed{{\\text{{$ANSWER}}}}.
16
17
 
17
- {question}
18
+ Example:
19
+
20
+ Let's solve the problem step by step.
21
+
22
+ Problem: Eliza's rate per hour for the first 40 hours she works each week is $10. She also receives an overtime pay of 1.2 times her regular hourly rate. If Eliza worked for 45 hours this week, how much are her earnings for this week?
18
23
 
19
- Remember to put your answer on its own line at the end in the form "ANSWER: $ANSWER" (without quotes) where $ANSWER is the answer to the problem, and you do not need to use a \\boxed command.
24
+ Step 1: Calculate Eliza's earnings for the first 40 hours. Eliza's hourly rate is $10, so her earnings for the first 40 hours are $10/hour x 40 hours = $400.
25
+ Step 2: Calculate Eliza's overtime pay rate. Eliza's overtime pay rate is 1.2 times her regular hourly rate, so her overtime pay rate is $10/hour x 1.2 = $12/hour.
26
+ Step 3: Calculate Eliza's earnings for the overtime hours. Eliza worked for 45 hours, so her overtime hours are 45 hours - 40 hours = 5 hours. Her earnings for the overtime hours are $12/hour x 5 hours = $60.
27
+ Step 4: Calculate Eliza's total earnings for the week. Eliza's total earnings for the week are her earnings for the first 40 hours plus her earnings for the overtime hours, which is $400 + $60 = $460.
28
+
29
+ Answer:
30
+ \\boxed{{\\text{{460}}}}
31
+
32
+ question:
33
+ {question}
20
34
 
21
- Reasoning:
35
+ Remember to put your answer on its own line at the end in the form "\\boxed{{\\text{{$ANSWER}}}}" (without quotes), where $ANSWER is replaced by the actual answer to the problem.
22
36
  """.lstrip() # noqa: E501
23
37
 
24
38
  FEWSHOT_TEMPLATE = """
@@ -41,7 +55,11 @@ Here are some examples of how to solve similar problems:
41
55
  few_shot_num=4,
42
56
  train_split='train',
43
57
  eval_split='test',
44
- metric_list=['acc'],
58
+ metric_list=[{
59
+ 'acc': {
60
+ 'numeric': True
61
+ }
62
+ }],
45
63
  prompt_template=PROMPT_TEMPLATE,
46
64
  few_shot_prompt_template=FEWSHOT_TEMPLATE,
47
65
  )
@@ -69,8 +87,6 @@ class GSM8KAdapter(DefaultDataAdapter):
69
87
  return ''
70
88
 
71
89
  def extract_answer(self, prediction: str, task_state: TaskState):
72
- from evalscope.filters.extraction import RegexFilter
90
+ from evalscope.metrics.math_parser import extract_answer
73
91
 
74
- regex = RegexFilter(regex_pattern=r'(-?[0-9.,]{2,})|(-?[0-9]+)', group_select=-1)
75
- res = regex(prediction)
76
- return res.replace(',', '').replace('+', '').strip().strip('.')
92
+ return extract_answer(prediction)
File without changes
@@ -0,0 +1,159 @@
1
+ from collections import defaultdict
2
+ from typing import Any, Dict, List
3
+
4
+ from evalscope.api.benchmark import BenchmarkMeta, VisionLanguageAdapter
5
+ from evalscope.api.dataset import Sample
6
+ from evalscope.api.evaluator.state import TaskState
7
+ from evalscope.api.messages import ChatMessageUser, Content, ContentImage, ContentText
8
+ from evalscope.api.metric.scorer import AggScore, SampleScore, Score
9
+ from evalscope.api.registry import register_benchmark
10
+ from evalscope.constants import Tags
11
+ from evalscope.utils.io_utils import bytes_to_base64
12
+ from evalscope.utils.logger import get_logger
13
+
14
+ logger = get_logger()
15
+
16
+
17
+ @register_benchmark(
18
+ BenchmarkMeta(
19
+ name='hallusion_bench',
20
+ pretty_name='HallusionBench',
21
+ tags=[Tags.MULTI_MODAL, Tags.HALLUCINATION, Tags.YES_NO],
22
+ description=
23
+ 'HallusionBench is an advanced diagnostic benchmark designed to evaluate image-context reasoning, analyze models\' tendencies for language hallucination and visual illusion in large vision-language models (LVLMs).', # noqa: E501
24
+ dataset_id='lmms-lab/HallusionBench',
25
+ metric_list=['aAcc', 'qAcc', 'fAcc'],
26
+ aggregation='f1',
27
+ eval_split='image',
28
+ prompt_template='{question}\nPlease answer YES or NO without an explanation.',
29
+ )
30
+ )
31
+ class HallusionBenchAdapter(VisionLanguageAdapter):
32
+
33
+ def __init__(self, **kwargs):
34
+ super().__init__(**kwargs)
35
+
36
+ def record_to_sample(self, record: Dict[str, Any]) -> Sample:
37
+
38
+ input_text = self.prompt_template.format(question=record['question'])
39
+ content_list: List[Content] = [ContentText(text=input_text)]
40
+ image = record.get('image')
41
+ if image:
42
+ image_base64 = bytes_to_base64(image['bytes'], format='png', add_header=True)
43
+ content_list.append(ContentImage(image=image_base64))
44
+ answer = 'NO' if str(record.get('answer', '0')) == '1' else 'YES'
45
+ return Sample(
46
+ input=[ChatMessageUser(content=content_list)],
47
+ target=answer,
48
+ metadata={
49
+ 'category': record.get('category'),
50
+ 'subcategory': record.get('subcategory'),
51
+ 'visual_input': record.get('visual_input'),
52
+ 'set_id': record.get('set_id'),
53
+ 'figure_id': record.get('figure_id'),
54
+ 'question_id': record.get('question_id'),
55
+ }
56
+ )
57
+
58
+ def match_score(self, original_prediction, filtered_prediction, reference, task_state) -> Score:
59
+ score = Score(
60
+ extracted_prediction=filtered_prediction,
61
+ prediction=original_prediction,
62
+ )
63
+ # Check if the reference answer is in the filtered prediction
64
+ result = 1 if reference in filtered_prediction.strip().upper() else 0
65
+ score.value = {'acc': result}
66
+ return score
67
+
68
+ def aggregate_scores(self, sample_scores: List[SampleScore]) -> List[AggScore]:
69
+
70
+ def compute_aAcc(scores: List[SampleScore]):
71
+ total = len(scores)
72
+ if total == 0:
73
+ return 0.0, 0
74
+ correct = sum(ss.score.main_value for ss in scores)
75
+ return (correct / total), total
76
+
77
+ def compute_group_accuracy(scores: List[SampleScore], group_type: str):
78
+ # group_type: 'figure' or 'question'
79
+ groups = defaultdict(list)
80
+ for ss in scores:
81
+ md = ss.sample_metadata
82
+ subcategory = md.get('subcategory')
83
+ set_id = md.get('set_id')
84
+ group_id = md.get('figure_id') if group_type == 'figure' else md.get('question_id')
85
+ if subcategory is None or set_id is None or group_id is None:
86
+ # Skip incomplete records for this grouping
87
+ continue
88
+ key = f'{subcategory}_{set_id}_{group_id}'
89
+ groups[key].append(ss.score.main_value)
90
+ if not groups:
91
+ return 0.0, 0
92
+ num_correct_groups = sum(1 for vals in groups.values() if all(vals))
93
+ num_groups = len(groups)
94
+ return (num_correct_groups / num_groups), num_groups
95
+
96
+ def compute_metrics(scores: List[SampleScore]) -> Dict[str, Dict[str, float]]:
97
+ a_acc, a_n = compute_aAcc(scores)
98
+ f_acc, f_n = compute_group_accuracy(scores, 'figure')
99
+ q_acc, q_n = compute_group_accuracy(scores, 'question')
100
+ return {
101
+ 'aAcc': {
102
+ 'score': a_acc,
103
+ 'num': a_n
104
+ },
105
+ 'fAcc': {
106
+ 'score': f_acc,
107
+ 'num': f_n
108
+ },
109
+ 'qAcc': {
110
+ 'score': q_acc,
111
+ 'num': q_n
112
+ },
113
+ }
114
+
115
+ outputs: List[AggScore] = []
116
+
117
+ # By subcategory
118
+ subcategories = sorted({ss.sample_metadata.get('subcategory') for ss in sample_scores})
119
+ for subcategory in subcategories:
120
+ subset = [ss for ss in sample_scores if ss.sample_metadata.get('subcategory') == subcategory]
121
+ stats = compute_metrics(subset)
122
+ for metric in ['aAcc', 'fAcc', 'qAcc']:
123
+ outputs.append(
124
+ AggScore(
125
+ score=stats[metric]['score'],
126
+ metric_name=metric,
127
+ aggregation_name=str(subcategory),
128
+ num=stats[metric]['num'],
129
+ )
130
+ )
131
+
132
+ # By category
133
+ categories = sorted({ss.sample_metadata.get('category') for ss in sample_scores})
134
+ for category in categories:
135
+ subset = [ss for ss in sample_scores if ss.sample_metadata.get('category') == category]
136
+ stats = compute_metrics(subset)
137
+ for metric in ['aAcc', 'fAcc', 'qAcc']:
138
+ outputs.append(
139
+ AggScore(
140
+ score=stats[metric]['score'],
141
+ metric_name=metric,
142
+ aggregation_name=str(category),
143
+ num=stats[metric]['num'],
144
+ )
145
+ )
146
+
147
+ # Overall
148
+ overall = compute_metrics(sample_scores)
149
+ for metric in ['aAcc', 'fAcc', 'qAcc']:
150
+ outputs.append(
151
+ AggScore(
152
+ score=overall[metric]['score'],
153
+ metric_name=metric,
154
+ aggregation_name='Overall',
155
+ num=overall[metric]['num'],
156
+ )
157
+ )
158
+
159
+ return outputs
File without changes
@@ -0,0 +1,128 @@
1
+ # flake8: noqa: E501
2
+
3
+ from typing import Any, Dict, List
4
+
5
+ from evalscope.api.benchmark import BenchmarkMeta, DefaultDataAdapter
6
+ from evalscope.api.dataset import Sample
7
+ from evalscope.api.messages import ChatMessageUser, Content, ContentText
8
+ from evalscope.api.metric.scorer import AggScore, SampleScore, Score
9
+ from evalscope.api.registry import register_benchmark
10
+ from evalscope.benchmarks.halu_eval.halu_eval_instructions import (
11
+ DIALOGUE_INSTRUCTIONS,
12
+ QA_INSTRUCTIONS,
13
+ SUMMARIZATION_INSTRUCTIONS,
14
+ )
15
+ from evalscope.constants import Tags
16
+ from evalscope.utils.logger import get_logger
17
+
18
+ DESCRIPTION = (
19
+ 'HaluEval is a large collection of generated and human-annotated hallucinated samples for evaluating the performance of LLMs in recognizing hallucination.'
20
+ )
21
+
22
+ logger = get_logger()
23
+
24
+
25
+ @register_benchmark(
26
+ BenchmarkMeta(
27
+ name='halueval',
28
+ pretty_name='HaluEval',
29
+ tags=[Tags.KNOWLEDGE, Tags.HALLUCINATION, Tags.YES_NO],
30
+ description=DESCRIPTION.strip(),
31
+ dataset_id='evalscope/HaluEval',
32
+ subset_list=['dialogue_samples', 'qa_samples', 'summarization_samples'],
33
+ default_subset='Full',
34
+ metric_list=['accuracy', 'precision', 'recall', 'f1_score', 'yes_ratio'],
35
+ few_shot_num=0,
36
+ eval_split='data',
37
+ prompt_template='{question}'
38
+ )
39
+ )
40
+ class HaluEvalAdapter(DefaultDataAdapter):
41
+
42
+ def __init__(self, **kwargs):
43
+ super().__init__(**kwargs)
44
+ self.add_overall_metric = False
45
+
46
+ def record_to_sample(self, record: Dict[str, Any]) -> Sample:
47
+ if self.current_subset_name == 'dialogue_samples':
48
+ knowledge = record['knowledge']
49
+ dialogue_history = record['dialogue_history']
50
+ response = record['response']
51
+ hallucination = record['hallucination']
52
+ inputs = f'{DIALOGUE_INSTRUCTIONS}\n\n#Knowledge: {knowledge}\n#Dialogue History#: {dialogue_history}\n#Response#: {response}\n#Your Judgement#:'
53
+ elif self.current_subset_name == 'qa_samples':
54
+ knowledge = record['knowledge']
55
+ question = record['question']
56
+ answer = record['answer']
57
+ hallucination = record['hallucination']
58
+ inputs = f'{QA_INSTRUCTIONS}\n\n#Knowledge: {knowledge}\n#Question#: {question}\n#Answer#: {answer}\n#Your Judgement#:'
59
+ elif self.current_subset_name == 'summarization_samples':
60
+ document = record['document']
61
+ summary = record['summary']
62
+ hallucination = record['hallucination']
63
+ inputs = f'{SUMMARIZATION_INSTRUCTIONS}\n\n#Document#: {document}\n#Summary#: {summary}\n#Your Judgement#:'
64
+
65
+ input_text = self.prompt_template.format(question=inputs)
66
+ content_list: List[Content] = [ContentText(text=input_text)]
67
+ answer = str(hallucination).upper() # 'YES' or 'NO'
68
+ return Sample(
69
+ input=[ChatMessageUser(content=content_list)], target=answer, metadata={
70
+ 'answer': hallucination,
71
+ }
72
+ )
73
+
74
+ def match_score(self, original_prediction, filtered_prediction, reference, task_state) -> Score:
75
+ score = Score(
76
+ extracted_prediction=filtered_prediction,
77
+ prediction=original_prediction,
78
+ )
79
+ # Check if the reference answer is in the filtered prediction
80
+ result = 1 if reference in filtered_prediction.strip().upper() else 0
81
+ score.value = {'acc': result}
82
+ return score
83
+
84
+ def aggregate_scores(self, sample_scores: List[SampleScore]) -> List[AggScore]:
85
+ """
86
+ Custom aggregation to compute accuracy, precision, recall, f1_score, and yes_ratio.
87
+ """
88
+
89
+ def compute_metrics(scores: List[SampleScore]):
90
+ tp = fp = tn = fn = 0
91
+ yes_count = 0
92
+ total_count = len(scores)
93
+
94
+ for ss in scores:
95
+ gt = ss.sample_metadata['answer'].strip().upper()
96
+ # Get prediction based on score
97
+ pred = gt if ss.score.main_value == 1 else ('NO' if gt == 'YES' else 'YES')
98
+ if pred == 'YES':
99
+ yes_count += 1
100
+ if pred == 'YES' and gt == 'YES':
101
+ tp += 1
102
+ elif pred == 'YES' and gt == 'NO':
103
+ fp += 1
104
+ elif pred == 'NO' and gt == 'NO':
105
+ tn += 1
106
+ elif pred == 'NO' and gt == 'YES':
107
+ fn += 1
108
+
109
+ accuracy = (tp + tn) / total_count if total_count > 0 else 0.0
110
+ precision = tp / (tp + fp) if (tp + fp) > 0 else 0.0
111
+ recall = tp / (tp + fn) if (tp + fn) > 0 else 0.0
112
+ f1_score = (2 * precision * recall) / (precision + recall) if (precision + recall) > 0 else 0.0
113
+ yes_ratio = yes_count / total_count if total_count > 0 else 0.0
114
+
115
+ return {
116
+ 'accuracy': accuracy,
117
+ 'precision': precision,
118
+ 'recall': recall,
119
+ 'f1_score': f1_score,
120
+ 'yes_ratio': yes_ratio
121
+ }
122
+
123
+ overall_metrics = compute_metrics(sample_scores)
124
+ agg_scores = []
125
+ for metric_name, value in overall_metrics.items():
126
+ agg_scores.append(AggScore(metric_name=metric_name, score=value, num=len(sample_scores), metadata={}))
127
+
128
+ return agg_scores
@@ -0,0 +1,84 @@
1
+ # flake8: noqa: E501
2
+
3
+ DIALOGUE_INSTRUCTIONS = """I want you act as a response judge. Given a dialogue history and a response, your objective is to determine if the provided response contains non-factual or hallucinated information. You SHOULD give your judgement based on the following hallucination types and the world knowledge.
4
+
5
+ You are trying to determine if the true entity in the response is replaced with a highly similar entity.
6
+ #Dialogue History#: [Human]: Could you recommand movies similar to The Dark Knight? [Assistant]: The sequel to Batman Begins is The Dark Knight. [Human]: Okay. Who is the director of The Dark Knight and any other movies from him not related to Batman?
7
+ #Response#: Christopher Nolan was the director. He also directed insomnia and inception.
8
+ #Your Judgement#: No
9
+ #Dialogue History#: [Human]: Could you recommand movies similar to The Dark Knight? [Assistant]: The sequel to Batman Begins is The Dark Knight. [Human]: Okay. Who is the director of The Dark Knight and any other movies from him not related to Batman?
10
+ #Response#: Steven Spielberg was the director. He also directed insomnia and inception.
11
+ #Your Judgement#: Yes
12
+
13
+ You are trying to determine if the true entity in the response is replaced with a dissimilar entity.
14
+ #Dialogue History#: [Human]: Could you recommand movies similar to The Dark Knight? [Assistant]: The sequel to Batman Begins is The Dark Knight. [Human]: Okay. Who is the director of The Dark Knight and any other movies from him not related to Batman?
15
+ #Response#: Christopher Nolan was the director. He also directed insomnia and inception.
16
+ #Your Judgement#: No
17
+ #Dialogue History#: [Human]: Could you recommand movies similar to The Dark Knight? [Assistant]: The sequel to Batman Begins is The Dark Knight. [Human]: Okay. Who is the director of The Dark Knight and any other movies from him not related to Batman?
18
+ #Response#: Batman Begins was the director. He also directed insomnia and inception.
19
+ #Your Judgement#: Yes
20
+
21
+ You are trying to determine if the true entity in the response is replaced with a dissimilar entity in a different entity type.
22
+ #Dialogue History#: [Human]: Could you recommand movies similar to The Dark Knight? [Assistant]: The sequel to Batman Begins is The Dark Knight. [Human]: Okay. Who is the director of The Dark Knight and any other movies from him not related to Batman?
23
+ #Response#: Christopher Nolan was the director. He also directed insomnia and inception.
24
+ #Your Judgement#: No
25
+ #Dialogue History#: [Human]: Could you recommand movies similar to The Dark Knight? [Assistant]: The sequel to Batman Begins is The Dark Knight. [Human]: Okay. Who is the director of The Dark Knight and any other movies from him not related to Batman?
26
+ #Response#: United States of America was the director. He also directed insomnia and inception.
27
+ #Your Judgement#: Yes
28
+
29
+ You should try your best to determine if the response contains non-factual or hallucinated information according to the above hallucination types. The answer you give MUST be \"Yes\" or \"No\"".
30
+ """
31
+
32
+ QA_INSTRUCTIONS = """I want you act as an answer judge. Given a question and an answer, your objective is to determine if the provided answer contains non-factual or hallucinated information. You SHOULD give your judgement based on the following hallucination types and the world knowledge.
33
+
34
+ You are trying to determine if the answer misunderstands the question context and intention.
35
+ #Question#: What is a rare breed of dog that was derived as a variant of Rat Terrier, Shiloh Shepherd dog or American Hairless Terrier?
36
+ #Answer#: American Hairless Terrier
37
+ #Your Judgement#: No
38
+
39
+ You are trying to determine if there is a factual contradiction between the answer and the world knowledge. Some information in the answer might be fabricated.
40
+ #Question#: Are the New Orleans Outfall Canals the same length as the Augusta Canal?
41
+ #Answer#: No, the New Orleans Outfall Canals and the Augusta Canal are not the same length. The Orleans Canal is approximately 3.6 miles (5.8 kilometers) long while the Augusta Canal is approximately 7 miles (11.3 kilometers) long.
42
+ #Your Judgement#: Yes
43
+ #Question#: What U.S Highway gives access to Zilpo Road, and is also known as Midland Trail?
44
+ #Answer#: U.S Highway 70
45
+ #Your Judgement#: Yes
46
+
47
+ You are trying to determine if the answer is too general or too specific to answer the question at an appropriate level of specificity.
48
+ #Question#: What genre do Superheaven and Oceansize belong to?
49
+ #Answer#: Superheaven and Oceansize belong to the rock genre.
50
+ #Your Judgement#: No
51
+ #Question#: What profession do Kōbō Abe and Agatha Christie share?
52
+ #Answer#: Playwright.
53
+ #Your Judgement#: No
54
+
55
+ You are trying to determine if the answer can be correctly inferred from the knowledge.
56
+ #Question#: Which band has more members, Muse or The Raconteurs?
57
+ #Answer#: Muse has more members than The Raconteurs.
58
+ #Your Judgement#: Yes
59
+ #Question#: Which is currently more valuable, Temagami-Lorrain Mine or Meadowbank Gold Mine?
60
+ #Answer#: Meadowbank Gold Mine, since Meadowbank Gold Mine is still producing gold and the TemagamiLorrain Mine has been inactive for years.
61
+ #Your Judgement#: No
62
+
63
+ You should try your best to determine if the answer contains non-factual or hallucinated information according to the above hallucination types. The answer you give MUST be \"Yes\" or \"No\"".
64
+ """
65
+
66
+ SUMMARIZATION_INSTRUCTIONS = """I want you act as a summary judge. Given a document and a summary, your objective is to determine if the provided summary contains non-factual or hallucinated information. You SHOULD give your judgement based on the following hallucination types and the world knowledge.
67
+
68
+ You are trying to determine if the summary is factual but some information cannot be directly inferred or entailed from the document.
69
+ #Document#: The panther chameleon was found on Monday by a dog walker in the wooded area at Marl Park. It had to be put down after X-rays showed all of its legs were broken and it had a deformed spine. RSPCA Cymru said it was an "extremely sad example of an abandoned and neglected exotic pet". Inspector Selina Chan said: "It is a possibility that the owners took on this animal but were unable to provide the care he needs and decided to release him to the wild. "We are urging potential owners of exotic animals to thoroughly research what is required in the care of the particular species before taking one on. "Potential owners need to make sure they can give their animal the environment it needs and they have the facilities, time, financial means and long-term commitment to maintain a good standard of care, as required under the Animal Welfare Act 2006." She added it was illegal to release non-native species into the wild.
70
+ #Summary#: A chameleon that was found in a Cardiff park has been put down after being abandoned and neglected by its owners.
71
+ #Your Judgement#: Yes
72
+
73
+ You are trying to determine if there exists some non-factual and incorrect information in the summary.
74
+ #Document#: The city was brought to a standstill on 15 December last year when a gunman held 18 hostages for 17 hours. Family members of victims Tori Johnson and Katrina Dawson were in attendance. Images of the floral tributes that filled the city centre in the wake of the siege were projected on to the cafe and surrounding buildings in an emotional twilight ceremony. Prime Minister Malcolm Turnbull gave an address saying a "whole nation resolved to answer hatred with love". "Testament to the spirit of Australians is that with such unnecessary, thoughtless tragedy, an amazing birth of mateship, unity and love occurs. Proud to be Australian," he said. How the Sydney siege unfolded New South Wales Premier Mike Baird has also announced plans for a permanent memorial to be built into the pavement in Martin Place. Clear cubes containing flowers will be embedded into the concrete and will shine with specialised lighting. It is a project inspired by the massive floral tributes that were left in the days after the siege. "Something remarkable happened here. As a city we were drawn to Martin Place. We came in shock and in sorrow but every step we took was with purpose," he said on Tuesday.
75
+ #Summary#: Crowds have gathered in Sydney's Martin Place to honour the victims of the Lindt cafe siege, one year on.
76
+ #Your Judgement#: No
77
+
78
+ You are trying to determine if there is a factual contradiction between the summary and the document.
79
+ #Document#: Christopher Huxtable, 34, from Swansea, had been missing since the collapse in February. His body was found on Wednesday and workers who carried out the search formed a guard of honour as it was driven from the site in the early hours of the morning. Ken Cresswell, 57, and John Shaw, 61, both from Rotherham, remain missing. The body of a fourth man, Michael Collings, 53, from Brotton, Teesside, was previously recovered from the site. Swansea East MP Carolyn Harris, who has been involved with the family since the incident, said they still did not know all the facts about the collapse. She said: "I feel very sad. My heart and my prayers go out to the family who have waited desperately for Christopher's body to be found. They can finally have closure, and say goodbye to him and grieve his loss. "But let's not forget that there's two other families who are still waiting for their loved ones to be returned." The building was due for demolition when it partially collapsed in February.
80
+ #Summary#: The body of a man whose body was found at the site of the Swansea Bay Power Station collapse has been removed from the site.
81
+ #Your Judgement#: Yes
82
+
83
+ You should try your best to determine if the summary contains non-factual or hallucinated information according to the above hallucination types. The answer you give MUST be \"Yes\" or \"No\"".
84
+ """
File without changes