crfm-helm 0.5.5__py3-none-any.whl → 0.5.6__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 crfm-helm might be problematic. Click here for more details.
- {crfm_helm-0.5.5.dist-info → crfm_helm-0.5.6.dist-info}/METADATA +27 -13
- {crfm_helm-0.5.5.dist-info → crfm_helm-0.5.6.dist-info}/RECORD +203 -156
- {crfm_helm-0.5.5.dist-info → crfm_helm-0.5.6.dist-info}/WHEEL +1 -1
- helm/benchmark/adaptation/adapters/in_context_learning_adapter.py +3 -3
- helm/benchmark/adaptation/adapters/test_adapter.py +4 -4
- helm/benchmark/annotation/air_bench_annotator.py +1 -1
- helm/benchmark/annotation/bigcodebench_annotator.py +3 -3
- helm/benchmark/annotation/bird_sql_annotator.py +2 -2
- helm/benchmark/annotation/chw_care_plan_annotator.py +7 -12
- helm/benchmark/annotation/ehr_sql_annotator.py +2 -2
- helm/benchmark/annotation/helpdesk_call_summarization_annotator.py +7 -7
- helm/benchmark/annotation/mimic_bhc_annotator.py +100 -0
- helm/benchmark/annotation/model_as_judge.py +12 -16
- helm/benchmark/annotation/omni_math_annotator.py +13 -14
- helm/benchmark/annotation/wildbench_annotator.py +9 -9
- helm/benchmark/executor.py +11 -12
- helm/benchmark/metrics/aci_bench_metrics.py +9 -29
- helm/benchmark/metrics/bias_word_lists.py +1 -1
- helm/benchmark/metrics/chw_care_plan_metrics.py +10 -30
- helm/benchmark/metrics/classification_metrics.py +3 -3
- helm/benchmark/metrics/cleva_harms_metrics.py +2 -2
- helm/benchmark/metrics/conv_fin_qa_calc_metrics.py +2 -2
- helm/benchmark/metrics/dischargeme_metrics.py +9 -29
- helm/benchmark/metrics/efficiency_metrics.py +3 -3
- helm/benchmark/metrics/gpt4_audio_refusal_metrics.py +145 -0
- helm/benchmark/metrics/ifeval_metrics.py +2 -2
- helm/benchmark/metrics/kpi_edgar_metrics.py +121 -0
- helm/benchmark/metrics/llm_jury_metrics.py +46 -0
- helm/benchmark/metrics/med_dialog_metrics.py +9 -29
- helm/benchmark/metrics/medalign_metrics.py +9 -29
- helm/benchmark/metrics/medi_qa_metrics.py +9 -29
- helm/benchmark/metrics/medication_qa_metrics.py +10 -30
- helm/benchmark/metrics/melt_bias_metric.py +234 -0
- helm/benchmark/metrics/melt_bias_word_lists.py +1367 -0
- helm/benchmark/metrics/melt_metric_specs.py +43 -0
- helm/benchmark/metrics/melt_toxicity_metric.py +107 -0
- helm/benchmark/metrics/mental_health_metrics.py +9 -29
- helm/benchmark/metrics/metric_service.py +11 -11
- helm/benchmark/metrics/mimic_bhc_metrics.py +14 -0
- helm/benchmark/metrics/mimic_rrs_metrics.py +9 -29
- helm/benchmark/metrics/mtsamples_procedures_metrics.py +9 -29
- helm/benchmark/metrics/mtsamples_replicate_metrics.py +9 -29
- helm/benchmark/metrics/openai_mrcr_metrics.py +52 -0
- helm/benchmark/metrics/ruler_qa_metrics.py +34 -0
- helm/benchmark/metrics/starr_patient_instructions_metrics.py +9 -29
- helm/benchmark/metrics/summac/model_summac.py +1 -2
- helm/benchmark/metrics/summarization_metrics.py +2 -1
- helm/benchmark/metrics/tokens/test_openai_token_cost_estimator.py +2 -2
- helm/benchmark/metrics/toxicity_metrics.py +2 -2
- helm/benchmark/metrics/unitxt_metrics.py +3 -4
- helm/benchmark/metrics/vision_language/emd_utils.py +4 -2
- helm/benchmark/metrics/vision_language/image_utils.py +2 -2
- helm/benchmark/model_deployment_registry.py +6 -8
- helm/benchmark/presentation/contamination.py +3 -3
- helm/benchmark/presentation/create_plots.py +33 -12
- helm/benchmark/presentation/run_display.py +13 -0
- helm/benchmark/presentation/schema.py +2 -1
- helm/benchmark/presentation/summarize.py +76 -59
- helm/benchmark/reeval_run.py +3 -4
- helm/benchmark/reeval_runner.py +3 -3
- helm/benchmark/run.py +78 -73
- helm/benchmark/run_expander.py +12 -1
- helm/benchmark/run_spec_factory.py +7 -6
- helm/benchmark/run_specs/audio_run_specs.py +52 -8
- helm/benchmark/run_specs/enterprise_run_specs.py +20 -0
- helm/benchmark/run_specs/experimental_run_specs.py +31 -1
- helm/benchmark/run_specs/long_context_run_specs.py +67 -15
- helm/benchmark/run_specs/medhelm_run_specs.py +146 -41
- helm/benchmark/run_specs/melt_run_specs.py +783 -0
- helm/benchmark/run_specs/speech_disorder_audio_run_specs.py +169 -0
- helm/benchmark/run_specs/vlm_run_specs.py +28 -0
- helm/benchmark/runner.py +5 -5
- helm/benchmark/scenarios/aci_bench_scenario.py +7 -1
- helm/benchmark/scenarios/audio_language/air_bench_chat_scenario.py +3 -1
- helm/benchmark/scenarios/audio_language/air_bench_foundation_scenario.py +5 -5
- helm/benchmark/scenarios/audio_language/corebench_scenario.py +77 -0
- helm/benchmark/scenarios/audio_language/ultra_suite_asr_classification.py +103 -0
- helm/benchmark/scenarios/audio_language/ultra_suite_classification_scenario.py +110 -0
- helm/benchmark/scenarios/audio_language/ultra_suite_disorder_breakdown_scenario.py +78 -0
- helm/benchmark/scenarios/audio_language/ultra_suite_disorder_symptoms_scenario.py +109 -0
- helm/benchmark/scenarios/audio_language/vocal_sound_scenario.py +15 -1
- helm/benchmark/scenarios/audio_language/voxceleb2_scenario.py +1 -2
- helm/benchmark/scenarios/autobencher_capabilities_scenario.py +2 -2
- helm/benchmark/scenarios/chw_care_plan_scenario.py +14 -13
- helm/benchmark/scenarios/clear_scenario.py +11 -7
- helm/benchmark/scenarios/dischargeme_scenario.py +36 -21
- helm/benchmark/scenarios/ehr_sql_scenario.py +7 -1
- helm/benchmark/scenarios/ehrshot_scenario.py +28 -55
- helm/benchmark/scenarios/grammar.py +2 -2
- helm/benchmark/scenarios/headqa_scenario.py +6 -1
- helm/benchmark/scenarios/infinite_bench_en_qa_scenario.py +85 -0
- helm/benchmark/scenarios/{infinite_bench_sum_scenario.py → infinite_bench_en_sum_scenario.py} +10 -13
- helm/benchmark/scenarios/kpi_edgar_scenario.py +151 -0
- helm/benchmark/scenarios/med_dialog_scenario.py +6 -1
- helm/benchmark/scenarios/medalign_scenario.py +9 -3
- helm/benchmark/scenarios/medalign_scenario_helper.py +8 -5
- helm/benchmark/scenarios/medbullets_scenario.py +7 -2
- helm/benchmark/scenarios/medcalc_bench_scenario.py +4 -2
- helm/benchmark/scenarios/medec_scenario.py +6 -1
- helm/benchmark/scenarios/medhallu_scenario.py +7 -1
- helm/benchmark/scenarios/medi_qa_scenario.py +10 -4
- helm/benchmark/scenarios/medication_qa_scenario.py +7 -1
- helm/benchmark/scenarios/melt_ir_scenario.py +171 -0
- helm/benchmark/scenarios/melt_knowledge_scenario.py +246 -0
- helm/benchmark/scenarios/melt_lm_scenarios.py +252 -0
- helm/benchmark/scenarios/melt_scenarios.py +793 -0
- helm/benchmark/scenarios/melt_srn_scenario.py +342 -0
- helm/benchmark/scenarios/melt_synthetic_reasoning_scenario.py +222 -0
- helm/benchmark/scenarios/melt_translation_scenario.py +152 -0
- helm/benchmark/scenarios/mental_health_scenario.py +16 -5
- helm/benchmark/scenarios/mimic_bhc_scenario.py +12 -7
- helm/benchmark/scenarios/mimic_rrs_scenario.py +17 -8
- helm/benchmark/scenarios/mimiciv_billing_code_scenario.py +14 -8
- helm/benchmark/scenarios/mmlu_pro_scenario.py +1 -1
- helm/benchmark/scenarios/mtsamples_procedures_scenario.py +5 -2
- helm/benchmark/scenarios/mtsamples_replicate_scenario.py +3 -2
- helm/benchmark/scenarios/n2c2_ct_matching_scenario.py +11 -5
- helm/benchmark/scenarios/numeracy_scenario.py +2 -1
- helm/benchmark/scenarios/openai_mrcr_scenario.py +79 -0
- helm/benchmark/scenarios/pubmed_qa_scenario.py +6 -1
- helm/benchmark/scenarios/race_based_med_scenario.py +18 -8
- helm/benchmark/scenarios/ruler_qa_scenario_helper.py +2 -2
- helm/benchmark/scenarios/ruler_qa_scenarios.py +2 -2
- helm/benchmark/scenarios/shc_bmt_scenario.py +12 -6
- helm/benchmark/scenarios/shc_cdi_scenario.py +11 -6
- helm/benchmark/scenarios/shc_conf_scenario.py +12 -6
- helm/benchmark/scenarios/shc_ent_scenario.py +11 -6
- helm/benchmark/scenarios/shc_gip_scenario.py +13 -5
- helm/benchmark/scenarios/shc_privacy_scenario.py +78 -0
- helm/benchmark/scenarios/shc_proxy_scenario.py +76 -0
- helm/benchmark/scenarios/shc_ptbm_scenario.py +12 -7
- helm/benchmark/scenarios/shc_sei_scenario.py +12 -7
- helm/benchmark/scenarios/shc_sequoia_scenario.py +13 -5
- helm/benchmark/scenarios/starr_patient_instructions_scenario.py +15 -8
- helm/benchmark/scenarios/test_infinite_bench_en_qa_scenario.py +18 -0
- helm/benchmark/scenarios/test_infinite_bench_en_sum_scenario.py +31 -0
- helm/benchmark/scenarios/truthful_qa_scenario.py +2 -1
- helm/benchmark/scenarios/vision_language/msr_vtt_scenario.py +75 -0
- helm/benchmark/server.py +2 -1
- helm/benchmark/static/schema_audio.yaml +60 -49
- helm/benchmark/static/schema_enterprise.yaml +21 -0
- helm/benchmark/static/schema_long_context.yaml +63 -20
- helm/benchmark/static/schema_medhelm.yaml +272 -213
- helm/benchmark/static/schema_melt.yaml +1257 -0
- helm/benchmark/static/schema_slphelm.yaml +162 -0
- helm/benchmark/static/schema_vhelm.yaml +26 -26
- helm/benchmark/static/schema_video.yaml +219 -0
- helm/benchmark/static_build/assets/index-94295e78.js +10 -0
- helm/benchmark/static_build/assets/index-b9779128.css +1 -0
- helm/benchmark/static_build/assets/medhelm-overview-eac29843.png +0 -0
- helm/benchmark/static_build/assets/{tremor-9cefc3c5.js → tremor-38a10867.js} +1 -1
- helm/benchmark/static_build/index.html +4 -4
- helm/benchmark/window_services/encoder_decoder_window_service.py +3 -3
- helm/benchmark/window_services/test_utils.py +3 -4
- helm/benchmark/window_services/tokenizer_service.py +7 -8
- helm/clients/anthropic_client.py +69 -29
- helm/clients/audio_language/diva_llama_client.py +4 -2
- helm/clients/audio_language/qwen2_5_omni_client.py +197 -0
- helm/clients/audio_language/qwen2_audiolm_client.py +8 -6
- helm/clients/audio_language/qwen_audiolm_client.py +4 -2
- helm/clients/audio_language/test.py +62 -0
- helm/clients/bedrock_client.py +3 -1
- helm/clients/client.py +7 -7
- helm/clients/grok_client.py +36 -0
- helm/clients/huggingface_client.py +42 -3
- helm/clients/huggingface_pipeline_client.py +138 -0
- helm/clients/image_generation/dalle_mini/model/configuration.py +1 -1
- helm/clients/image_generation/dalle_mini/model/modeling.py +1 -1
- helm/clients/image_generation/dalle_mini/model/processor.py +1 -1
- helm/clients/image_generation/dalle_mini/model/tokenizer.py +1 -1
- helm/clients/openai_client.py +100 -54
- helm/clients/openai_responses_client.py +174 -0
- helm/clients/palmyra_client.py +2 -5
- helm/clients/reka_client.py +2 -2
- helm/clients/together_client.py +31 -4
- helm/clients/vertexai_client.py +6 -0
- helm/clients/vision_language/huggingface_vision2seq_client.py +6 -4
- helm/clients/vision_language/huggingface_vlm_client.py +2 -2
- helm/clients/vision_language/idefics_client.py +6 -2
- helm/clients/vision_language/paligemma_client.py +2 -2
- helm/clients/vision_language/qwen2_vlm_client.py +66 -53
- helm/clients/vision_language/qwen_vlm_client.py +7 -5
- helm/clients/writer_client.py +102 -0
- helm/common/context.py +80 -0
- helm/common/credentials_utils.py +5 -5
- helm/common/general.py +9 -2
- helm/common/hierarchical_logger.py +46 -3
- helm/common/local_context.py +140 -0
- helm/common/remote_context.py +61 -0
- helm/common/request.py +8 -0
- helm/config/model_deployments.yaml +864 -193
- helm/config/model_metadata.yaml +667 -53
- helm/config/tokenizer_configs.yaml +144 -3
- helm/proxy/cli.py +3 -1
- helm/proxy/critique/mechanical_turk_utils.py +1 -1
- helm/proxy/services/server_service.py +21 -85
- helm/tokenizers/grok_tokenizer.py +53 -0
- helm/tokenizers/huggingface_tokenizer.py +1 -1
- helm/tokenizers/test_grok_tokenizer.py +33 -0
- helm/benchmark/scenarios/test_infinite_bench_sum_scenario.py +0 -46
- helm/benchmark/static_build/assets/index-262903c1.js +0 -10
- helm/benchmark/static_build/assets/index-42060d71.css +0 -1
- {crfm_helm-0.5.5.dist-info → crfm_helm-0.5.6.dist-info}/entry_points.txt +0 -0
- {crfm_helm-0.5.5.dist-info → crfm_helm-0.5.6.dist-info}/licenses/LICENSE +0 -0
- {crfm_helm-0.5.5.dist-info → crfm_helm-0.5.6.dist-info}/top_level.txt +0 -0
- /helm/benchmark/static_build/assets/{medhelm-overview-3ddfcd65.png → medhelm-v1-overview-3ddfcd65.png} +0 -0
|
@@ -0,0 +1,793 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from abc import abstractmethod
|
|
3
|
+
from typing import Dict, List, Tuple, Optional
|
|
4
|
+
|
|
5
|
+
from datasets import load_dataset
|
|
6
|
+
from helm.common.general import ensure_directory_exists
|
|
7
|
+
from helm.benchmark.scenarios.scenario import (
|
|
8
|
+
Scenario,
|
|
9
|
+
Instance,
|
|
10
|
+
Reference,
|
|
11
|
+
TRAIN_SPLIT,
|
|
12
|
+
TEST_SPLIT,
|
|
13
|
+
VALID_SPLIT,
|
|
14
|
+
CORRECT_TAG,
|
|
15
|
+
PassageQuestionInput,
|
|
16
|
+
Input,
|
|
17
|
+
Output,
|
|
18
|
+
)
|
|
19
|
+
from helm.benchmark.scenarios.math_scenario import get_answer
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class MELTQAScenario(Scenario):
|
|
23
|
+
name = "melt_question_answering"
|
|
24
|
+
description = "Question answering scenario."
|
|
25
|
+
tags = ["question_answering"]
|
|
26
|
+
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
dataset_name: str,
|
|
30
|
+
revision: str,
|
|
31
|
+
subset: Optional[str] = None,
|
|
32
|
+
passage_prefix: str = "Passage: ",
|
|
33
|
+
question_prefix: str = "Question: ",
|
|
34
|
+
splits: Optional[Dict[str, str]] = None,
|
|
35
|
+
):
|
|
36
|
+
"""
|
|
37
|
+
Initializes the question answering scenario.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
dataset_name: The name of the dataset.
|
|
41
|
+
revision: The revision of the dataset to use.
|
|
42
|
+
subset: The subset of the dataset to use. Defaults to "".
|
|
43
|
+
passage_prefix: The prefix to use for the context passage. Defaults to "Passage: ".
|
|
44
|
+
question_prefix: The prefix to use for the question. Defaults to "Question: ".
|
|
45
|
+
splits: The splits to use for the dataset. Defaults to None.
|
|
46
|
+
"""
|
|
47
|
+
super().__init__()
|
|
48
|
+
self.dataset_name = dataset_name
|
|
49
|
+
self.subset = subset
|
|
50
|
+
self.revision = revision
|
|
51
|
+
self.passage_prefix = passage_prefix
|
|
52
|
+
self.question_prefix = question_prefix
|
|
53
|
+
self.splits = splits
|
|
54
|
+
|
|
55
|
+
def process_example(self, sample: dict) -> Tuple[Input, List[str]]:
|
|
56
|
+
"""
|
|
57
|
+
Given an sample from the dataset, create the prompt and the list of
|
|
58
|
+
correct references.
|
|
59
|
+
Each sample is a dictionary with the following keys:
|
|
60
|
+
- context: The passage to be used for the question.
|
|
61
|
+
- question: A questions.
|
|
62
|
+
- answers: A list of answers with dictionary format {'answer_start': [], 'text': []}
|
|
63
|
+
"""
|
|
64
|
+
passage = sample["context"]
|
|
65
|
+
question = sample["question"]
|
|
66
|
+
prompt = PassageQuestionInput(
|
|
67
|
+
passage=passage,
|
|
68
|
+
passage_prefix=self.passage_prefix,
|
|
69
|
+
question=question,
|
|
70
|
+
question_prefix=self.question_prefix,
|
|
71
|
+
separator="\n\n",
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
answers: List[str] = []
|
|
75
|
+
for answer_text in sample["answers"]["text"]:
|
|
76
|
+
answers.append(answer_text)
|
|
77
|
+
|
|
78
|
+
return prompt, answers
|
|
79
|
+
|
|
80
|
+
def get_instances_for_splits(self, splits: Dict[str, str]) -> List[Instance]:
|
|
81
|
+
"""
|
|
82
|
+
Helper for generating instances for a split.
|
|
83
|
+
Args:
|
|
84
|
+
splits (dict): Which splits to partition the data into.
|
|
85
|
+
Returns:
|
|
86
|
+
List[Instance]: Instances from the file for the specified split.
|
|
87
|
+
"""
|
|
88
|
+
instances: List[Instance] = []
|
|
89
|
+
dataset = load_dataset(
|
|
90
|
+
self.dataset_name,
|
|
91
|
+
self.subset,
|
|
92
|
+
revision=self.revision,
|
|
93
|
+
trust_remote_code=True,
|
|
94
|
+
)
|
|
95
|
+
for dataset_split_name, helm_split_name in splits.items():
|
|
96
|
+
if dataset_split_name not in dataset:
|
|
97
|
+
raise ValueError(f"Could not find split {dataset_split_name} in dataset {self.dataset_name}")
|
|
98
|
+
|
|
99
|
+
for sample in dataset[dataset_split_name]:
|
|
100
|
+
prompt, answers = self.process_example(sample)
|
|
101
|
+
instance = Instance(
|
|
102
|
+
input=prompt,
|
|
103
|
+
references=[Reference(Output(text=answer), tags=[CORRECT_TAG]) for answer in answers],
|
|
104
|
+
split=helm_split_name,
|
|
105
|
+
)
|
|
106
|
+
instances.append(instance)
|
|
107
|
+
|
|
108
|
+
return instances
|
|
109
|
+
|
|
110
|
+
def get_instances(self, output_path: str) -> List[Instance]:
|
|
111
|
+
if self.splits is None:
|
|
112
|
+
splits = {"train": TRAIN_SPLIT, "validation": VALID_SPLIT, "test": TEST_SPLIT}
|
|
113
|
+
else:
|
|
114
|
+
splits = {}
|
|
115
|
+
if "train" in self.splits:
|
|
116
|
+
splits[self.splits[TRAIN_SPLIT]] = TRAIN_SPLIT
|
|
117
|
+
if "validation" in self.splits:
|
|
118
|
+
splits[self.splits[VALID_SPLIT]] = VALID_SPLIT
|
|
119
|
+
if "test" in self.splits:
|
|
120
|
+
splits[self.splits[TEST_SPLIT]] = TEST_SPLIT
|
|
121
|
+
|
|
122
|
+
instances: List[Instance] = self.get_instances_for_splits(splits=splits)
|
|
123
|
+
return instances
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class MELTQAMLQAScenario(MELTQAScenario):
|
|
127
|
+
"""
|
|
128
|
+
Scenario for MLQA dataset.
|
|
129
|
+
This dataset is a multilingual question answering dataset.
|
|
130
|
+
It contains questions in multiple languages and their corresponding
|
|
131
|
+
answers in the same language.
|
|
132
|
+
In this scenario, we are using the Vietnamese subset of the MLQA dataset.
|
|
133
|
+
"""
|
|
134
|
+
|
|
135
|
+
name = "melt_question_answering_mlqa"
|
|
136
|
+
description = "MLQA is an open-ended question answering dataset in multiple languages."
|
|
137
|
+
tags = ["question_answering"]
|
|
138
|
+
|
|
139
|
+
def __init__(self):
|
|
140
|
+
super().__init__(
|
|
141
|
+
dataset_name="facebook/mlqa",
|
|
142
|
+
revision="397ed406c1a7902140303e7faf60fff35b58d285",
|
|
143
|
+
subset="mlqa.vi.vi",
|
|
144
|
+
passage_prefix="Ngữ cảnh: ",
|
|
145
|
+
question_prefix="Câu hỏi: ",
|
|
146
|
+
splits={
|
|
147
|
+
VALID_SPLIT: "validation",
|
|
148
|
+
TEST_SPLIT: "test",
|
|
149
|
+
},
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class MELTQAXQuADScenario(MELTQAScenario):
|
|
154
|
+
"""
|
|
155
|
+
Scenario for XQuAD dataset.
|
|
156
|
+
XQuAD (Cross-lingual Question Answering Dataset) is a benchmark dataset
|
|
157
|
+
for evaluating cross-lingual question answering performance.
|
|
158
|
+
"""
|
|
159
|
+
|
|
160
|
+
name = "melt_question_answering_xquad"
|
|
161
|
+
description = "XQuAD is a cross-lingual question answering dataset."
|
|
162
|
+
tags = ["question_answering"]
|
|
163
|
+
|
|
164
|
+
def __init__(self):
|
|
165
|
+
super().__init__(
|
|
166
|
+
dataset_name="juletxara/xquad_xtreme",
|
|
167
|
+
revision="87646a09233481f6884b6ffcc6795af9ca0b85d7",
|
|
168
|
+
subset="vi",
|
|
169
|
+
passage_prefix="Ngữ cảnh: ",
|
|
170
|
+
question_prefix="Câu hỏi: ",
|
|
171
|
+
splits={
|
|
172
|
+
VALID_SPLIT: "translate_train",
|
|
173
|
+
TEST_SPLIT: "test",
|
|
174
|
+
},
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class MELTSummarizationScenario(Scenario):
|
|
179
|
+
"""
|
|
180
|
+
Scenario for single document text summarization.
|
|
181
|
+
"""
|
|
182
|
+
|
|
183
|
+
name = "melt_summarization"
|
|
184
|
+
description = "Scenario for summarization tasks"
|
|
185
|
+
tags = ["summarization"]
|
|
186
|
+
|
|
187
|
+
def __init__(
|
|
188
|
+
self,
|
|
189
|
+
dataset_name: str,
|
|
190
|
+
revision: str,
|
|
191
|
+
subset: Optional[str] = None,
|
|
192
|
+
train_min_length: Optional[int] = None,
|
|
193
|
+
train_max_length: Optional[int] = None,
|
|
194
|
+
doc_max_length: Optional[int] = None,
|
|
195
|
+
article_key: str = "source",
|
|
196
|
+
summary_key: str = "target",
|
|
197
|
+
splits: Optional[Dict[str, str]] = None,
|
|
198
|
+
):
|
|
199
|
+
"""
|
|
200
|
+
Initializes summarization scenario.
|
|
201
|
+
Args:
|
|
202
|
+
dataset_name: String identifier for dataset. Currently
|
|
203
|
+
supported options ["vietnews", "wikilingua"].
|
|
204
|
+
revision: String identifier for dataset version.
|
|
205
|
+
subset: Dataset subset to use. Defaults to "".
|
|
206
|
+
train_min_length: Int indicating minimum length for training
|
|
207
|
+
documents. Training examples smaller than
|
|
208
|
+
train_min_length will be filtered out.
|
|
209
|
+
Useful for preventing the adapter from sampling
|
|
210
|
+
really small documents.
|
|
211
|
+
train_max_length: Int indicating maximum length for training
|
|
212
|
+
documents. Training examples larger than
|
|
213
|
+
train_max_length will be filtered out.
|
|
214
|
+
Useful for preventing the adapter from
|
|
215
|
+
sampling really large documents.
|
|
216
|
+
doc_max_length: Int indicating the maximum length to truncate
|
|
217
|
+
documents. Documents in all splits will be
|
|
218
|
+
truncated to doc_max_length tokens.
|
|
219
|
+
NOTE: Currently uses whitespace tokenization.
|
|
220
|
+
article_key: String key for article text in dataset. Defaults to "source".
|
|
221
|
+
summary_key: String key for summary text in dataset. Defaults to "target".
|
|
222
|
+
splits: Dict containing split names and corresponding split. If
|
|
223
|
+
None, defaults to {"train": TRAIN_SPLIT, "validation": VALID_SPLIT, "test": TEST_SPLIT}.
|
|
224
|
+
"""
|
|
225
|
+
super().__init__()
|
|
226
|
+
self.dataset_name = dataset_name
|
|
227
|
+
self.revision = revision
|
|
228
|
+
self.subset = subset
|
|
229
|
+
self.train_min_length = train_min_length
|
|
230
|
+
self.train_max_length = train_max_length
|
|
231
|
+
self.doc_max_length = doc_max_length
|
|
232
|
+
self.article_key = article_key
|
|
233
|
+
self.summary_key = summary_key
|
|
234
|
+
self.splits = splits
|
|
235
|
+
|
|
236
|
+
def _clean_and_truncate(self, text: str, max_length: Optional[int] = None) -> str:
|
|
237
|
+
return " ".join(text.split()[:max_length])
|
|
238
|
+
|
|
239
|
+
def get_instances_for_splits(self, splits: Dict[str, str]) -> List[Instance]:
|
|
240
|
+
"""
|
|
241
|
+
Helper for generating instances for a split.
|
|
242
|
+
Args:
|
|
243
|
+
splits (dict): Which splits to partition the data into.
|
|
244
|
+
Returns:
|
|
245
|
+
List[Instance]: Instances from the file for the specified split.
|
|
246
|
+
"""
|
|
247
|
+
instances: List[Instance] = []
|
|
248
|
+
dataset = load_dataset(
|
|
249
|
+
self.dataset_name,
|
|
250
|
+
self.subset,
|
|
251
|
+
revision=self.revision,
|
|
252
|
+
trust_remote_code=True,
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
for dataset_split_name, helm_split_name in splits.items():
|
|
256
|
+
if dataset_split_name not in dataset:
|
|
257
|
+
raise ValueError(f"Could not find split {dataset_split_name} in dataset {self.dataset_name}")
|
|
258
|
+
|
|
259
|
+
for sample in dataset[dataset_split_name]:
|
|
260
|
+
article: str = self._clean_and_truncate(sample[self.article_key], self.doc_max_length)
|
|
261
|
+
summary: str = self._clean_and_truncate(sample[self.summary_key])
|
|
262
|
+
|
|
263
|
+
if helm_split_name == "train":
|
|
264
|
+
art_len = len(article.split())
|
|
265
|
+
if self.train_max_length and art_len > self.train_max_length:
|
|
266
|
+
continue
|
|
267
|
+
if self.train_min_length and art_len < self.train_min_length:
|
|
268
|
+
continue
|
|
269
|
+
|
|
270
|
+
instances.append(
|
|
271
|
+
Instance(
|
|
272
|
+
input=Input(text=article),
|
|
273
|
+
references=[Reference(Output(text=summary), tags=[CORRECT_TAG])],
|
|
274
|
+
split=helm_split_name,
|
|
275
|
+
)
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
return instances
|
|
279
|
+
|
|
280
|
+
def get_instances(self, output_path: str) -> List[Instance]:
|
|
281
|
+
if self.splits is None:
|
|
282
|
+
splits = {"train": TRAIN_SPLIT, "validation": VALID_SPLIT, "test": TEST_SPLIT}
|
|
283
|
+
else:
|
|
284
|
+
splits = {}
|
|
285
|
+
if "train" in self.splits:
|
|
286
|
+
splits[self.splits[TRAIN_SPLIT]] = TRAIN_SPLIT
|
|
287
|
+
if "validation" in self.splits:
|
|
288
|
+
splits[self.splits[VALID_SPLIT]] = VALID_SPLIT
|
|
289
|
+
if "test" in self.splits:
|
|
290
|
+
splits[self.splits[TEST_SPLIT]] = TEST_SPLIT
|
|
291
|
+
|
|
292
|
+
instances: List[Instance] = self.get_instances_for_splits(splits=splits)
|
|
293
|
+
return instances
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
class MELTSummarizationVietnewsScenario(MELTSummarizationScenario):
|
|
297
|
+
"""
|
|
298
|
+
Scenario for summarization on Vietnews dataset.
|
|
299
|
+
Vietnews includes a collection of news articles in Vietnamese from
|
|
300
|
+
online news such as Tuoi Tre, VnExpress, and Nguoi Dua Tin between 2016 and 2019.
|
|
301
|
+
The topic of the articles is about the world, news, law, and business.
|
|
302
|
+
The dataset also contains the corresponding summary for each article.
|
|
303
|
+
"""
|
|
304
|
+
|
|
305
|
+
name = "melt_summarization_vietnews"
|
|
306
|
+
description = (
|
|
307
|
+
"Vietnews is a Vietnamese news summarization dataset collected from online news articles between 2016 and 2019."
|
|
308
|
+
)
|
|
309
|
+
tags = ["summarization"]
|
|
310
|
+
|
|
311
|
+
def __init__(self, **kwargs):
|
|
312
|
+
super().__init__(
|
|
313
|
+
dataset_name="Yuhthe/vietnews",
|
|
314
|
+
revision="c391150e7541839d0f07d9ea89fe00005618a8f7",
|
|
315
|
+
article_key="article",
|
|
316
|
+
summary_key="abstract",
|
|
317
|
+
splits={
|
|
318
|
+
TRAIN_SPLIT: "train",
|
|
319
|
+
VALID_SPLIT: "validation",
|
|
320
|
+
TEST_SPLIT: "test",
|
|
321
|
+
},
|
|
322
|
+
**kwargs,
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
class MELTSummarizationWikilinguaScenario(MELTSummarizationScenario):
|
|
327
|
+
"""
|
|
328
|
+
Scenario for summarization on Wikilingua dataset.
|
|
329
|
+
Wikilingua is a multilingual summarization dataset.
|
|
330
|
+
In this scenario, we are using the Vietnamese subset of the Wikilingua dataset.
|
|
331
|
+
"""
|
|
332
|
+
|
|
333
|
+
name = "melt_summarization_wikilingua"
|
|
334
|
+
description = "Wikilingua is a multilingual summarization dataset."
|
|
335
|
+
tags = ["summarization"]
|
|
336
|
+
|
|
337
|
+
def __init__(self, **kwargs):
|
|
338
|
+
super().__init__(
|
|
339
|
+
dataset_name="GEM/wiki_lingua",
|
|
340
|
+
revision="af5d0f00b59a6933165c97b384f50d8b563c314d",
|
|
341
|
+
article_key="source",
|
|
342
|
+
summary_key="target",
|
|
343
|
+
splits={
|
|
344
|
+
TRAIN_SPLIT: "train",
|
|
345
|
+
VALID_SPLIT: "validation",
|
|
346
|
+
TEST_SPLIT: "test",
|
|
347
|
+
},
|
|
348
|
+
**kwargs,
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
class MELTMATHScenario(Scenario):
|
|
353
|
+
"""
|
|
354
|
+
The MATH dataset from the paper
|
|
355
|
+
"Measuring Mathematical Problem Solving With the MATH Dataset"
|
|
356
|
+
by Hendrycks et al. (2021):
|
|
357
|
+
https://arxiv.org/pdf/2103.03874.pdf
|
|
358
|
+
|
|
359
|
+
Example input, using official examples:
|
|
360
|
+
|
|
361
|
+
```
|
|
362
|
+
Given a mathematics problem, determine the answer. Simplify your answer as much as possible.
|
|
363
|
+
###
|
|
364
|
+
Problem: What is $\left(\frac{7}{8}\right)^3 \cdot \left(\frac{7}{8}\right)^{-3}$?
|
|
365
|
+
Answer: $1$
|
|
366
|
+
###
|
|
367
|
+
Problem: In how many ways can 4 books be selected from a shelf of 6 books if the order in which the books are selected does not matter?
|
|
368
|
+
Answer: $15$
|
|
369
|
+
###
|
|
370
|
+
Problem: Find the distance between the points $(2,1,-4)$ and $(5,8,-3).$
|
|
371
|
+
Answer: $\sqrt{59}$
|
|
372
|
+
###
|
|
373
|
+
Problem: The faces of an octahedral die are labeled with digits $1$ through $8$. What is the probability, expressed as a common fraction, of rolling a sum of $15$ with a pair of such octahedral dice?
|
|
374
|
+
Answer: $\frac{1}{32}$
|
|
375
|
+
###
|
|
376
|
+
Problem: The first three terms of an arithmetic sequence are 1, 10 and 19, respectively. What is the value of the 21st term?
|
|
377
|
+
Answer: $181$
|
|
378
|
+
###
|
|
379
|
+
Problem: Calculate $6 \cdot 8\frac{1}{3}
|
|
380
|
+
Answer: $50$
|
|
381
|
+
###
|
|
382
|
+
Problem: When the binary number $100101110010_2$ is divided by 4, what is the remainder (give your answer in base 10)?
|
|
383
|
+
Answer: $2$
|
|
384
|
+
###
|
|
385
|
+
Problem: How many zeros are at the end of the product 25 $\times$ 240?
|
|
386
|
+
Answer: $3$
|
|
387
|
+
###
|
|
388
|
+
Problem: What is $\dbinom{n}{n}$ for any positive integer $n$?
|
|
389
|
+
Answer: $
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
Example expected output
|
|
393
|
+
|
|
394
|
+
```
|
|
395
|
+
1$
|
|
396
|
+
```
|
|
397
|
+
""" # noqa
|
|
398
|
+
|
|
399
|
+
name = "MATH"
|
|
400
|
+
description = "Mathematical Problem Solving in Vietnamese"
|
|
401
|
+
tags = ["knowledge", "reasoning"]
|
|
402
|
+
|
|
403
|
+
subjects_mapping = {
|
|
404
|
+
"number_theory": "Number Theory",
|
|
405
|
+
"intermediate_algebra": "Intermediate Algebra",
|
|
406
|
+
"algebra": "Algebra",
|
|
407
|
+
"prealgebra": "Prealgebra",
|
|
408
|
+
"geometry": "Geometry",
|
|
409
|
+
"counting_and_probability": "Counting & Probability",
|
|
410
|
+
"precalculus": "Precalculus",
|
|
411
|
+
}
|
|
412
|
+
levels = ["1", "2", "3", "4", "5"]
|
|
413
|
+
|
|
414
|
+
def __init__(
|
|
415
|
+
self, subject: str, level: str, use_official_examples: bool = False, use_chain_of_thought: bool = False
|
|
416
|
+
):
|
|
417
|
+
super().__init__()
|
|
418
|
+
self.subject_name: str = MELTMATHScenario.subjects_mapping[subject]
|
|
419
|
+
self.subject: str = subject
|
|
420
|
+
self.level: str = f"Level {level}"
|
|
421
|
+
self.use_official_examples: bool = use_official_examples
|
|
422
|
+
self.use_chain_of_thought: bool = use_chain_of_thought
|
|
423
|
+
if use_chain_of_thought:
|
|
424
|
+
assert not use_official_examples, "Cannot use official examples when use_chain_of_thought is True."
|
|
425
|
+
|
|
426
|
+
def get_instances(self, output_path: str) -> List[Instance]:
|
|
427
|
+
dataset = {}
|
|
428
|
+
cache_dir = os.path.join(output_path, "data")
|
|
429
|
+
ensure_directory_exists(cache_dir)
|
|
430
|
+
dataset = load_dataset(
|
|
431
|
+
"ura-hcmut/Vietnamese-MATH",
|
|
432
|
+
self.subject,
|
|
433
|
+
trust_remote_code=True,
|
|
434
|
+
cache_dir=cache_dir,
|
|
435
|
+
revision="f8edc7f8e2873e8b271391d4489c1eedc5456f40",
|
|
436
|
+
)
|
|
437
|
+
|
|
438
|
+
instances = []
|
|
439
|
+
for split, split_name in zip([TRAIN_SPLIT, TEST_SPLIT], ["train", "test"]):
|
|
440
|
+
if split == TRAIN_SPLIT and self.use_official_examples:
|
|
441
|
+
train_instances = [
|
|
442
|
+
("Kết quả của $\left(\\frac{7}{8}\\right)^3 \cdot \left(\\frac{7}{8}\\right)^{-3}$ là gì?", "1"),
|
|
443
|
+
(
|
|
444
|
+
"Có bao nhiêu cách chọn 4 quyển sách từ một kệ sách có 6 quyển,"
|
|
445
|
+
+ " nếu thứ tự các cuốn sách được chọn không quan trọng?",
|
|
446
|
+
"15",
|
|
447
|
+
),
|
|
448
|
+
("Tìm khoảng cách giữa các điểm $(2,1,-4)$ và $(5,8,-3).$", "\sqrt{59}"),
|
|
449
|
+
(
|
|
450
|
+
"Các mặt của khối xúc xắc bát diện được dán nhãn bằng các số từ $1$ đến $8$."
|
|
451
|
+
+ " Xác suất tung một cặp xúc xắc bát diện để được tổng số bằng $15$ là bao nhiêu?"
|
|
452
|
+
+ " Biểu diễn kết quả dưới dạng phân số tối giản.",
|
|
453
|
+
"\\frac{1}{32}",
|
|
454
|
+
),
|
|
455
|
+
(
|
|
456
|
+
"Ba số hạng đầu tiên của một dãy số cộng lần lượt là 1, 10 và 19."
|
|
457
|
+
+ " Giá trị của số hạng thứ 21 là?",
|
|
458
|
+
"181",
|
|
459
|
+
),
|
|
460
|
+
("Tính $6 \\cdot 8\\frac{1}{3}", "50"),
|
|
461
|
+
(
|
|
462
|
+
"Khi chia số nhị phân $100101110010_2$ cho 4,"
|
|
463
|
+
+ " phần dư của phép chia là bao nhiêu (biểu diễn kết quả với cơ số 10)?",
|
|
464
|
+
"2",
|
|
465
|
+
),
|
|
466
|
+
("Có bao nhiêu số 0 ở cuối kết quả của tích 25 $\\times$ 240?", "3"),
|
|
467
|
+
]
|
|
468
|
+
dataset[TRAIN_SPLIT] = [
|
|
469
|
+
{"problem_vi": problem, "answer_vi": answer} for problem, answer in train_instances
|
|
470
|
+
]
|
|
471
|
+
|
|
472
|
+
else:
|
|
473
|
+
examples = dataset[split].filter(lambda example: example["level"] == self.level)
|
|
474
|
+
list_answers = []
|
|
475
|
+
|
|
476
|
+
for example in examples:
|
|
477
|
+
# Sanity check that we filtered correctly
|
|
478
|
+
assert (
|
|
479
|
+
example["type"] == self.subject_name and example["level"] == self.level
|
|
480
|
+
), f"Wrong example was included after filtering: {example}"
|
|
481
|
+
|
|
482
|
+
if self.use_chain_of_thought:
|
|
483
|
+
answer = example["solution_vi"]
|
|
484
|
+
else:
|
|
485
|
+
maybe_answer = get_answer(example["solution_vi"])
|
|
486
|
+
if maybe_answer is None:
|
|
487
|
+
maybe_answer = "Không có đáp án"
|
|
488
|
+
answer = maybe_answer
|
|
489
|
+
list_answers.append(answer)
|
|
490
|
+
|
|
491
|
+
# Add column answer_vi to examples
|
|
492
|
+
dataset[split] = examples.add_column("answer_vi", list_answers)
|
|
493
|
+
|
|
494
|
+
for example in dataset[split]:
|
|
495
|
+
instance = Instance(
|
|
496
|
+
input=Input(text=example["problem_vi"]),
|
|
497
|
+
references=[Reference(Output(text=example["answer_vi"]), tags=[CORRECT_TAG])],
|
|
498
|
+
split=split,
|
|
499
|
+
)
|
|
500
|
+
instances.append(instance)
|
|
501
|
+
|
|
502
|
+
return instances
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
class MELTTextClassificationScenario(Scenario):
|
|
506
|
+
name = "melt_text_classification"
|
|
507
|
+
description = "Text Classification scenario."
|
|
508
|
+
tags = ["text_classification"]
|
|
509
|
+
|
|
510
|
+
def __init__(
|
|
511
|
+
self,
|
|
512
|
+
dataset_name: str,
|
|
513
|
+
revision: str,
|
|
514
|
+
subset: Optional[str] = None,
|
|
515
|
+
text_key: str = "text",
|
|
516
|
+
label_key: str = "label",
|
|
517
|
+
splits: Optional[Dict[str, str]] = None,
|
|
518
|
+
):
|
|
519
|
+
"""
|
|
520
|
+
Initializes the question answering scenario.
|
|
521
|
+
|
|
522
|
+
Args:
|
|
523
|
+
dataset_name: The name of the dataset.
|
|
524
|
+
revision: The revision of the dataset to use.
|
|
525
|
+
subset: The subset of the dataset to use. Defaults to "".
|
|
526
|
+
splits: The splits to use for the dataset. Defaults to None.
|
|
527
|
+
"""
|
|
528
|
+
super().__init__()
|
|
529
|
+
self.dataset_name = dataset_name
|
|
530
|
+
self.subset = subset
|
|
531
|
+
self.revision = revision
|
|
532
|
+
self.splits = splits
|
|
533
|
+
|
|
534
|
+
@abstractmethod
|
|
535
|
+
def process_example(self, sample: dict) -> Tuple[str, List[str]]:
|
|
536
|
+
"""
|
|
537
|
+
Given an sample from the dataset, create the input text and
|
|
538
|
+
list of answers for the instance.
|
|
539
|
+
"""
|
|
540
|
+
pass
|
|
541
|
+
|
|
542
|
+
def get_instances_for_splits(self, splits: Dict[str, str]) -> List[Instance]:
|
|
543
|
+
"""
|
|
544
|
+
Helper for generating instances for a split.
|
|
545
|
+
Args:
|
|
546
|
+
splits (dict): Which splits to partition the data into.
|
|
547
|
+
Returns:
|
|
548
|
+
List[Instance]: Instances from the file for the specified split.
|
|
549
|
+
"""
|
|
550
|
+
instances: List[Instance] = []
|
|
551
|
+
dataset = load_dataset(
|
|
552
|
+
self.dataset_name,
|
|
553
|
+
self.subset,
|
|
554
|
+
revision=self.revision,
|
|
555
|
+
trust_remote_code=True,
|
|
556
|
+
)
|
|
557
|
+
for dataset_split_name, helm_split_name in splits.items():
|
|
558
|
+
if dataset_split_name not in dataset:
|
|
559
|
+
raise ValueError(f"Could not find split {dataset_split_name} in dataset {self.dataset_name}")
|
|
560
|
+
|
|
561
|
+
for sample in dataset[dataset_split_name]:
|
|
562
|
+
prompt, answers = self.process_example(sample)
|
|
563
|
+
instance = Instance(
|
|
564
|
+
input=Input(text=prompt),
|
|
565
|
+
references=[Reference(Output(text=answer), tags=[CORRECT_TAG]) for answer in answers],
|
|
566
|
+
split=helm_split_name,
|
|
567
|
+
)
|
|
568
|
+
instances.append(instance)
|
|
569
|
+
|
|
570
|
+
return instances
|
|
571
|
+
|
|
572
|
+
def get_instances(self, output_path: str) -> List[Instance]:
|
|
573
|
+
if self.splits is None:
|
|
574
|
+
splits = {"train": TRAIN_SPLIT, "validation": VALID_SPLIT, "test": TEST_SPLIT}
|
|
575
|
+
else:
|
|
576
|
+
splits = {}
|
|
577
|
+
if "train" in self.splits:
|
|
578
|
+
splits[self.splits[TRAIN_SPLIT]] = TRAIN_SPLIT
|
|
579
|
+
if "validation" in self.splits:
|
|
580
|
+
splits[self.splits[VALID_SPLIT]] = VALID_SPLIT
|
|
581
|
+
if "test" in self.splits:
|
|
582
|
+
splits[self.splits[TEST_SPLIT]] = TEST_SPLIT
|
|
583
|
+
|
|
584
|
+
instances: List[Instance] = self.get_instances_for_splits(splits=splits)
|
|
585
|
+
return instances
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
class MELTTextClassificationVSMECScenario(MELTTextClassificationScenario):
|
|
589
|
+
"""
|
|
590
|
+
Scenario for the UIT-VSMEC dataset.
|
|
591
|
+
The UIT-VSMEC dataset is a Vietnamese emotion-labeled corpus consisting of
|
|
592
|
+
6,927 human-annotated sentences collected from social media, categorized
|
|
593
|
+
into six emotions: sadness, enjoyment, anger, disgust, fear, and surprise.
|
|
594
|
+
"""
|
|
595
|
+
|
|
596
|
+
name = "melt_text_classification_vsmec"
|
|
597
|
+
description = "UIT-VSMEC dataset for emotion classification."
|
|
598
|
+
tags = ["text_classification"]
|
|
599
|
+
|
|
600
|
+
def __init__(self):
|
|
601
|
+
super().__init__(
|
|
602
|
+
dataset_name="ura-hcmut/UIT-VSMEC",
|
|
603
|
+
revision="ab642b189eff31fdb781cca7c4c34dee3ee0f1de",
|
|
604
|
+
splits={
|
|
605
|
+
TRAIN_SPLIT: "train",
|
|
606
|
+
VALID_SPLIT: "validation",
|
|
607
|
+
TEST_SPLIT: "test",
|
|
608
|
+
},
|
|
609
|
+
)
|
|
610
|
+
self.text_key = "Sentence"
|
|
611
|
+
self.label_key = "Emotion"
|
|
612
|
+
|
|
613
|
+
def process_example(self, sample: dict) -> Tuple[str, List[str]]:
|
|
614
|
+
"""
|
|
615
|
+
Given an sample from the dataset, create the input text and
|
|
616
|
+
list of answers for the instance.
|
|
617
|
+
"""
|
|
618
|
+
return sample[self.text_key], [sample[self.label_key].lower()]
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
class MELTTextClassificationPhoATISScenario(MELTTextClassificationScenario):
|
|
622
|
+
"""
|
|
623
|
+
Scenario for the PhoATIS dataset.
|
|
624
|
+
The PhoATIS dataset is a Vietnamese benchmark for intent detection and slot filling,
|
|
625
|
+
consisting of 5,871 fluent utterances collected from task-oriented dialogue systems.
|
|
626
|
+
It was later extended with manual disfluency annotations to create a disfluent variant,
|
|
627
|
+
enabling research on the impact of disfluencies in spoken language understanding for Vietnamese.
|
|
628
|
+
"""
|
|
629
|
+
|
|
630
|
+
name = "melt_text_classification_phoatis"
|
|
631
|
+
description = "PhoATIS dataset for intent detection of flight booking."
|
|
632
|
+
tags = ["text_classification"]
|
|
633
|
+
|
|
634
|
+
def __init__(self):
|
|
635
|
+
super().__init__(
|
|
636
|
+
dataset_name="ura-hcmut/PhoATIS",
|
|
637
|
+
revision="bd026c9b276d7fb083d19ec3d6870fca90e1834f",
|
|
638
|
+
splits={
|
|
639
|
+
TRAIN_SPLIT: "train",
|
|
640
|
+
VALID_SPLIT: "validation",
|
|
641
|
+
TEST_SPLIT: "test",
|
|
642
|
+
},
|
|
643
|
+
)
|
|
644
|
+
self.text_key = "text"
|
|
645
|
+
self.label_key = "label"
|
|
646
|
+
|
|
647
|
+
def process_example(self, sample: dict) -> Tuple[str, List[str]]:
|
|
648
|
+
"""
|
|
649
|
+
Given an sample from the dataset, create the input text and
|
|
650
|
+
list of answers for the instance.
|
|
651
|
+
"""
|
|
652
|
+
return sample[self.text_key], sample[self.label_key].lower().split("#")
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
class MELTTSentimentAnalysisVLSPScenario(MELTTextClassificationScenario):
|
|
656
|
+
"""
|
|
657
|
+
Scenario for the VLSP 2016 sentiment analysis dataset.
|
|
658
|
+
The VLSP2016 dataset is a Vietnamese sentiment analysis corpus consisting of
|
|
659
|
+
short user-generated reviews from social media, each labeled with an overall
|
|
660
|
+
sentiment of positive, negative, or neutral. It was developed to support polarity
|
|
661
|
+
classification and benchmark Vietnamese sentiment analysis systems through the
|
|
662
|
+
VLSP 2016 evaluation campaign.
|
|
663
|
+
"""
|
|
664
|
+
|
|
665
|
+
name = "melt_sentiment_analysis_vlsp"
|
|
666
|
+
description = "VLSP 2016 contains public comments from social media, used for sentiment analysis."
|
|
667
|
+
tags = ["sentiment_analysis"]
|
|
668
|
+
|
|
669
|
+
def __init__(self):
|
|
670
|
+
super().__init__(
|
|
671
|
+
dataset_name="ura-hcmut/vlsp2016",
|
|
672
|
+
revision="9531ec0ccabcafb7d51020fe69d8f9faebb91953",
|
|
673
|
+
splits={
|
|
674
|
+
TRAIN_SPLIT: "train",
|
|
675
|
+
TEST_SPLIT: "test",
|
|
676
|
+
},
|
|
677
|
+
)
|
|
678
|
+
self.text_key = "Data"
|
|
679
|
+
self.label_key = "Class"
|
|
680
|
+
|
|
681
|
+
def process_example(self, sample: dict) -> Tuple[str, List[str]]:
|
|
682
|
+
"""
|
|
683
|
+
Given an sample from the dataset, create the input text and
|
|
684
|
+
list of answers for the instance.
|
|
685
|
+
"""
|
|
686
|
+
|
|
687
|
+
return sample[self.text_key], [sample[self.label_key].lower()]
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
class MELTTSentimentAnalysisVSFCScenario(MELTTextClassificationScenario):
|
|
691
|
+
"""
|
|
692
|
+
Scenario for the UIT-VSFC dataset.
|
|
693
|
+
The UIT-VSFC dataset is a Vietnamese corpus of over 16,000 student feedback sentences,
|
|
694
|
+
annotated for both sentiment-based (positive, negative, neutral) and topic-based classifications.
|
|
695
|
+
It supports interdisciplinary research at the intersection of sentiment analysis and education,
|
|
696
|
+
with high inter-annotator agreement and strong baseline performance using a Maximum Entropy classifier.
|
|
697
|
+
"""
|
|
698
|
+
|
|
699
|
+
name = "melt_sentiment_analysis_vsfc"
|
|
700
|
+
description = "UIT-VSFC dataset for analyzing sentiment of student feedback."
|
|
701
|
+
tags = ["sentiment_analysis"]
|
|
702
|
+
|
|
703
|
+
def __init__(self):
|
|
704
|
+
super().__init__(
|
|
705
|
+
dataset_name="ura-hcmut/UIT-VSFC",
|
|
706
|
+
revision="c572aed01a811a1dbc68e9aed9f9e684980a10a2",
|
|
707
|
+
splits={
|
|
708
|
+
TRAIN_SPLIT: "train",
|
|
709
|
+
VALID_SPLIT: "validation",
|
|
710
|
+
TEST_SPLIT: "test",
|
|
711
|
+
},
|
|
712
|
+
)
|
|
713
|
+
self.text_key = "text"
|
|
714
|
+
self.label_key = "label"
|
|
715
|
+
|
|
716
|
+
def process_example(self, sample: dict) -> Tuple[str, List[str]]:
|
|
717
|
+
"""
|
|
718
|
+
Given an sample from the dataset, create the input text and
|
|
719
|
+
list of answers for the instance.
|
|
720
|
+
"""
|
|
721
|
+
|
|
722
|
+
return sample[self.text_key], [sample[self.label_key].lower()]
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
class MELTToxicityDetectionViHSDScenario(MELTTextClassificationScenario):
|
|
726
|
+
"""
|
|
727
|
+
Scenario for the UIT-ViHSD dataset.
|
|
728
|
+
"""
|
|
729
|
+
|
|
730
|
+
name = "melt_toxicity_detection_vihsd"
|
|
731
|
+
description = "UIT-ViHSD dataset for toxicity detection."
|
|
732
|
+
tags = ["toxicity_detection"]
|
|
733
|
+
|
|
734
|
+
def __init__(self):
|
|
735
|
+
super().__init__(
|
|
736
|
+
dataset_name="ura-hcmut/UIT-ViHSD",
|
|
737
|
+
revision="16c4f67cf509d4f9f36ca5b63c5503c7c8830557",
|
|
738
|
+
splits={
|
|
739
|
+
TRAIN_SPLIT: "train",
|
|
740
|
+
VALID_SPLIT: "validation",
|
|
741
|
+
TEST_SPLIT: "test",
|
|
742
|
+
},
|
|
743
|
+
)
|
|
744
|
+
self.label_mapping = {
|
|
745
|
+
0: "clean",
|
|
746
|
+
1: "offensive",
|
|
747
|
+
2: "hate",
|
|
748
|
+
}
|
|
749
|
+
self.text_key = "free_text"
|
|
750
|
+
self.label_key = "label_id"
|
|
751
|
+
|
|
752
|
+
def process_example(self, sample: dict) -> Tuple[str, List[str]]:
|
|
753
|
+
"""
|
|
754
|
+
Given an sample from the dataset, create the input text and
|
|
755
|
+
list of answers for the instance.
|
|
756
|
+
"""
|
|
757
|
+
label = sample[self.label_key]
|
|
758
|
+
return sample[self.text_key], [self.label_mapping[label]]
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
class MELTToxicityDetectionViCTSDScenario(MELTTextClassificationScenario):
|
|
762
|
+
"""
|
|
763
|
+
Scenario for the UIT-ViCTSD dataset.
|
|
764
|
+
"""
|
|
765
|
+
|
|
766
|
+
name = "melt_toxicity_detection_victsd"
|
|
767
|
+
description = "UIT-ViCTSD dataset for toxicity detection."
|
|
768
|
+
tags = ["toxicity_detection"]
|
|
769
|
+
|
|
770
|
+
def __init__(self):
|
|
771
|
+
super().__init__(
|
|
772
|
+
dataset_name="tarudesu/ViCTSD",
|
|
773
|
+
revision="65a073f2c48401410b264213229a6c52417f367a",
|
|
774
|
+
splits={
|
|
775
|
+
TRAIN_SPLIT: "train",
|
|
776
|
+
VALID_SPLIT: "validation",
|
|
777
|
+
TEST_SPLIT: "test",
|
|
778
|
+
},
|
|
779
|
+
)
|
|
780
|
+
self.label_mapping = {
|
|
781
|
+
0: "clean",
|
|
782
|
+
1: "toxic",
|
|
783
|
+
}
|
|
784
|
+
self.text_key = "Comment"
|
|
785
|
+
self.label_key = "Toxicity"
|
|
786
|
+
|
|
787
|
+
def process_example(self, sample: dict) -> Tuple[str, List[str]]:
|
|
788
|
+
"""
|
|
789
|
+
Given an sample from the dataset, create the input text and
|
|
790
|
+
list of answers for the instance.
|
|
791
|
+
"""
|
|
792
|
+
label = sample[self.label_key]
|
|
793
|
+
return sample[self.text_key], [self.label_mapping[label]]
|