evalscope 0.7.2__py3-none-any.whl → 0.8.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.
Potentially problematic release.
This version of evalscope might be problematic. Click here for more details.
- evalscope/__init__.py +1 -1
- evalscope/arguments.py +73 -0
- evalscope/backend/base.py +5 -1
- evalscope/backend/opencompass/api_meta_template.py +8 -14
- evalscope/backend/opencompass/backend_manager.py +24 -15
- evalscope/backend/opencompass/tasks/eval_api.py +1 -6
- evalscope/backend/opencompass/tasks/eval_datasets.py +26 -28
- evalscope/backend/rag_eval/__init__.py +3 -3
- evalscope/backend/rag_eval/backend_manager.py +21 -25
- evalscope/backend/rag_eval/clip_benchmark/__init__.py +1 -1
- evalscope/backend/rag_eval/clip_benchmark/arguments.py +6 -6
- evalscope/backend/rag_eval/clip_benchmark/dataset_builder.py +62 -79
- evalscope/backend/rag_eval/clip_benchmark/task_template.py +29 -43
- evalscope/backend/rag_eval/clip_benchmark/tasks/image_caption.py +20 -22
- evalscope/backend/rag_eval/clip_benchmark/tasks/zeroshot_classification.py +16 -23
- evalscope/backend/rag_eval/clip_benchmark/tasks/zeroshot_retrieval.py +14 -35
- evalscope/backend/rag_eval/clip_benchmark/utils/webdataset_convert.py +69 -90
- evalscope/backend/rag_eval/cmteb/__init__.py +3 -3
- evalscope/backend/rag_eval/cmteb/arguments.py +25 -27
- evalscope/backend/rag_eval/cmteb/base.py +22 -23
- evalscope/backend/rag_eval/cmteb/task_template.py +15 -17
- evalscope/backend/rag_eval/cmteb/tasks/Classification.py +98 -79
- evalscope/backend/rag_eval/cmteb/tasks/Clustering.py +17 -22
- evalscope/backend/rag_eval/cmteb/tasks/CustomTask.py +17 -19
- evalscope/backend/rag_eval/cmteb/tasks/PairClassification.py +35 -29
- evalscope/backend/rag_eval/cmteb/tasks/Reranking.py +18 -5
- evalscope/backend/rag_eval/cmteb/tasks/Retrieval.py +163 -163
- evalscope/backend/rag_eval/cmteb/tasks/STS.py +126 -104
- evalscope/backend/rag_eval/cmteb/tasks/__init__.py +33 -34
- evalscope/backend/rag_eval/ragas/__init__.py +2 -2
- evalscope/backend/rag_eval/ragas/arguments.py +3 -8
- evalscope/backend/rag_eval/ragas/prompts/chinese/AnswerCorrectness/correctness_prompt_chinese.json +9 -9
- evalscope/backend/rag_eval/ragas/prompts/chinese/AnswerCorrectness/long_form_answer_prompt_chinese.json +2 -2
- evalscope/backend/rag_eval/ragas/prompts/chinese/AnswerRelevancy/question_generation_chinese.json +3 -3
- evalscope/backend/rag_eval/ragas/prompts/chinese/ContextPrecision/context_precision_prompt_chinese.json +5 -5
- evalscope/backend/rag_eval/ragas/prompts/chinese/CustomNodeFilter/scoring_prompt_chinese.json +7 -0
- evalscope/backend/rag_eval/ragas/prompts/chinese/Faithfulness/nli_statements_message_chinese.json +8 -8
- evalscope/backend/rag_eval/ragas/prompts/chinese/Faithfulness/statement_prompt_chinese.json +5 -5
- evalscope/backend/rag_eval/ragas/prompts/chinese/HeadlinesExtractor/prompt_chinese.json +7 -5
- evalscope/backend/rag_eval/ragas/prompts/chinese/MultiHopAbstractQuerySynthesizer/concept_combination_prompt_chinese.json +2 -2
- evalscope/backend/rag_eval/ragas/prompts/chinese/MultiHopAbstractQuerySynthesizer/generate_query_reference_prompt_chinese.json +27 -4
- evalscope/backend/rag_eval/ragas/prompts/chinese/MultiHopAbstractQuerySynthesizer/theme_persona_matching_prompt_chinese.json +2 -2
- evalscope/backend/rag_eval/ragas/prompts/chinese/MultiHopSpecificQuerySynthesizer/generate_query_reference_prompt_chinese.json +27 -4
- evalscope/backend/rag_eval/ragas/prompts/chinese/MultiHopSpecificQuerySynthesizer/theme_persona_matching_prompt_chinese.json +2 -2
- evalscope/backend/rag_eval/ragas/prompts/chinese/MultiModalFaithfulness/faithfulness_prompt_chinese.json +2 -2
- evalscope/backend/rag_eval/ragas/prompts/chinese/MultiModalRelevance/relevance_prompt_chinese.json +5 -5
- evalscope/backend/rag_eval/ragas/prompts/chinese/NERExtractor/prompt_chinese.json +3 -3
- evalscope/backend/rag_eval/ragas/prompts/chinese/SingleHopSpecificQuerySynthesizer/generate_query_reference_prompt_chinese.json +21 -4
- evalscope/backend/rag_eval/ragas/prompts/chinese/SingleHopSpecificQuerySynthesizer/theme_persona_matching_prompt_chinese.json +3 -3
- evalscope/backend/rag_eval/ragas/prompts/chinese/SummaryExtractor/prompt_chinese.json +4 -4
- evalscope/backend/rag_eval/ragas/prompts/chinese/ThemesExtractor/prompt_chinese.json +2 -2
- evalscope/backend/rag_eval/ragas/prompts/persona_prompt.py +0 -1
- evalscope/backend/rag_eval/ragas/task_template.py +10 -15
- evalscope/backend/rag_eval/ragas/tasks/__init__.py +1 -1
- evalscope/backend/rag_eval/ragas/tasks/build_distribution.py +45 -0
- evalscope/backend/rag_eval/ragas/tasks/build_transform.py +135 -0
- evalscope/backend/rag_eval/ragas/tasks/testset_generation.py +17 -133
- evalscope/backend/rag_eval/ragas/tasks/translate_prompt.py +8 -18
- evalscope/backend/rag_eval/utils/clip.py +46 -50
- evalscope/backend/rag_eval/utils/embedding.py +12 -11
- evalscope/backend/rag_eval/utils/llm.py +8 -6
- evalscope/backend/rag_eval/utils/tools.py +12 -11
- evalscope/backend/vlm_eval_kit/__init__.py +1 -1
- evalscope/backend/vlm_eval_kit/custom_dataset.py +7 -8
- evalscope/benchmarks/arc/__init__.py +3 -2
- evalscope/benchmarks/arc/ai2_arc.py +19 -16
- evalscope/benchmarks/arc/arc_adapter.py +32 -24
- evalscope/benchmarks/bbh/__init__.py +1 -2
- evalscope/benchmarks/bbh/bbh_adapter.py +28 -25
- evalscope/benchmarks/bbh/cot_prompts/boolean_expressions.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/causal_judgement.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/date_understanding.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/disambiguation_qa.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/dyck_languages.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/formal_fallacies.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/geometric_shapes.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/hyperbaton.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/logical_deduction_five_objects.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/logical_deduction_seven_objects.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/logical_deduction_three_objects.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/movie_recommendation.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/multistep_arithmetic_two.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/navigate.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/object_counting.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/penguins_in_a_table.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/reasoning_about_colored_objects.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/ruin_names.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/salient_translation_error_detection.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/snarks.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/sports_understanding.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/temporal_sequences.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/tracking_shuffled_objects_five_objects.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/tracking_shuffled_objects_seven_objects.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/tracking_shuffled_objects_three_objects.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/web_of_lies.txt +1 -1
- evalscope/benchmarks/bbh/cot_prompts/word_sorting.txt +1 -1
- evalscope/benchmarks/benchmark.py +16 -16
- evalscope/benchmarks/ceval/__init__.py +3 -2
- evalscope/benchmarks/ceval/ceval_adapter.py +80 -69
- evalscope/benchmarks/ceval/ceval_exam.py +18 -31
- evalscope/benchmarks/cmmlu/__init__.py +3 -2
- evalscope/benchmarks/cmmlu/cmmlu.py +87 -92
- evalscope/benchmarks/cmmlu/cmmlu_adapter.py +109 -155
- evalscope/benchmarks/cmmlu/samples.jsonl +1 -1
- evalscope/benchmarks/competition_math/__init__.py +3 -2
- evalscope/benchmarks/competition_math/competition_math.py +7 -16
- evalscope/benchmarks/competition_math/competition_math_adapter.py +32 -34
- evalscope/benchmarks/data_adapter.py +24 -24
- evalscope/benchmarks/general_qa/__init__.py +3 -2
- evalscope/benchmarks/general_qa/general_qa_adapter.py +34 -38
- evalscope/benchmarks/gsm8k/__init__.py +1 -1
- evalscope/benchmarks/gsm8k/gsm8k.py +6 -12
- evalscope/benchmarks/gsm8k/gsm8k_adapter.py +26 -24
- evalscope/benchmarks/hellaswag/__init__.py +3 -2
- evalscope/benchmarks/hellaswag/hellaswag.py +15 -19
- evalscope/benchmarks/hellaswag/hellaswag_adapter.py +27 -23
- evalscope/benchmarks/humaneval/__init__.py +1 -1
- evalscope/benchmarks/humaneval/humaneval.py +15 -18
- evalscope/benchmarks/humaneval/humaneval_adapter.py +0 -1
- evalscope/benchmarks/mmlu/__init__.py +3 -2
- evalscope/benchmarks/mmlu/mmlu.py +15 -29
- evalscope/benchmarks/mmlu/mmlu_adapter.py +85 -77
- evalscope/benchmarks/race/__init__.py +3 -2
- evalscope/benchmarks/race/race.py +21 -35
- evalscope/benchmarks/race/race_adapter.py +32 -29
- evalscope/benchmarks/race/samples.jsonl +1 -1
- evalscope/benchmarks/trivia_qa/__init__.py +3 -2
- evalscope/benchmarks/trivia_qa/samples.jsonl +1 -1
- evalscope/benchmarks/trivia_qa/trivia_qa.py +19 -34
- evalscope/benchmarks/trivia_qa/trivia_qa_adapter.py +27 -22
- evalscope/benchmarks/truthful_qa/__init__.py +3 -2
- evalscope/benchmarks/truthful_qa/truthful_qa.py +25 -29
- evalscope/benchmarks/truthful_qa/truthful_qa_adapter.py +36 -37
- evalscope/cli/cli.py +6 -5
- evalscope/cli/start_eval.py +31 -0
- evalscope/cli/start_perf.py +0 -3
- evalscope/cli/start_server.py +27 -41
- evalscope/config.py +119 -95
- evalscope/constants.py +61 -29
- evalscope/evaluator/__init__.py +1 -0
- evalscope/evaluator/evaluator.py +96 -377
- evalscope/evaluator/humaneval_evaluator.py +158 -0
- evalscope/evaluator/rating_eval.py +12 -33
- evalscope/evaluator/reviewer/auto_reviewer.py +47 -76
- evalscope/metrics/bundled_rouge_score/rouge_scorer.py +10 -20
- evalscope/metrics/code_metric.py +3 -9
- evalscope/metrics/math_accuracy.py +3 -6
- evalscope/metrics/metrics.py +21 -21
- evalscope/metrics/rouge_metric.py +11 -25
- evalscope/models/__init__.py +1 -2
- evalscope/models/api/openai_api.py +40 -29
- evalscope/models/custom/__init__.py +0 -1
- evalscope/models/custom/custom_model.py +3 -3
- evalscope/models/dummy_chat_model.py +7 -8
- evalscope/models/model_adapter.py +89 -156
- evalscope/models/openai_model.py +20 -20
- evalscope/perf/arguments.py +15 -3
- evalscope/perf/benchmark.py +7 -9
- evalscope/perf/http_client.py +3 -8
- evalscope/perf/main.py +10 -0
- evalscope/perf/plugin/api/custom_api.py +1 -2
- evalscope/perf/plugin/api/dashscope_api.py +1 -2
- evalscope/perf/plugin/api/openai_api.py +2 -3
- evalscope/perf/plugin/datasets/base.py +1 -2
- evalscope/perf/plugin/datasets/flickr8k.py +1 -2
- evalscope/perf/plugin/datasets/longalpaca.py +1 -2
- evalscope/perf/plugin/datasets/openqa.py +1 -2
- evalscope/perf/utils/analysis_result.py +1 -2
- evalscope/perf/utils/benchmark_util.py +1 -2
- evalscope/perf/utils/db_util.py +11 -8
- evalscope/perf/utils/local_server.py +19 -13
- evalscope/registry/config/cfg_arena_zhihu.yaml +1 -1
- evalscope/registry/tasks/arc.yaml +2 -3
- evalscope/registry/tasks/bbh.yaml +3 -4
- evalscope/registry/tasks/bbh_mini.yaml +3 -4
- evalscope/registry/tasks/ceval.yaml +3 -3
- evalscope/registry/tasks/ceval_mini.yaml +3 -4
- evalscope/registry/tasks/cmmlu.yaml +3 -3
- evalscope/registry/tasks/eval_qwen-7b-chat_v100.yaml +1 -1
- evalscope/registry/tasks/general_qa.yaml +1 -1
- evalscope/registry/tasks/gsm8k.yaml +2 -2
- evalscope/registry/tasks/mmlu.yaml +3 -3
- evalscope/registry/tasks/mmlu_mini.yaml +3 -3
- evalscope/run.py +184 -375
- evalscope/run_arena.py +20 -25
- evalscope/summarizer.py +16 -17
- evalscope/third_party/longbench_write/README.md +99 -42
- evalscope/third_party/longbench_write/default_task.json +1 -1
- evalscope/third_party/longbench_write/default_task.yaml +8 -7
- evalscope/third_party/longbench_write/eval.py +29 -28
- evalscope/third_party/longbench_write/infer.py +16 -104
- evalscope/third_party/longbench_write/longbench_write.py +5 -5
- evalscope/third_party/longbench_write/resources/judge.txt +1 -1
- evalscope/third_party/longbench_write/tools/data_etl.py +4 -5
- evalscope/third_party/longbench_write/utils.py +0 -1
- evalscope/third_party/toolbench_static/eval.py +14 -15
- evalscope/third_party/toolbench_static/infer.py +48 -69
- evalscope/third_party/toolbench_static/llm/swift_infer.py +4 -12
- evalscope/third_party/toolbench_static/requirements.txt +1 -1
- evalscope/third_party/toolbench_static/toolbench_static.py +3 -3
- evalscope/tools/combine_reports.py +25 -30
- evalscope/tools/rewrite_eval_results.py +14 -46
- evalscope/utils/__init__.py +0 -1
- evalscope/utils/arena_utils.py +18 -48
- evalscope/{perf/utils → utils}/chat_service.py +3 -4
- evalscope/utils/completion_parsers.py +3 -8
- evalscope/utils/logger.py +9 -7
- evalscope/utils/model_utils.py +11 -0
- evalscope/utils/utils.py +12 -138
- evalscope/version.py +2 -2
- {evalscope-0.7.2.dist-info → evalscope-0.8.0.dist-info}/METADATA +123 -118
- evalscope-0.8.0.dist-info/RECORD +285 -0
- tests/cli/test_run.py +54 -15
- tests/perf/test_perf.py +4 -0
- tests/rag/test_clip_benchmark.py +38 -38
- tests/rag/test_mteb.py +3 -2
- tests/rag/test_ragas.py +5 -5
- tests/swift/test_run_swift_eval.py +2 -3
- tests/swift/test_run_swift_vlm_eval.py +2 -3
- tests/swift/test_run_swift_vlm_jugde_eval.py +2 -3
- evalscope/backend/rag_eval/ragas/metrics/__init__.py +0 -2
- evalscope/backend/rag_eval/ragas/metrics/multi_modal_faithfulness.py +0 -91
- evalscope/backend/rag_eval/ragas/metrics/multi_modal_relevance.py +0 -99
- evalscope/cache.py +0 -98
- evalscope/models/template.py +0 -1446
- evalscope/run_ms.py +0 -140
- evalscope/utils/task_cfg_parser.py +0 -10
- evalscope/utils/task_utils.py +0 -22
- evalscope-0.7.2.dist-info/RECORD +0 -286
- {evalscope-0.7.2.dist-info → evalscope-0.8.0.dist-info}/LICENSE +0 -0
- {evalscope-0.7.2.dist-info → evalscope-0.8.0.dist-info}/WHEEL +0 -0
- {evalscope-0.7.2.dist-info → evalscope-0.8.0.dist-info}/entry_points.txt +0 -0
- {evalscope-0.7.2.dist-info → evalscope-0.8.0.dist-info}/top_level.txt +0 -0
evalscope/backend/rag_eval/ragas/prompts/chinese/Faithfulness/nli_statements_message_chinese.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
"ragas_version": "0.2.
|
|
3
|
-
"original_hash":
|
|
2
|
+
"ragas_version": "0.2.7",
|
|
3
|
+
"original_hash": 5296785184599215999,
|
|
4
4
|
"language": "chinese",
|
|
5
5
|
"instruction": "您的任务是根据给定的上下文判断一系列陈述的真实性。对于每个陈述,如果可以根据上下文直接推断出该陈述,则必须返回判决为1;如果不能根据上下文直接推断出该陈述,则返回判决为0。",
|
|
6
6
|
"examples": [
|
|
7
7
|
{
|
|
8
8
|
"input": {
|
|
9
|
-
"context": "约翰是XYZ
|
|
9
|
+
"context": "约翰是XYZ大学的学生。他正在攻读计算机科学学位。本学期他注册了几门课程,包括数据结构、算法和数据库管理。约翰是一个勤奋的学生,花费大量时间学习和完成作业。他经常在图书馆待到很晚以完成他的项目。",
|
|
10
10
|
"statements": [
|
|
11
11
|
"约翰主修生物学。",
|
|
12
|
-
"
|
|
12
|
+
"约翰正在学习一门人工智能课程。",
|
|
13
13
|
"约翰是一个勤奋的学生。",
|
|
14
14
|
"约翰有一份兼职工作。"
|
|
15
15
|
]
|
|
@@ -22,18 +22,18 @@
|
|
|
22
22
|
"verdict": 0
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
"statement": "
|
|
26
|
-
"reason": "
|
|
25
|
+
"statement": "约翰正在学习一门人工智能课程。",
|
|
26
|
+
"reason": "上下文中提到约翰目前注册的课程,并未提到人工智能。因此,不能推断出约翰正在学习人工智能课程。",
|
|
27
27
|
"verdict": 0
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
"statement": "约翰是一个勤奋的学生。",
|
|
31
|
-
"reason": "
|
|
31
|
+
"reason": "上下文中提到他花费大量时间学习和完成作业。此外,还提到他经常在图书馆待到很晚以完成他的项目,这意味着他很勤奋。",
|
|
32
32
|
"verdict": 1
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
"statement": "约翰有一份兼职工作。",
|
|
36
|
-
"reason": "
|
|
36
|
+
"reason": "上下文中没有给出约翰有兼职工作的信息。",
|
|
37
37
|
"verdict": 0
|
|
38
38
|
}
|
|
39
39
|
]
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
-
"ragas_version": "0.2.
|
|
3
|
-
"original_hash":
|
|
2
|
+
"ragas_version": "0.2.7",
|
|
3
|
+
"original_hash": -8546983388246528139,
|
|
4
4
|
"language": "chinese",
|
|
5
5
|
"instruction": "给定一个问题、一个答案和答案中的句子,分析在“句子”下给出的每个句子的复杂性,并将每个句子分解为一个或多个完全可理解的陈述,同时确保每个陈述中不使用代词。将输出格式化为JSON。",
|
|
6
6
|
"examples": [
|
|
7
7
|
{
|
|
8
8
|
"input": {
|
|
9
9
|
"question": "阿尔伯特·爱因斯坦是谁,他最出名的是什么?",
|
|
10
|
-
"answer": "
|
|
10
|
+
"answer": "他是一位出生于德国的理论物理学家,被广泛认为是有史以来最伟大和最有影响力的物理学家之一。他最出名的是发展了相对论,他还为量子力学理论的发展做出了重要贡献。",
|
|
11
11
|
"sentences": {
|
|
12
12
|
"0": "他是一位出生于德国的理论物理学家,被广泛认为是有史以来最伟大和最有影响力的物理学家之一。",
|
|
13
|
-
"1": "
|
|
13
|
+
"1": "他最出名的是发展了相对论,他还为量子力学理论的发展做出了重要贡献。"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"output": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"sentence_index": 1,
|
|
27
27
|
"simpler_statements": [
|
|
28
28
|
"阿尔伯特·爱因斯坦最出名的是发展了相对论。",
|
|
29
|
-
"
|
|
29
|
+
"阿尔伯特·爱因斯坦还为量子力学理论的发展做出了重要贡献。"
|
|
30
30
|
]
|
|
31
31
|
}
|
|
32
32
|
]
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
{
|
|
2
|
-
"ragas_version": "0.2.
|
|
3
|
-
"original_hash":
|
|
2
|
+
"ragas_version": "0.2.7",
|
|
3
|
+
"original_hash": 7972318980248949928,
|
|
4
4
|
"language": "chinese",
|
|
5
|
-
"instruction": "
|
|
5
|
+
"instruction": "从给定文本中提取最重要的max_num标题,这些标题可用于将文本分成独立的部分。重点关注第2级和第3级标题。",
|
|
6
6
|
"examples": [
|
|
7
7
|
{
|
|
8
8
|
"input": {
|
|
9
|
-
"text": " 介绍\n 主题概述...\n\n 主要概念\n 核心思想的解释...\n\n 详细分析\n 分析的技术和方法...\n\n 小节:专业技术\n 专业技术的进一步细节...\n\n 未来方向\n 对即将到来的趋势的见解...\n\n 小节:研究的下一步\n 新研究领域的讨论...\n\n 结论\n 最后的评论和总结。\n "
|
|
9
|
+
"text": " 介绍\n 主题概述...\n\n 主要概念\n 核心思想的解释...\n\n 详细分析\n 分析的技术和方法...\n\n 小节:专业技术\n 专业技术的进一步细节...\n\n 未来方向\n 对即将到来的趋势的见解...\n\n 小节:研究的下一步\n 新研究领域的讨论...\n\n 结论\n 最后的评论和总结。\n ",
|
|
10
|
+
"max_num": 6
|
|
10
11
|
},
|
|
11
12
|
"output": {
|
|
12
13
|
"headlines": [
|
|
14
|
+
"介绍",
|
|
13
15
|
"主要概念",
|
|
14
16
|
"详细分析",
|
|
15
17
|
"小节:专业技术",
|
|
16
18
|
"未来方向",
|
|
17
|
-
"
|
|
19
|
+
"结论"
|
|
18
20
|
]
|
|
19
21
|
}
|
|
20
22
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"ragas_version": "0.2.
|
|
3
|
-
"original_hash":
|
|
2
|
+
"ragas_version": "0.2.7",
|
|
3
|
+
"original_hash": 5035835898922847346,
|
|
4
4
|
"language": "chinese",
|
|
5
5
|
"instruction": "通过将来自至少两个不同列表的概念配对来形成组合。\n**说明:**\n- 查看每个节点的概念。\n- 确定可以逻辑连接或对比的概念。\n- 形成涉及来自不同节点的概念的组合。\n- 每个组合应至少包括来自两个或多个节点的一个概念。\n- 清晰简洁地列出组合。\n- 不要重复相同的组合。",
|
|
6
6
|
"examples": [
|
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
"ragas_version": "0.2.
|
|
3
|
-
"original_hash":
|
|
2
|
+
"ragas_version": "0.2.7",
|
|
3
|
+
"original_hash": 5691378570114822729,
|
|
4
4
|
"language": "chinese",
|
|
5
|
-
"instruction": "
|
|
6
|
-
"examples": [
|
|
5
|
+
"instruction": "根据指定的条件(角色、主题、风格、长度)和提供的上下文生成一个多跳查询和答案。主题代表从上下文中提取或生成的一组短语,这些短语突出显示了所选上下文在创建多跳查询时的适用性。确保查询明确包含这些主题。### 指导:\n1. **生成多跳查询**:使用提供的上下文片段和主题形成一个需要结合多个片段信息的查询(例如,`<1-hop>` 和 `<2-hop>`)。确保查询明确包含一个或多个主题,并反映其与上下文的相关性。\n2. **生成答案**:仅使用提供的上下文中的内容来创建查询的详细和忠实的答案。避免添加不直接存在或无法从给定上下文推断的信息。\n3. **多跳上下文标签**:\n - 每个上下文片段标记为 `<1-hop>`、`<2-hop>` 等。\n - 确保查询使用至少两个片段的信息并有意义地连接它们。",
|
|
6
|
+
"examples": [
|
|
7
|
+
{
|
|
8
|
+
"input": {
|
|
9
|
+
"persona": {
|
|
10
|
+
"name": "历史学家",
|
|
11
|
+
"role_description": "专注于主要科学里程碑及其全球影响。"
|
|
12
|
+
},
|
|
13
|
+
"themes": [
|
|
14
|
+
"相对论",
|
|
15
|
+
"实验验证"
|
|
16
|
+
],
|
|
17
|
+
"query_style": "正式",
|
|
18
|
+
"query_length": "中等",
|
|
19
|
+
"context": [
|
|
20
|
+
"<1-hop> 阿尔伯特·爱因斯坦发展了相对论,引入了时空的概念。",
|
|
21
|
+
"<2-hop> 在1919年的日食期间,光线被重力弯曲的现象得到了证实,支持了爱因斯坦的理论。"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"output": {
|
|
25
|
+
"query": "在1919年日食期间,相对论的实验验证是如何实现的?",
|
|
26
|
+
"answer": "在1919年日食期间,通过确认光线被重力弯曲,实现了相对论的实验验证,这支持了爱因斯坦在理论中提出的时空概念。"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
]
|
|
7
30
|
}
|
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
"ragas_version": "0.2.
|
|
3
|
-
"original_hash":
|
|
2
|
+
"ragas_version": "0.2.7",
|
|
3
|
+
"original_hash": 5691378570114822729,
|
|
4
4
|
"language": "chinese",
|
|
5
|
-
"instruction": "
|
|
6
|
-
"examples": [
|
|
5
|
+
"instruction": "根据指定的条件(角色、主题、风格、长度)和提供的上下文生成一个多跳查询和答案。主题代表从上下文中提取或生成的一组短语,这些短语突出显示了所选上下文适合多跳查询创建的适用性。确保查询明确包含这些主题。### 指导:\n1. **生成多跳查询**:使用提供的上下文片段和主题形成一个需要结合多个片段信息的查询(例如,`<1-hop>` 和 `<2-hop>`)。确保查询明确包含一个或多个主题,并反映其与上下文的相关性。\n2. **生成答案**:仅使用提供的上下文中的内容来创建对查询的详细和忠实的答案。避免添加不直接存在或无法从给定上下文推断的信息。\n3. **多跳上下文标签**:\n - 每个上下文片段标记为 `<1-hop>`、`<2-hop>` 等。\n - 确保查询使用至少两个片段的信息并有意义地连接它们。",
|
|
6
|
+
"examples": [
|
|
7
|
+
{
|
|
8
|
+
"input": {
|
|
9
|
+
"persona": {
|
|
10
|
+
"name": "历史学家",
|
|
11
|
+
"role_description": "专注于重大的科学里程碑及其全球影响。"
|
|
12
|
+
},
|
|
13
|
+
"themes": [
|
|
14
|
+
"相对论",
|
|
15
|
+
"实验验证"
|
|
16
|
+
],
|
|
17
|
+
"query_style": "正式",
|
|
18
|
+
"query_length": "中等",
|
|
19
|
+
"context": [
|
|
20
|
+
"<1-hop> 阿尔伯特·爱因斯坦发展了相对论,引入了时空的概念。",
|
|
21
|
+
"<2-hop> 在1919年的日全食期间,光线被重力弯曲的现象得到了证实,支持了爱因斯坦的理论。"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"output": {
|
|
25
|
+
"query": "在1919年的日全食期间,相对论的实验验证是如何实现的?",
|
|
26
|
+
"answer": "在1919年的日全食期间,通过确认光线被重力弯曲的现象,实现了相对论的实验验证,这支持了爱因斯坦在理论中提出的时空概念。"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
]
|
|
7
30
|
}
|
evalscope/backend/rag_eval/ragas/prompts/chinese/MultiModalRelevance/relevance_prompt_chinese.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"ragas_version": "0.2.
|
|
3
|
-
"original_hash": -
|
|
2
|
+
"ragas_version": "0.2.7",
|
|
3
|
+
"original_hash": -2067734205359291291,
|
|
4
4
|
"language": "chinese",
|
|
5
5
|
"instruction": "\n您的任务是评估查询的响应是否与提供的图像和文本上下文信息一致。\n您有两个选项可以回答。要么是 True / False。\n如果查询的响应与上下文信息一致,则回答 - True,否则为 False。\n",
|
|
6
6
|
"examples": [
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"user_input": "传统玛格丽塔披萨的主要成分是什么?",
|
|
10
10
|
"response": "玛格丽塔披萨的主要成分是番茄、马苏里拉奶酪和新鲜罗勒。",
|
|
11
11
|
"retrieved_contexts": [
|
|
12
|
-
"
|
|
12
|
+
"传统的玛格丽塔披萨由薄饼皮组成。",
|
|
13
13
|
"主要的配料包括番茄、马苏里拉奶酪、新鲜罗勒、盐和橄榄油。",
|
|
14
14
|
"它是最简单和最经典的披萨类型之一。"
|
|
15
15
|
]
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
"input": {
|
|
23
|
-
"user_input": "谁在2021
|
|
23
|
+
"user_input": "谁在2021年获得了奥斯卡最佳男演员奖?",
|
|
24
24
|
"response": "2021年的最佳男演员奖由莱昂纳多·迪卡普里奥获得。",
|
|
25
25
|
"retrieved_contexts": [
|
|
26
26
|
"第93届奥斯卡颁奖典礼于2021年举行。",
|
|
27
|
-
"
|
|
27
|
+
"安东尼·霍普金斯凭借在《困在时间里的父亲》中的角色获得了最佳男演员奖。",
|
|
28
28
|
"由于COVID-19的限制,这次活动具有独特性。"
|
|
29
29
|
]
|
|
30
30
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"ragas_version": "0.2.
|
|
3
|
-
"original_hash": -
|
|
2
|
+
"ragas_version": "0.2.7",
|
|
3
|
+
"original_hash": -677862064343016555,
|
|
4
4
|
"language": "chinese",
|
|
5
|
-
"instruction": "
|
|
5
|
+
"instruction": "从给定文本中提取命名实体,限制输出为顶级实体。确保实体数量不超过指定的最大值。",
|
|
6
6
|
"examples": [
|
|
7
7
|
{
|
|
8
8
|
"input": {
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
"ragas_version": "0.2.
|
|
3
|
-
"original_hash":
|
|
2
|
+
"ragas_version": "0.2.7",
|
|
3
|
+
"original_hash": 3079700511467088808,
|
|
4
4
|
"language": "chinese",
|
|
5
|
-
"instruction": "
|
|
6
|
-
"examples": [
|
|
5
|
+
"instruction": "根据指定的条件(角色、术语、风格、长度)和提供的上下文生成一个单跳查询和答案。确保答案完全忠实于上下文,仅使用提供的上下文中的信息。### 指导:\n1. **生成查询**:根据上下文、角色、术语、风格和长度,创建一个与角色视角一致并包含术语的问题。\n2. **生成答案**:仅使用提供的上下文中的内容,构建对查询的详细答案。不要添加上下文中未包含或无法推断的信息。\n",
|
|
6
|
+
"examples": [
|
|
7
|
+
{
|
|
8
|
+
"input": {
|
|
9
|
+
"persona": {
|
|
10
|
+
"name": "软件工程师",
|
|
11
|
+
"role_description": "专注于编码最佳实践和系统设计。"
|
|
12
|
+
},
|
|
13
|
+
"term": "微服务",
|
|
14
|
+
"query_style": "正式",
|
|
15
|
+
"query_length": "中等",
|
|
16
|
+
"context": "微服务是一种架构风格,其中应用程序被构建为一组松散耦合的服务。每个服务都是细粒度的,并专注于单一功能。"
|
|
17
|
+
},
|
|
18
|
+
"output": {
|
|
19
|
+
"query": "微服务在软件架构中的目的是什么?",
|
|
20
|
+
"answer": "微服务旨在将应用程序结构化为一组松散耦合的服务,每个服务专注于单一功能。"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
]
|
|
7
24
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"ragas_version": "0.2.
|
|
3
|
-
"original_hash":
|
|
2
|
+
"ragas_version": "0.2.7",
|
|
3
|
+
"original_hash": 4608101540215877909,
|
|
4
4
|
"language": "chinese",
|
|
5
5
|
"instruction": "给定一个主题和角色列表,根据角色描述将每个角色与相关主题关联起来。",
|
|
6
6
|
"examples": [
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"role_description": "专注于包容性和员工支持。"
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
|
-
"name": "
|
|
20
|
+
"name": "远程团队负责人",
|
|
21
21
|
"role_description": "管理远程团队沟通。"
|
|
22
22
|
}
|
|
23
23
|
]
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"ragas_version": "0.2.
|
|
3
|
-
"original_hash": -
|
|
2
|
+
"ragas_version": "0.2.7",
|
|
3
|
+
"original_hash": -2203889341293275650,
|
|
4
4
|
"language": "chinese",
|
|
5
|
-
"instruction": "
|
|
5
|
+
"instruction": "将给定文本总结为不超过10个句子。",
|
|
6
6
|
"examples": [
|
|
7
7
|
{
|
|
8
8
|
"input": {
|
|
9
|
-
"text": "人工智能\n\n
|
|
9
|
+
"text": "人工智能\n\n人工智能正在通过自动化以前需要人类智能的任务来改变各个行业。从医疗保健到金融,人工智能正在被用来快速准确地分析大量数据。这项技术还推动了自动驾驶汽车和个性化推荐等领域的创新。"
|
|
10
10
|
},
|
|
11
11
|
"output": {
|
|
12
12
|
"text": "人工智能通过自动化任务、分析数据和推动自动驾驶汽车和个性化推荐等创新,正在革新各个行业。"
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import os
|
|
2
1
|
import asyncio
|
|
2
|
+
import os
|
|
3
3
|
from datasets import Dataset
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
from evalscope.backend.rag_eval import LLM, EmbeddingModel
|
|
5
6
|
from evalscope.backend.rag_eval.ragas.tasks.translate_prompt import translate_prompts
|
|
6
7
|
from evalscope.utils.logger import get_logger
|
|
7
8
|
from .arguments import EvaluationArguments
|
|
@@ -9,13 +10,11 @@ from .arguments import EvaluationArguments
|
|
|
9
10
|
logger = get_logger()
|
|
10
11
|
|
|
11
12
|
|
|
12
|
-
def rag_eval(
|
|
13
|
-
args: EvaluationArguments,
|
|
14
|
-
) -> None:
|
|
13
|
+
def rag_eval(args: EvaluationArguments, ) -> None:
|
|
15
14
|
|
|
16
|
-
from ragas import evaluate, RunConfig
|
|
17
|
-
from ragas.llms import LangchainLLMWrapper
|
|
18
15
|
import importlib
|
|
16
|
+
from ragas import RunConfig, evaluate
|
|
17
|
+
from ragas.llms import LangchainLLMWrapper
|
|
19
18
|
|
|
20
19
|
def dynamic_import(*function_names):
|
|
21
20
|
functions = []
|
|
@@ -27,9 +26,6 @@ def rag_eval(
|
|
|
27
26
|
llm = LLM.load(**args.critic_llm)
|
|
28
27
|
embedding = EmbeddingModel.load(**args.embeddings)
|
|
29
28
|
|
|
30
|
-
# load dataset
|
|
31
|
-
dataset = Dataset.from_json(args.testset_file)
|
|
32
|
-
|
|
33
29
|
# load metrics
|
|
34
30
|
metrics = dynamic_import(*args.metrics)
|
|
35
31
|
asyncio.run(
|
|
@@ -38,8 +34,9 @@ def rag_eval(
|
|
|
38
34
|
target_lang=args.language,
|
|
39
35
|
llm=LangchainLLMWrapper(llm),
|
|
40
36
|
adapt_instruction=True,
|
|
41
|
-
)
|
|
42
|
-
|
|
37
|
+
))
|
|
38
|
+
# load dataset
|
|
39
|
+
dataset = Dataset.from_json(args.testset_file)
|
|
43
40
|
|
|
44
41
|
# evaluate
|
|
45
42
|
runconfig = RunConfig(timeout=600, max_retries=2, max_wait=60, max_workers=1)
|
|
@@ -54,8 +51,6 @@ def rag_eval(
|
|
|
54
51
|
logger.info(score_df)
|
|
55
52
|
|
|
56
53
|
output_path = args.testset_file.replace('.json', '_score.json')
|
|
57
|
-
score_df.to_json(
|
|
58
|
-
output_path, indent=4, index=False, orient='records', force_ascii=False
|
|
59
|
-
)
|
|
54
|
+
score_df.to_json(output_path, indent=4, index=False, orient='records', force_ascii=False)
|
|
60
55
|
|
|
61
56
|
logger.info(f'Eval score saved to {output_path}')
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
from evalscope.backend.rag_eval.ragas.tasks.testset_generation import generate_testset
|
|
2
|
-
from evalscope.backend.rag_eval.ragas.tasks.translate_prompt import translate_prompts
|
|
2
|
+
from evalscope.backend.rag_eval.ragas.tasks.translate_prompt import translate_prompts
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from ragas.llms import BaseRagasLLM
|
|
3
|
+
from ragas.testset.graph import KnowledgeGraph
|
|
4
|
+
from ragas.testset.synthesizers.multi_hop import MultiHopAbstractQuerySynthesizer, MultiHopSpecificQuerySynthesizer
|
|
5
|
+
from ragas.testset.synthesizers.single_hop.specific import SingleHopSpecificQuerySynthesizer
|
|
6
|
+
|
|
7
|
+
from .translate_prompt import translate_prompts
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def default_query_distribution(llm: BaseRagasLLM, kg: KnowledgeGraph, language: str):
|
|
11
|
+
"""
|
|
12
|
+
Generates a distribution of query synthesizers, optionally tailored to a
|
|
13
|
+
specific knowledge graph (KG) and translated into a given language.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
single_hop = SingleHopSpecificQuerySynthesizer(llm=llm)
|
|
17
|
+
multi_hop_abs = MultiHopAbstractQuerySynthesizer(llm=llm)
|
|
18
|
+
multi_hop_spec = MultiHopSpecificQuerySynthesizer(llm=llm)
|
|
19
|
+
|
|
20
|
+
asyncio.run(
|
|
21
|
+
translate_prompts(
|
|
22
|
+
prompts=[
|
|
23
|
+
single_hop,
|
|
24
|
+
multi_hop_abs,
|
|
25
|
+
multi_hop_spec,
|
|
26
|
+
],
|
|
27
|
+
target_lang=language,
|
|
28
|
+
llm=llm,
|
|
29
|
+
adapt_instruction=True,
|
|
30
|
+
))
|
|
31
|
+
|
|
32
|
+
default_queries = [
|
|
33
|
+
single_hop,
|
|
34
|
+
multi_hop_abs,
|
|
35
|
+
multi_hop_spec,
|
|
36
|
+
]
|
|
37
|
+
if kg is not None:
|
|
38
|
+
available_queries = []
|
|
39
|
+
for query in default_queries:
|
|
40
|
+
if query.get_node_clusters(kg):
|
|
41
|
+
available_queries.append(query)
|
|
42
|
+
else:
|
|
43
|
+
available_queries = default_queries
|
|
44
|
+
|
|
45
|
+
return [(query, 1 / len(available_queries)) for query in available_queries]
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from langchain_core.documents import Document
|
|
3
|
+
from ragas.embeddings import BaseRagasEmbeddings
|
|
4
|
+
from ragas.llms import BaseRagasLLM
|
|
5
|
+
from ragas.testset.graph import NodeType
|
|
6
|
+
from ragas.testset.transforms.engine import Parallel
|
|
7
|
+
from ragas.testset.transforms.extractors import EmbeddingExtractor, HeadlinesExtractor, SummaryExtractor
|
|
8
|
+
from ragas.testset.transforms.extractors.llm_based import NERExtractor, ThemesExtractor
|
|
9
|
+
from ragas.testset.transforms.filters import CustomNodeFilter
|
|
10
|
+
from ragas.testset.transforms.relationship_builders import CosineSimilarityBuilder, OverlapScoreBuilder
|
|
11
|
+
from ragas.testset.transforms.splitters import HeadlineSplitter
|
|
12
|
+
from ragas.utils import num_tokens_from_string
|
|
13
|
+
from typing import List
|
|
14
|
+
|
|
15
|
+
from .translate_prompt import translate_prompts
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def default_transforms(
|
|
19
|
+
documents: List[Document],
|
|
20
|
+
llm: BaseRagasLLM,
|
|
21
|
+
embedding_model: BaseRagasEmbeddings,
|
|
22
|
+
language: str,
|
|
23
|
+
):
|
|
24
|
+
"""
|
|
25
|
+
Creates and returns a default set of transforms for processing a knowledge graph.
|
|
26
|
+
|
|
27
|
+
This function defines a series of transformation steps to be applied to a
|
|
28
|
+
knowledge graph, including extracting summaries, keyphrases, titles,
|
|
29
|
+
headlines, and embeddings, as well as building similarity relationships
|
|
30
|
+
between nodes.
|
|
31
|
+
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
def count_doc_length_bins(documents, bin_ranges):
|
|
35
|
+
data = [num_tokens_from_string(doc.page_content) for doc in documents]
|
|
36
|
+
bins = {f'{start}-{end}': 0 for start, end in bin_ranges}
|
|
37
|
+
|
|
38
|
+
for num in data:
|
|
39
|
+
for start, end in bin_ranges:
|
|
40
|
+
if start <= num <= end:
|
|
41
|
+
bins[f'{start}-{end}'] += 1
|
|
42
|
+
break # Move to the next number once it’s placed in a bin
|
|
43
|
+
|
|
44
|
+
return bins
|
|
45
|
+
|
|
46
|
+
def filter_doc_with_num_tokens(node, min_num_tokens=500):
|
|
47
|
+
return (node.type == NodeType.DOCUMENT
|
|
48
|
+
and num_tokens_from_string(node.properties['page_content']) > min_num_tokens)
|
|
49
|
+
|
|
50
|
+
def filter_docs(node):
|
|
51
|
+
return node.type == NodeType.DOCUMENT
|
|
52
|
+
|
|
53
|
+
def filter_chunks(node):
|
|
54
|
+
return node.type == NodeType.CHUNK
|
|
55
|
+
|
|
56
|
+
bin_ranges = [(0, 100), (101, 500), (501, 100000)]
|
|
57
|
+
result = count_doc_length_bins(documents, bin_ranges)
|
|
58
|
+
result = {k: v / len(documents) for k, v in result.items()}
|
|
59
|
+
|
|
60
|
+
if result['501-100000'] >= 0.25:
|
|
61
|
+
headline_extractor = HeadlinesExtractor(llm=llm, filter_nodes=lambda node: filter_doc_with_num_tokens(node))
|
|
62
|
+
splitter = HeadlineSplitter(min_tokens=500)
|
|
63
|
+
summary_extractor = SummaryExtractor(llm=llm, filter_nodes=lambda node: filter_doc_with_num_tokens(node))
|
|
64
|
+
|
|
65
|
+
theme_extractor = ThemesExtractor(llm=llm, filter_nodes=lambda node: filter_chunks(node))
|
|
66
|
+
ner_extractor = NERExtractor(llm=llm, filter_nodes=lambda node: filter_chunks(node))
|
|
67
|
+
|
|
68
|
+
summary_emb_extractor = EmbeddingExtractor(
|
|
69
|
+
embedding_model=embedding_model,
|
|
70
|
+
property_name='summary_embedding',
|
|
71
|
+
embed_property_name='summary',
|
|
72
|
+
filter_nodes=lambda node: filter_doc_with_num_tokens(node),
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
cosine_sim_builder = CosineSimilarityBuilder(
|
|
76
|
+
property_name='summary_embedding',
|
|
77
|
+
new_property_name='summary_similarity',
|
|
78
|
+
threshold=0.7,
|
|
79
|
+
filter_nodes=lambda node: filter_doc_with_num_tokens(node),
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
ner_overlap_sim = OverlapScoreBuilder(threshold=0.01, filter_nodes=lambda node: filter_chunks(node))
|
|
83
|
+
|
|
84
|
+
node_filter = CustomNodeFilter(llm=llm, filter_nodes=lambda node: filter_chunks(node))
|
|
85
|
+
|
|
86
|
+
# translate prompts
|
|
87
|
+
asyncio.run(
|
|
88
|
+
translate_prompts(
|
|
89
|
+
prompts=[headline_extractor, summary_extractor, theme_extractor, ner_extractor, node_filter],
|
|
90
|
+
target_lang=language,
|
|
91
|
+
llm=llm,
|
|
92
|
+
adapt_instruction=True,
|
|
93
|
+
))
|
|
94
|
+
|
|
95
|
+
transforms = [
|
|
96
|
+
headline_extractor,
|
|
97
|
+
splitter,
|
|
98
|
+
summary_extractor,
|
|
99
|
+
node_filter,
|
|
100
|
+
Parallel(summary_emb_extractor, theme_extractor, ner_extractor),
|
|
101
|
+
Parallel(cosine_sim_builder, ner_overlap_sim),
|
|
102
|
+
]
|
|
103
|
+
elif result['101-500'] >= 0.25:
|
|
104
|
+
summary_extractor = SummaryExtractor(llm=llm, filter_nodes=lambda node: filter_doc_with_num_tokens(node, 100))
|
|
105
|
+
summary_emb_extractor = EmbeddingExtractor(
|
|
106
|
+
embedding_model=embedding_model,
|
|
107
|
+
property_name='summary_embedding',
|
|
108
|
+
embed_property_name='summary',
|
|
109
|
+
filter_nodes=lambda node: filter_doc_with_num_tokens(node, 100),
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
ner_extractor = NERExtractor(llm=llm)
|
|
113
|
+
ner_overlap_sim = OverlapScoreBuilder(threshold=0.01)
|
|
114
|
+
theme_extractor = ThemesExtractor(llm=llm, filter_nodes=lambda node: filter_docs(node))
|
|
115
|
+
node_filter = CustomNodeFilter(llm=llm)
|
|
116
|
+
|
|
117
|
+
# translate prompts
|
|
118
|
+
asyncio.run(
|
|
119
|
+
translate_prompts(
|
|
120
|
+
prompts=[summary_extractor, theme_extractor, ner_extractor, node_filter],
|
|
121
|
+
target_lang=language,
|
|
122
|
+
llm=llm,
|
|
123
|
+
adapt_instruction=True,
|
|
124
|
+
))
|
|
125
|
+
|
|
126
|
+
transforms = [
|
|
127
|
+
summary_extractor,
|
|
128
|
+
node_filter,
|
|
129
|
+
Parallel(summary_emb_extractor, theme_extractor, ner_extractor),
|
|
130
|
+
ner_overlap_sim,
|
|
131
|
+
]
|
|
132
|
+
else:
|
|
133
|
+
raise ValueError('Documents appears to be too short (ie 100 tokens or less). Please provide longer documents.')
|
|
134
|
+
|
|
135
|
+
return transforms
|