crfm-helm 0.5.1__py3-none-any.whl → 0.5.3__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.1.dist-info → crfm_helm-0.5.3.dist-info}/METADATA +41 -57
- {crfm_helm-0.5.1.dist-info → crfm_helm-0.5.3.dist-info}/RECORD +197 -152
- {crfm_helm-0.5.1.dist-info → crfm_helm-0.5.3.dist-info}/WHEEL +1 -1
- helm/benchmark/adaptation/adapter_spec.py +32 -31
- helm/benchmark/adaptation/adapters/multiple_choice_joint_adapter.py +12 -5
- helm/benchmark/adaptation/adapters/test_generation_adapter.py +12 -12
- helm/benchmark/adaptation/adapters/test_language_modeling_adapter.py +8 -8
- helm/benchmark/adaptation/adapters/test_multiple_choice_joint_adapter.py +77 -9
- helm/benchmark/adaptation/common_adapter_specs.py +2 -0
- helm/benchmark/annotation/air_bench_annotator.py +64 -0
- helm/benchmark/annotation/annotator_factory.py +6 -0
- helm/benchmark/annotation/anthropic_red_team_annotator.py +70 -0
- helm/benchmark/annotation/call_center_annotator.py +247 -0
- helm/benchmark/annotation/financebench_annotator.py +79 -0
- helm/benchmark/annotation/harm_bench_annotator.py +68 -0
- helm/benchmark/annotation/{image2structure → image2struct}/latex_compiler_annotator.py +2 -2
- helm/benchmark/annotation/{image2structure → image2struct}/lilypond_compiler_annotator.py +5 -3
- helm/benchmark/annotation/{image2structure → image2struct}/webpage_compiler_annotator.py +5 -5
- helm/benchmark/annotation/live_qa_annotator.py +71 -0
- helm/benchmark/annotation/medication_qa_annotator.py +68 -0
- helm/benchmark/annotation/model_as_judge.py +45 -0
- helm/benchmark/annotation/simple_safety_tests_annotator.py +64 -0
- helm/benchmark/annotation/xstest_annotator.py +110 -0
- helm/benchmark/augmentations/translate_perturbation.py +1 -0
- helm/benchmark/huggingface_registration.py +16 -6
- helm/benchmark/metrics/air_bench_metrics.py +56 -0
- helm/benchmark/metrics/annotation_metrics.py +108 -0
- helm/benchmark/metrics/bhasa_metrics.py +188 -0
- helm/benchmark/metrics/bhasa_metrics_specs.py +10 -0
- helm/benchmark/metrics/code_metrics_helper.py +11 -1
- helm/benchmark/metrics/fin_qa_metrics.py +60 -0
- helm/benchmark/metrics/fin_qa_metrics_helper.py +398 -0
- helm/benchmark/metrics/gpt4v_originality_critique_metrics.py +126 -0
- helm/benchmark/metrics/instruction_following_critique_metrics.py +1 -0
- helm/benchmark/metrics/live_qa_metrics.py +23 -0
- helm/benchmark/metrics/medication_qa_metrics.py +23 -0
- helm/benchmark/metrics/prometheus_vision_critique_metrics.py +185 -0
- helm/benchmark/metrics/reka_vibe_critique_metrics.py +158 -0
- helm/benchmark/metrics/safety_metrics.py +57 -0
- helm/benchmark/metrics/summac/model_summac.py +3 -3
- helm/benchmark/metrics/tokens/test_ai21_token_cost_estimator.py +2 -2
- helm/benchmark/metrics/tokens/test_openai_token_cost_estimator.py +4 -4
- helm/benchmark/metrics/unitxt_metrics.py +20 -10
- helm/benchmark/metrics/vision_language/emd_utils.py +4 -0
- helm/benchmark/metrics/vision_language/image_metrics.py +30 -72
- helm/benchmark/metrics/vision_language/image_utils.py +1 -1
- helm/benchmark/model_metadata_registry.py +3 -3
- helm/benchmark/presentation/schema.py +54 -4
- helm/benchmark/presentation/test_run_entry.py +1 -0
- helm/benchmark/presentation/test_schema.py +11 -0
- helm/benchmark/run.py +31 -2
- helm/benchmark/run_expander.py +113 -10
- helm/benchmark/run_spec_factory.py +4 -0
- helm/benchmark/run_specs/air_bench_run_specs.py +40 -0
- helm/benchmark/run_specs/bhasa_run_specs.py +638 -0
- helm/benchmark/run_specs/call_center_run_specs.py +152 -0
- helm/benchmark/run_specs/classic_run_specs.py +15 -11
- helm/benchmark/run_specs/decodingtrust_run_specs.py +11 -9
- helm/benchmark/run_specs/experimental_run_specs.py +85 -0
- helm/benchmark/run_specs/finance_run_specs.py +110 -0
- helm/benchmark/run_specs/safety_run_specs.py +154 -0
- helm/benchmark/run_specs/vlm_run_specs.py +251 -57
- helm/benchmark/scenarios/air_bench_scenario.py +50 -0
- helm/benchmark/scenarios/anthropic_red_team_scenario.py +71 -0
- helm/benchmark/scenarios/banking77_scenario.py +51 -0
- helm/benchmark/scenarios/bhasa_scenario.py +1798 -0
- helm/benchmark/scenarios/call_center_scenario.py +84 -0
- helm/benchmark/scenarios/ci_mcqa_scenario.py +80 -0
- helm/benchmark/scenarios/decodingtrust_stereotype_bias_scenario.py +2 -1
- helm/benchmark/scenarios/entity_data_imputation_scenario.py +8 -2
- helm/benchmark/scenarios/ewok_scenario.py +116 -0
- helm/benchmark/scenarios/fin_qa_scenario.py +119 -0
- helm/benchmark/scenarios/financebench_scenario.py +53 -0
- helm/benchmark/scenarios/harm_bench_scenario.py +59 -0
- helm/benchmark/scenarios/scenario.py +1 -1
- helm/benchmark/scenarios/simple_safety_tests_scenario.py +33 -0
- helm/benchmark/scenarios/test_air_bench_scenario.py +27 -0
- helm/benchmark/scenarios/test_commonsense_scenario.py +21 -0
- helm/benchmark/scenarios/test_ewok_scenario.py +25 -0
- helm/benchmark/scenarios/test_financebench_scenario.py +26 -0
- helm/benchmark/scenarios/test_gsm_scenario.py +31 -0
- helm/benchmark/scenarios/test_legalbench_scenario.py +30 -0
- helm/benchmark/scenarios/test_math_scenario.py +2 -8
- helm/benchmark/scenarios/test_med_qa_scenario.py +30 -0
- helm/benchmark/scenarios/test_mmlu_scenario.py +33 -0
- helm/benchmark/scenarios/test_narrativeqa_scenario.py +73 -0
- helm/benchmark/scenarios/thai_exam_scenario.py +4 -4
- helm/benchmark/scenarios/vision_language/a_okvqa_scenario.py +1 -1
- helm/benchmark/scenarios/vision_language/bingo_scenario.py +5 -5
- helm/benchmark/scenarios/vision_language/crossmodal_3600_scenario.py +2 -1
- helm/benchmark/scenarios/vision_language/exams_v_scenario.py +104 -0
- helm/benchmark/scenarios/vision_language/fair_face_scenario.py +136 -0
- helm/benchmark/scenarios/vision_language/flickr30k_scenario.py +1 -1
- helm/benchmark/scenarios/vision_language/gqa_scenario.py +2 -2
- helm/benchmark/scenarios/vision_language/hateful_memes_scenario.py +1 -1
- helm/benchmark/scenarios/vision_language/{image2structure → image2struct}/chart2csv_scenario.py +1 -1
- helm/benchmark/scenarios/vision_language/{image2structure/image2structure_scenario.py → image2struct/image2struct_scenario.py} +13 -2
- helm/benchmark/scenarios/vision_language/{image2structure → image2struct}/latex_scenario.py +3 -7
- helm/benchmark/scenarios/vision_language/{image2structure → image2struct}/musicsheet_scenario.py +1 -5
- helm/benchmark/scenarios/vision_language/{image2structure → image2struct}/utils_latex.py +31 -39
- helm/benchmark/scenarios/vision_language/{image2structure → image2struct}/webpage/driver.py +1 -1
- helm/benchmark/scenarios/vision_language/{image2structure → image2struct}/webpage/utils.py +1 -1
- helm/benchmark/scenarios/vision_language/{image2structure → image2struct}/webpage_scenario.py +44 -13
- helm/benchmark/scenarios/vision_language/math_vista_scenario.py +1 -1
- helm/benchmark/scenarios/vision_language/mementos_scenario.py +3 -3
- helm/benchmark/scenarios/vision_language/mm_safety_bench_scenario.py +2 -2
- helm/benchmark/scenarios/vision_language/mme_scenario.py +21 -18
- helm/benchmark/scenarios/vision_language/mmmu_scenario.py +1 -1
- helm/benchmark/scenarios/vision_language/pairs_scenario.py +7 -6
- helm/benchmark/scenarios/vision_language/pope_scenario.py +2 -1
- helm/benchmark/scenarios/vision_language/real_world_qa_scenario.py +57 -0
- helm/benchmark/scenarios/vision_language/seed_bench_scenario.py +7 -5
- helm/benchmark/scenarios/vision_language/unicorn_scenario.py +5 -5
- helm/benchmark/scenarios/vision_language/vibe_eval_scenario.py +98 -0
- helm/benchmark/scenarios/vision_language/viz_wiz_scenario.py +1 -1
- helm/benchmark/scenarios/vision_language/vqa_scenario.py +3 -1
- helm/benchmark/scenarios/xstest_scenario.py +35 -0
- helm/benchmark/server.py +1 -6
- helm/benchmark/static/schema_air_bench.yaml +3149 -0
- helm/benchmark/static/schema_bhasa.yaml +709 -0
- helm/benchmark/static/schema_call_center.yaml +232 -0
- helm/benchmark/static/schema_classic.yaml +3 -59
- helm/benchmark/static/schema_cleva.yaml +768 -0
- helm/benchmark/static/schema_decodingtrust.yaml +444 -0
- helm/benchmark/static/schema_ewok.yaml +367 -0
- helm/benchmark/static/schema_finance.yaml +189 -0
- helm/benchmark/static/schema_image2struct.yaml +588 -0
- helm/benchmark/static/schema_instruction_following.yaml +3 -52
- helm/benchmark/static/schema_lite.yaml +3 -61
- helm/benchmark/static/schema_medical.yaml +255 -0
- helm/benchmark/static/schema_mmlu.yaml +3 -61
- helm/benchmark/static/schema_safety.yaml +247 -0
- helm/benchmark/static/schema_tables.yaml +317 -0
- helm/benchmark/static/schema_thai.yaml +244 -0
- helm/benchmark/static/schema_unitxt.yaml +3 -61
- helm/benchmark/static/{schema_vlm.yaml → schema_vhelm.yaml} +304 -298
- helm/benchmark/static/schema_vhelm_lite.yaml +4 -59
- helm/benchmark/static_build/assets/accenture-6f97eeda.png +0 -0
- helm/benchmark/static_build/assets/air-overview-d2e6c49f.png +0 -0
- helm/benchmark/static_build/assets/aisingapore-6dfc9acf.png +0 -0
- helm/benchmark/static_build/assets/cresta-9e22b983.png +0 -0
- helm/benchmark/static_build/assets/cuhk-8c5631e9.png +0 -0
- helm/benchmark/static_build/assets/index-05c76bb1.css +1 -0
- helm/benchmark/static_build/assets/index-58f97dcd.js +10 -0
- helm/benchmark/static_build/assets/overview-74aea3d8.png +0 -0
- helm/benchmark/static_build/assets/process-flow-bd2eba96.png +0 -0
- helm/benchmark/static_build/assets/scb10x-204bd786.png +0 -0
- helm/benchmark/static_build/assets/wellsfargo-a86a6c4a.png +0 -0
- helm/benchmark/static_build/index.html +2 -2
- helm/benchmark/window_services/test_openai_window_service.py +8 -8
- helm/clients/ai21_client.py +71 -1
- helm/clients/anthropic_client.py +50 -28
- helm/clients/auto_client.py +11 -0
- helm/clients/client.py +24 -7
- helm/clients/cohere_client.py +98 -3
- helm/clients/huggingface_client.py +79 -19
- helm/clients/nvidia_nim_client.py +35 -0
- helm/clients/openai_client.py +11 -5
- helm/clients/palmyra_client.py +25 -0
- helm/clients/perspective_api_client.py +11 -6
- helm/clients/reka_client.py +189 -0
- helm/clients/test_client.py +7 -9
- helm/clients/test_huggingface_client.py +19 -3
- helm/clients/test_together_client.py +72 -2
- helm/clients/together_client.py +129 -23
- helm/clients/vertexai_client.py +62 -18
- helm/clients/vision_language/huggingface_vlm_client.py +1 -0
- helm/clients/vision_language/open_flamingo_client.py +1 -2
- helm/clients/vision_language/paligemma_client.py +146 -0
- helm/clients/vision_language/palmyra_vision_client.py +99 -0
- helm/clients/yi_client.py +31 -0
- helm/common/critique_request.py +10 -1
- helm/common/images_utils.py +25 -0
- helm/common/mongo_key_value_store.py +2 -1
- helm/common/request.py +16 -0
- helm/config/model_deployments.yaml +740 -363
- helm/config/model_metadata.yaml +824 -128
- helm/config/tokenizer_configs.yaml +207 -10
- helm/proxy/critique/model_critique_client.py +32 -4
- helm/proxy/example_queries.py +14 -21
- helm/proxy/services/server_service.py +2 -3
- helm/proxy/token_counters/test_auto_token_counter.py +2 -2
- helm/tokenizers/ai21_tokenizer.py +51 -59
- helm/tokenizers/auto_tokenizer.py +1 -1
- helm/tokenizers/cohere_tokenizer.py +29 -62
- helm/tokenizers/huggingface_tokenizer.py +35 -13
- helm/tokenizers/test_ai21_tokenizer.py +48 -0
- helm/tokenizers/test_cohere_tokenizer.py +39 -0
- helm/tokenizers/test_huggingface_tokenizer.py +5 -1
- helm/benchmark/static/benchmarking.css +0 -156
- helm/benchmark/static/benchmarking.js +0 -1705
- helm/benchmark/static/config.js +0 -3
- helm/benchmark/static/general.js +0 -122
- helm/benchmark/static/images/crfm-logo.png +0 -0
- helm/benchmark/static/images/helm-logo-simple.png +0 -0
- helm/benchmark/static/images/helm-logo.png +0 -0
- helm/benchmark/static/images/language-model-helm.png +0 -0
- helm/benchmark/static/images/organizations/ai21.png +0 -0
- helm/benchmark/static/images/organizations/anthropic.png +0 -0
- helm/benchmark/static/images/organizations/bigscience.png +0 -0
- helm/benchmark/static/images/organizations/cohere.png +0 -0
- helm/benchmark/static/images/organizations/eleutherai.png +0 -0
- helm/benchmark/static/images/organizations/google.png +0 -0
- helm/benchmark/static/images/organizations/meta.png +0 -0
- helm/benchmark/static/images/organizations/microsoft.png +0 -0
- helm/benchmark/static/images/organizations/nvidia.png +0 -0
- helm/benchmark/static/images/organizations/openai.png +0 -0
- helm/benchmark/static/images/organizations/together.png +0 -0
- helm/benchmark/static/images/organizations/tsinghua-keg.png +0 -0
- helm/benchmark/static/images/organizations/yandex.png +0 -0
- helm/benchmark/static/images/scenarios-by-metrics.png +0 -0
- helm/benchmark/static/images/taxonomy-scenarios.png +0 -0
- helm/benchmark/static/index.html +0 -68
- helm/benchmark/static/info-icon.png +0 -0
- helm/benchmark/static/json-urls.js +0 -69
- helm/benchmark/static/plot-captions.js +0 -27
- helm/benchmark/static/schema_image2structure.yaml +0 -304
- helm/benchmark/static/utils.js +0 -285
- helm/benchmark/static_build/assets/index-737eef9e.js +0 -10
- helm/benchmark/static_build/assets/index-878a1094.css +0 -1
- helm/benchmark/window_services/ai21_window_service.py +0 -247
- helm/benchmark/window_services/cohere_window_service.py +0 -101
- helm/benchmark/window_services/test_ai21_window_service.py +0 -163
- helm/benchmark/window_services/test_cohere_window_service.py +0 -75
- helm/benchmark/window_services/test_cohere_window_service_utils.py +0 -8328
- helm/benchmark/window_services/test_ice_window_service.py +0 -327
- helm/tokenizers/ice_tokenizer.py +0 -30
- helm/tokenizers/test_ice_tokenizer.py +0 -57
- {crfm_helm-0.5.1.dist-info → crfm_helm-0.5.3.dist-info}/LICENSE +0 -0
- {crfm_helm-0.5.1.dist-info → crfm_helm-0.5.3.dist-info}/entry_points.txt +0 -0
- {crfm_helm-0.5.1.dist-info → crfm_helm-0.5.3.dist-info}/top_level.txt +0 -0
- /helm/benchmark/annotation/{image2structure → image2struct}/__init__.py +0 -0
- /helm/benchmark/annotation/{image2structure → image2struct}/image_compiler_annotator.py +0 -0
- /helm/benchmark/scenarios/vision_language/{image2structure → image2struct}/__init__.py +0 -0
- /helm/benchmark/scenarios/vision_language/{image2structure → image2struct}/webpage/__init__.py +0 -0
- /helm/benchmark/scenarios/vision_language/{image2structure → image2struct}/webpage/jekyll_server.py +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from tempfile import TemporaryDirectory
|
|
3
|
+
|
|
4
|
+
from helm.benchmark.scenarios.financebench_scenario import FinanceBenchScenario
|
|
5
|
+
from helm.benchmark.scenarios.scenario import CORRECT_TAG, TEST_SPLIT, TRAIN_SPLIT
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@pytest.mark.scenarios
|
|
9
|
+
def test_air_2024_scenario_get_instances():
|
|
10
|
+
scenario = FinanceBenchScenario()
|
|
11
|
+
with TemporaryDirectory() as tmpdir:
|
|
12
|
+
instances = scenario.get_instances(tmpdir)
|
|
13
|
+
assert len(instances) == 150
|
|
14
|
+
assert len([instance for instance in instances if instance.split == TRAIN_SPLIT]) == 10
|
|
15
|
+
assert (
|
|
16
|
+
"Evidence: Table of Contents \n3M Company and Subsidiaries\nConsolidated Statement of Cash Flow s\n" # noqa: E501
|
|
17
|
+
in instances[0].input.text
|
|
18
|
+
)
|
|
19
|
+
assert (
|
|
20
|
+
"Question: What is the FY2018 capital expenditure amount (in USD millions) for 3M? Give a response to the question by relying on the details shown in the cash flow statement." # noqa: E501
|
|
21
|
+
in instances[0].input.text
|
|
22
|
+
)
|
|
23
|
+
assert len(instances[0].references) == 1
|
|
24
|
+
assert instances[0].references[0].output.text == "$1577.00"
|
|
25
|
+
assert instances[0].references[0].tags == [CORRECT_TAG]
|
|
26
|
+
assert instances[0].split == TEST_SPLIT
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from tempfile import TemporaryDirectory
|
|
3
|
+
|
|
4
|
+
from helm.benchmark.scenarios.gsm_scenario import GSM8KScenario
|
|
5
|
+
from helm.benchmark.scenarios.scenario import Input, Output, Reference
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@pytest.mark.scenarios
|
|
9
|
+
def test_gsm_scenario_get_instances():
|
|
10
|
+
math_scenario = GSM8KScenario()
|
|
11
|
+
with TemporaryDirectory() as tmpdir:
|
|
12
|
+
actual_instances = math_scenario.get_instances(tmpdir)
|
|
13
|
+
assert len(actual_instances) == 8792
|
|
14
|
+
assert actual_instances[0].input == Input(
|
|
15
|
+
text=(
|
|
16
|
+
"Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many"
|
|
17
|
+
" clips did Natalia sell altogether in April and May?"
|
|
18
|
+
)
|
|
19
|
+
)
|
|
20
|
+
assert actual_instances[0].references == [
|
|
21
|
+
Reference(
|
|
22
|
+
output=Output(
|
|
23
|
+
text=(
|
|
24
|
+
"Natalia sold 48/2 = <<48/2=24>>24 clips in May. Natalia sold 48+24 = <<48+24=72>>72 clips"
|
|
25
|
+
" altogether in April and May. The answer is 72."
|
|
26
|
+
)
|
|
27
|
+
),
|
|
28
|
+
tags=["correct"],
|
|
29
|
+
)
|
|
30
|
+
]
|
|
31
|
+
assert actual_instances[0].split == "train"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from tempfile import TemporaryDirectory
|
|
3
|
+
|
|
4
|
+
from helm.benchmark.scenarios.legalbench_scenario import LegalBenchScenario
|
|
5
|
+
from helm.benchmark.scenarios.scenario import CORRECT_TAG, Input, Output, Reference
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@pytest.mark.scenarios
|
|
9
|
+
def test_legalbench_scenario():
|
|
10
|
+
scenario = LegalBenchScenario(subset="abercrombie")
|
|
11
|
+
with TemporaryDirectory() as tmpdir:
|
|
12
|
+
instances = scenario.get_instances(tmpdir)
|
|
13
|
+
assert len(instances) == 100
|
|
14
|
+
assert instances[0].input == Input(text='Description: The mark "Ivory" for a product made of elephant tusks.')
|
|
15
|
+
assert instances[0].references == [
|
|
16
|
+
Reference(output=Output(text="generic"), tags=["correct"]),
|
|
17
|
+
]
|
|
18
|
+
assert instances[0].split == "train"
|
|
19
|
+
|
|
20
|
+
scenario = LegalBenchScenario(subset="proa")
|
|
21
|
+
with TemporaryDirectory() as tmpdir:
|
|
22
|
+
instances = scenario.get_instances(tmpdir)
|
|
23
|
+
assert len(instances) == 100
|
|
24
|
+
assert instances[0].input == Input(
|
|
25
|
+
text="Statute: Amendments to pleadings must be filed within 15 days of the filing of the initial pleading."
|
|
26
|
+
)
|
|
27
|
+
assert instances[0].references == [
|
|
28
|
+
Reference(output=Output(text="No"), tags=[CORRECT_TAG]),
|
|
29
|
+
]
|
|
30
|
+
assert instances[0].split == "train"
|
|
@@ -5,18 +5,12 @@ from helm.benchmark.scenarios.math_scenario import MATHScenario
|
|
|
5
5
|
from helm.benchmark.scenarios.scenario import Input, Output, Reference
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
@pytest.mark.skip(
|
|
10
|
-
reason="Incompatible with newer versions with diffusers>0.24.0. Fails with "
|
|
11
|
-
'"Loading a dataset cached in a LocalFileSystem is not supported"'
|
|
12
|
-
)
|
|
8
|
+
@pytest.mark.scenarios
|
|
13
9
|
def test_math_scenario_get_instances():
|
|
14
10
|
math_scenario = MATHScenario(subject="number_theory", level="1")
|
|
15
11
|
with TemporaryDirectory() as tmpdir:
|
|
16
12
|
actual_instances = math_scenario.get_instances(tmpdir)
|
|
17
13
|
assert len(actual_instances) == 77
|
|
18
14
|
assert actual_instances[0].input == Input(text="What is the remainder when (99)(101) is divided by 9?")
|
|
19
|
-
assert actual_instances[0].references == [
|
|
20
|
-
Reference(output=Output(text="0", multimedia_content=None), tags=["correct"])
|
|
21
|
-
]
|
|
15
|
+
assert actual_instances[0].references == [Reference(output=Output(text="0"), tags=["correct"])]
|
|
22
16
|
assert actual_instances[0].split == "train"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from tempfile import TemporaryDirectory
|
|
3
|
+
|
|
4
|
+
from helm.benchmark.scenarios.med_qa_scenario import MedQAScenario
|
|
5
|
+
from helm.benchmark.scenarios.scenario import CORRECT_TAG, Input, Output, Reference
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@pytest.mark.scenarios
|
|
9
|
+
def test_med_qa_scenario():
|
|
10
|
+
scenario = MedQAScenario()
|
|
11
|
+
with TemporaryDirectory() as tmpdir:
|
|
12
|
+
instances = scenario.get_instances(tmpdir)
|
|
13
|
+
assert len(instances) == 12723
|
|
14
|
+
assert instances[0].input == Input(
|
|
15
|
+
text=(
|
|
16
|
+
"A 23-year-old pregnant woman at 22 weeks gestation presents with burning upon urination. She states it"
|
|
17
|
+
" started 1 day ago and has been worsening despite drinking more water and taking cranberry extract. She"
|
|
18
|
+
" otherwise feels well and is followed by a doctor for her pregnancy. Her temperature is 97.7°F (36.5°C),"
|
|
19
|
+
" blood pressure is 122/77 mmHg, pulse is 80/min, respirations are 19/min, and oxygen saturation is 98% on"
|
|
20
|
+
" room air. Physical exam is notable for an absence of costovertebral angle tenderness and a gravid uterus."
|
|
21
|
+
" Which of the following is the best treatment for this patient?"
|
|
22
|
+
)
|
|
23
|
+
)
|
|
24
|
+
assert instances[0].references == [
|
|
25
|
+
Reference(output=Output(text="Ampicillin"), tags=[]),
|
|
26
|
+
Reference(output=Output(text="Ceftriaxone"), tags=[]),
|
|
27
|
+
Reference(output=Output(text="Doxycycline"), tags=[]),
|
|
28
|
+
Reference(output=Output(text="Nitrofurantoin"), tags=[CORRECT_TAG]),
|
|
29
|
+
]
|
|
30
|
+
assert instances[0].split == "train"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from tempfile import TemporaryDirectory
|
|
3
|
+
|
|
4
|
+
from helm.benchmark.scenarios.mmlu_scenario import MMLUScenario
|
|
5
|
+
from helm.benchmark.scenarios.scenario import CORRECT_TAG, Input, Output, Reference
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@pytest.mark.scenarios
|
|
9
|
+
def test_mmlu_scenario():
|
|
10
|
+
with TemporaryDirectory() as tmpdir:
|
|
11
|
+
scenario = MMLUScenario(subject="abstract_algebra")
|
|
12
|
+
instances = scenario.get_instances(tmpdir)
|
|
13
|
+
assert len(instances) == 116
|
|
14
|
+
assert instances[0].input == Input(text="Find all c in Z_3 such that Z_3[x]/(x^2 + c) is a field.")
|
|
15
|
+
assert instances[0].references == [
|
|
16
|
+
Reference(output=Output(text="0"), tags=[]),
|
|
17
|
+
Reference(output=Output(text="1"), tags=[CORRECT_TAG]),
|
|
18
|
+
Reference(output=Output(text="2"), tags=[]),
|
|
19
|
+
Reference(output=Output(text="3"), tags=[]),
|
|
20
|
+
]
|
|
21
|
+
assert instances[0].split == "train"
|
|
22
|
+
|
|
23
|
+
scenario = MMLUScenario(subject="anatomy")
|
|
24
|
+
instances = scenario.get_instances(tmpdir)
|
|
25
|
+
assert len(instances) == 154
|
|
26
|
+
assert instances[0].input == Input(text="What is the embryological origin of the hyoid bone?")
|
|
27
|
+
assert instances[0].references == [
|
|
28
|
+
Reference(output=Output(text="The first pharyngeal arch"), tags=[]),
|
|
29
|
+
Reference(output=Output(text="The first and second pharyngeal arches"), tags=[]),
|
|
30
|
+
Reference(output=Output(text="The second pharyngeal arch"), tags=[]),
|
|
31
|
+
Reference(output=Output(text="The second and third pharyngeal arches"), tags=[CORRECT_TAG]),
|
|
32
|
+
]
|
|
33
|
+
assert instances[0].split == "train"
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from tempfile import TemporaryDirectory
|
|
3
|
+
|
|
4
|
+
from helm.benchmark.scenarios.narrativeqa_scenario import NarrativeQAScenario
|
|
5
|
+
from helm.benchmark.scenarios.scenario import CORRECT_TAG, Output, Reference
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@pytest.mark.scenarios
|
|
9
|
+
def test_narrativeqa_scenario():
|
|
10
|
+
scenario = NarrativeQAScenario()
|
|
11
|
+
with TemporaryDirectory() as tmpdir:
|
|
12
|
+
instances = scenario.get_instances(tmpdir)
|
|
13
|
+
assert len(instances) == 1572
|
|
14
|
+
assert (
|
|
15
|
+
instances[0].input.text
|
|
16
|
+
== "At Madeline Hall, an old mansion-house near Southampton belonging to the wealthy de Versely family, lives"
|
|
17
|
+
" an elderly spinster Miss Delmar, the aunt of the earl de Versely and Captain Delmar. Miss Delmar invites"
|
|
18
|
+
" Arabella Mason, the daughter of a deceased, well-liked steward to stay with her as a lower-class guest in"
|
|
19
|
+
" the house. Captain Delmar is known to visit his aunt at Madeline Hall frequently, accompanied by his"
|
|
20
|
+
" valet Ben Keene, who is also a private marine. Captain Delmar eventually suggests that Ben should propose"
|
|
21
|
+
" to Arabella, and the two marry in secret, to the frustration of Miss Delmar and Arabella's mother. The"
|
|
22
|
+
" captain is able to smooth over the situation with his aunt, even after it is discovered that Arabella was"
|
|
23
|
+
" six months pregnant at the time of the marriage. She later gives birth to a boy, who takes the Captain's"
|
|
24
|
+
" Christian name and Ben's surname--the titular Percival Keene.\nThe family moves to Chatham, after Ben is"
|
|
25
|
+
" ordered back with his detachment. Arabella opens up a successful shop and circulating library below her"
|
|
26
|
+
" house, enlisting the help of her mother and sister, Amelia. Percival becomes well known in town from his"
|
|
27
|
+
" mischievous pranks on officers and other strangers, often encouraged by his aunt Amelia. However,"
|
|
28
|
+
" Percival's mother and grandmother are less fond of his disregard for manners, and insist on sending him"
|
|
29
|
+
" to school after an episode in which he bites his grandmother. Percival reports to the school house of Mr."
|
|
30
|
+
" O'Gallagher, a poor Irish scholar, who rules his class with a system of severe corporal punishment. Mr."
|
|
31
|
+
" O'Gallagher routinely bullies Percival by stealing his lunch, leading Percival to seek revenge by"
|
|
32
|
+
" poisoning his sandwiches with calomel. On Guy Fawkes Day the schoolteacher confiscates all the"
|
|
33
|
+
" schoolboys' fireworks, for which Percival retaliates by setting off the collected fireworks while the"
|
|
34
|
+
" teacher sits above them, leading to the total destruction of the schoolhouse and near death of the"
|
|
35
|
+
" schoolmaster.\nWhen Percival is a young teenager, Captain Delmar reappears and offers him a position"
|
|
36
|
+
" aboard his new navy ship, the H.M. Calliope. While preparing to enter service, Percival overhears gossip"
|
|
37
|
+
" of his illegitimate birth, introducing the idea that Captain Delmar may be his father. He confronts his"
|
|
38
|
+
" mother about his parentage, which she at first harshly denies but later tearfully explains the truth of"
|
|
39
|
+
" her affair. Early in his service in the navy, Percival is captured during a pirate raid along with"
|
|
40
|
+
" others. The pirate crew is entirely black, and the captain explains that they are primarily escaped"
|
|
41
|
+
" slaves from the Americas. Percival is taken in as a cabin boy, and later dyes his skin tan in the"
|
|
42
|
+
" appearance of a mulatto to please the captain who doesn't approve of white skin. The pirates often seek"
|
|
43
|
+
" to take over slave trading vessels, killing every white person on board. During the taking of one such"
|
|
44
|
+
" vessel, Percival is able is convince the captain to spare the lives of a wealthy Dutch merchant and his"
|
|
45
|
+
" young daughter, Minnie. Eventually the H.M. Calliope takes the pirate ship, and Percival--unrecognizable"
|
|
46
|
+
" with his dyed skin--is taken as a prisoner, later to convince his fellow shipman of his true"
|
|
47
|
+
" identity.\nAfter his reappearance aboard the ship, Percival gains esteem among the crew and is welcomed"
|
|
48
|
+
" back by the emotional Captain Delmar. His reputation continues to grow over the course of his service in"
|
|
49
|
+
" conflicts with Dutch and French vessels around the island of Curacao. He also stands in for an ill"
|
|
50
|
+
" Captain Delmar in a duel with a French officer, effectively saving the captain's life. At this point, the"
|
|
51
|
+
" captain receives news that his older brother has died, making him the new Lord de Versely, and before"
|
|
52
|
+
" returning to England he grants Perceval command of his own schooner. After another intense but successful"
|
|
53
|
+
" battle with a French war ship, Percival is promoted to captain. During his service in the Navy, Percival"
|
|
54
|
+
" still partakes in the merry pranks of his youth, and at one point teams up with a mulatto hotel owner in"
|
|
55
|
+
" Curaรงao to convince his fellow officers they've been poisoned. He also keeps correspondence with Minnie,"
|
|
56
|
+
" developing a romance with the beautiful heiress.\nNear the end of the story, Percival guides his crew"
|
|
57
|
+
" through a terrible storm in which many of the crew are killed and the ship is heavily damaged. After"
|
|
58
|
+
" being saved by another English vessel, he receives a letter informing him of Lord de Versely's sudden"
|
|
59
|
+
" death from heart complications and learns that he has been left all of his personal property. Percival is"
|
|
60
|
+
" still disappointed that he can not take his father's name. He later journey's with his friend Bob Cross"
|
|
61
|
+
" to Hamburg to reunite with Minnie, but is captured by French troops on the road and sentenced to"
|
|
62
|
+
" execution for spying. During a skirmish between the French and the Cossacks, Percival and Cross are able"
|
|
63
|
+
" to escape and continue on the road. At the end of the novel, Percival proposes to Minnie, and stands to"
|
|
64
|
+
" inherit a great fortune through her father. He also receives a letter from the de Versely attorney"
|
|
65
|
+
" letting him know he has been granted the arms and name of Delmar.\nQuestion: Who did Percival reunited"
|
|
66
|
+
" with?"
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
assert instances[0].references == [
|
|
70
|
+
Reference(output=Output(text="Minnie"), tags=[CORRECT_TAG]),
|
|
71
|
+
Reference(output=Output(text="minnie"), tags=[CORRECT_TAG]),
|
|
72
|
+
]
|
|
73
|
+
assert instances[0].split == "train"
|
|
@@ -86,9 +86,9 @@ class ThaiExamScenario(Scenario):
|
|
|
86
86
|
super().__init__()
|
|
87
87
|
self.exam = exam
|
|
88
88
|
|
|
89
|
-
def download_thai_exam(self, path: str):
|
|
89
|
+
def download_thai_exam(self, path: str, revision: str):
|
|
90
90
|
ensure_file_downloaded(
|
|
91
|
-
"https://
|
|
91
|
+
f"https://huggingface.co/datasets/scb10x/thai_exam/resolve/{revision}/thai_exam.tar.gz",
|
|
92
92
|
target_path=path,
|
|
93
93
|
unpack=True,
|
|
94
94
|
)
|
|
@@ -118,8 +118,8 @@ class ThaiExamScenario(Scenario):
|
|
|
118
118
|
|
|
119
119
|
def get_instances(self, output_path) -> List[Instance]:
|
|
120
120
|
data_path: str = os.path.join(output_path, "data")
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
# ThaiExam (v1.0) revision = d78aef04ea3cc5095545e6951cb39e17c64e26a1
|
|
122
|
+
self.download_thai_exam(data_path, revision="d78aef04ea3cc5095545e6951cb39e17c64e26a1")
|
|
123
123
|
instances: List[Instance] = []
|
|
124
124
|
splits: Dict[str, str] = {
|
|
125
125
|
"train": TRAIN_SPLIT,
|
|
@@ -42,7 +42,7 @@ class AOKVQAScenario(Scenario):
|
|
|
42
42
|
name = "a_okvqa"
|
|
43
43
|
description = (
|
|
44
44
|
"A crowdsourced dataset composed of a diverse set of about 25K questions requiring a broad base of "
|
|
45
|
-
"commonsense and world knowledge to answer ([
|
|
45
|
+
"commonsense and world knowledge to answer ([Schwenk et al., 2022](https://arxiv.org/abs/2206.01718))."
|
|
46
46
|
)
|
|
47
47
|
tags = ["vision-language", "knowledge", "reasoning"]
|
|
48
48
|
|
|
@@ -43,7 +43,7 @@ class BingoScenario(Scenario):
|
|
|
43
43
|
Paper: https://arxiv.org/abs/2311.03287
|
|
44
44
|
"""
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
BINGO_HUGGINGFACE_DATASET_URL: str = "https://huggingface.co/datasets/PahaII/Bingo/resolve/main"
|
|
47
47
|
|
|
48
48
|
IMAGE_URL: str = "https://huggingface.co/datasets/PahaII/Bingo/resolve/main/images/{image_path}?download=true"
|
|
49
49
|
|
|
@@ -51,8 +51,8 @@ class BingoScenario(Scenario):
|
|
|
51
51
|
|
|
52
52
|
name = "bingo"
|
|
53
53
|
description = (
|
|
54
|
-
"Evaluate multimodal models on biased and inference-challenging scenarios with five subjects"
|
|
55
|
-
"
|
|
54
|
+
"Evaluate multimodal models on biased and inference-challenging scenarios with five subjects "
|
|
55
|
+
"([Cui et al., 2023](https://arxiv.org/abs/2311.03287))."
|
|
56
56
|
)
|
|
57
57
|
tags = ["vision-language"]
|
|
58
58
|
|
|
@@ -67,12 +67,12 @@ class BingoScenario(Scenario):
|
|
|
67
67
|
|
|
68
68
|
# There is only the test split in Unicorn benchmark
|
|
69
69
|
instances: List[Instance] = []
|
|
70
|
-
question_data_files = {TEST_SPLIT: f"{self._subject}.json"}
|
|
70
|
+
question_data_files = {TEST_SPLIT: f"{self.BINGO_HUGGINGFACE_DATASET_URL}/{self._subject}.json"}
|
|
71
71
|
|
|
72
72
|
# Process the test set
|
|
73
73
|
for row in tqdm(
|
|
74
74
|
load_dataset(
|
|
75
|
-
|
|
75
|
+
"json",
|
|
76
76
|
data_files=question_data_files,
|
|
77
77
|
split=TEST_SPLIT,
|
|
78
78
|
cache_dir=output_path,
|
|
@@ -75,7 +75,8 @@ class Crossmodal3600Scenario(Scenario):
|
|
|
75
75
|
name = "crossmodal_3600"
|
|
76
76
|
description = (
|
|
77
77
|
"Crossmodal-3600 dataset (XM3600 in short), a geographically-diverse set of 3600 images annotated "
|
|
78
|
-
"with human-generated reference captions in 36 languages.
|
|
78
|
+
"with human-generated reference captions in 36 languages. "
|
|
79
|
+
"([Thapliyal et al., 2022)](https://arxiv.org/abs/2205.12522))."
|
|
79
80
|
)
|
|
80
81
|
tags = ["vision-language", "multilinguality"]
|
|
81
82
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
from typing import List, Set
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from datasets import load_dataset
|
|
5
|
+
from tqdm import tqdm
|
|
6
|
+
|
|
7
|
+
from helm.benchmark.scenarios.scenario import (
|
|
8
|
+
CORRECT_TAG,
|
|
9
|
+
TEST_SPLIT,
|
|
10
|
+
TRAIN_SPLIT,
|
|
11
|
+
Instance,
|
|
12
|
+
Input,
|
|
13
|
+
Output,
|
|
14
|
+
Reference,
|
|
15
|
+
Scenario,
|
|
16
|
+
)
|
|
17
|
+
from helm.common.media_object import MediaObject, MultimediaObject
|
|
18
|
+
from helm.common.images_utils import generate_hash
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ExamsVScenario(Scenario):
|
|
22
|
+
"""
|
|
23
|
+
EXAMS-V: A Multi-Discipline Multilingual Multimodal Exam Benchmark for Evaluating Vision Language Models
|
|
24
|
+
|
|
25
|
+
A challenging multi-discipline multimodal multilingual exam benchmark for evaluating vision language models.
|
|
26
|
+
It consists of 20,932 multiple-choice questions across 20 school disciplines covering natural science,
|
|
27
|
+
social science, and other miscellaneous studies, e.g.,religion, fine arts, business, etc.
|
|
28
|
+
|
|
29
|
+
Paper: https://arxiv.org/abs/2403.10378
|
|
30
|
+
Website: https://huggingface.co/datasets/Rocktim/EXAMS-V
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
HUGGINGFACE_DATASET_NAME: str = "Rocktim/EXAMS-V"
|
|
34
|
+
|
|
35
|
+
VALID_LANGUAGES: Set[str] = {
|
|
36
|
+
"Chinese",
|
|
37
|
+
"Croation",
|
|
38
|
+
"Italian",
|
|
39
|
+
"Hungarian",
|
|
40
|
+
"Arabic",
|
|
41
|
+
"Serbian",
|
|
42
|
+
"Bulgarian",
|
|
43
|
+
"English",
|
|
44
|
+
"German",
|
|
45
|
+
"French",
|
|
46
|
+
"Spanish",
|
|
47
|
+
"Polish",
|
|
48
|
+
}
|
|
49
|
+
VALID_SUBJECT_GROUP: Set[str] = {
|
|
50
|
+
"Natural Science",
|
|
51
|
+
"Social Sciences",
|
|
52
|
+
"Other",
|
|
53
|
+
}
|
|
54
|
+
VALID_TYPES: Set[str] = {"text", "image_text"}
|
|
55
|
+
|
|
56
|
+
name = "exams_v"
|
|
57
|
+
description = (
|
|
58
|
+
"Multimodal and Multilingual benchmark to evaluate vision-language models across 20 school disciplines "
|
|
59
|
+
"covering natural science, social science, and other miscellaneous studies "
|
|
60
|
+
"([Das et al., 2024]( https://arxiv.org/abs/2403.10378))."
|
|
61
|
+
)
|
|
62
|
+
tags = ["vision-language", "knowledge", "reasoning", "multilingual"]
|
|
63
|
+
|
|
64
|
+
def __init__(self, language: str, subject_grouped: str, type: str) -> None:
|
|
65
|
+
super().__init__()
|
|
66
|
+
|
|
67
|
+
subject_grouped = subject_grouped.replace("_", " ")
|
|
68
|
+
assert subject_grouped in self.VALID_SUBJECT_GROUP, f"Invalid subject_grouped: {subject_grouped}"
|
|
69
|
+
assert type in self.VALID_TYPES, f"Invalid type: {type}"
|
|
70
|
+
assert language in self.VALID_LANGUAGES, f"Invalid language: {language}"
|
|
71
|
+
|
|
72
|
+
self._language: str = language
|
|
73
|
+
self._subject_grouped: str = subject_grouped
|
|
74
|
+
self._type: str = type
|
|
75
|
+
|
|
76
|
+
def get_instances(self, output_path: str) -> List[Instance]:
|
|
77
|
+
instances: List[Instance] = []
|
|
78
|
+
|
|
79
|
+
for split in [TRAIN_SPLIT, TEST_SPLIT]:
|
|
80
|
+
for row in tqdm(load_dataset(self.HUGGINGFACE_DATASET_NAME, split=split, cache_dir=output_path)):
|
|
81
|
+
language: str = row["language"]
|
|
82
|
+
subject_grouped: str = row["subject_grouped"]
|
|
83
|
+
type: str = row["type"]
|
|
84
|
+
|
|
85
|
+
# Exclude examples that do not match the specified language, subject, and type
|
|
86
|
+
if language != self._language or subject_grouped != self._subject_grouped or type != self._type:
|
|
87
|
+
continue
|
|
88
|
+
|
|
89
|
+
# Save the image to disk
|
|
90
|
+
image = row["image"]
|
|
91
|
+
image_file_name: str = generate_hash(image) + ".jpg"
|
|
92
|
+
local_image_path: str = os.path.join(output_path, image_file_name)
|
|
93
|
+
if not os.path.exists(local_image_path):
|
|
94
|
+
image.convert("RGB").save(local_image_path)
|
|
95
|
+
|
|
96
|
+
content: List[MediaObject] = [
|
|
97
|
+
MediaObject(location=local_image_path, content_type="image/jpeg"),
|
|
98
|
+
]
|
|
99
|
+
references: List[Reference] = [Reference(output=Output(text=row["answer_key"]), tags=[CORRECT_TAG])]
|
|
100
|
+
instances.append(
|
|
101
|
+
Instance(Input(multimedia_content=MultimediaObject(content)), references=references, split=split)
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
return instances
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from datasets import load_dataset
|
|
5
|
+
from tqdm import tqdm
|
|
6
|
+
|
|
7
|
+
from helm.benchmark.scenarios.scenario import (
|
|
8
|
+
CORRECT_TAG,
|
|
9
|
+
VALID_SPLIT,
|
|
10
|
+
TRAIN_SPLIT,
|
|
11
|
+
Instance,
|
|
12
|
+
Input,
|
|
13
|
+
Output,
|
|
14
|
+
Reference,
|
|
15
|
+
Scenario,
|
|
16
|
+
)
|
|
17
|
+
from helm.common.media_object import MediaObject, MultimediaObject
|
|
18
|
+
from helm.common.images_utils import generate_hash
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class FairFaceScenario(Scenario):
|
|
22
|
+
"""
|
|
23
|
+
Identify the race, gender or age of a photo of a person.
|
|
24
|
+
|
|
25
|
+
@misc{kärkkäinen2019fairfacefaceattributedataset,
|
|
26
|
+
title={FairFace: Face Attribute Dataset for Balanced Race, Gender, and Age},
|
|
27
|
+
author={Kimmo Kärkkäinen and Jungseock Joo},
|
|
28
|
+
year={2019},
|
|
29
|
+
eprint={1908.04913},
|
|
30
|
+
archivePrefix={arXiv},
|
|
31
|
+
primaryClass={cs.CV},
|
|
32
|
+
url={https://arxiv.org/abs/1908.04913},
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
Paper: https://arxiv.org/abs/1908.04913
|
|
36
|
+
Website: https://huggingface.co/datasets/HuggingFaceM4/FairFace
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
HUGGINGFACE_DATASET_NAME: str = "HuggingFaceM4/FairFace"
|
|
40
|
+
|
|
41
|
+
RACE_ATTRIBUTE: str = "race"
|
|
42
|
+
GENDER_ATTRIBUTE: str = "gender"
|
|
43
|
+
AGE_ATTRIBUTE: str = "age"
|
|
44
|
+
|
|
45
|
+
QUESTION_TEMPLATE: str = "Identify the {attribute} of the person in the image."
|
|
46
|
+
|
|
47
|
+
RACE_SUBGROUPS: List[str] = [
|
|
48
|
+
"East Asian",
|
|
49
|
+
"Indian",
|
|
50
|
+
"Black",
|
|
51
|
+
"White",
|
|
52
|
+
"Middle Eastern",
|
|
53
|
+
"Latino Hispanic",
|
|
54
|
+
"Southeast Asian",
|
|
55
|
+
]
|
|
56
|
+
GENDER_SUBGROUPS: List[str] = ["Male", "Female"]
|
|
57
|
+
AGE_SUBGROUPS: List[str] = [
|
|
58
|
+
"0-2 years",
|
|
59
|
+
"3-9 years",
|
|
60
|
+
"10-19 years",
|
|
61
|
+
"20-29 years",
|
|
62
|
+
"30-39 years",
|
|
63
|
+
"40-49 years",
|
|
64
|
+
"50-59 years",
|
|
65
|
+
"60-69 years",
|
|
66
|
+
"Over 70 years",
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
name = "fair_face"
|
|
70
|
+
description = (
|
|
71
|
+
"Identify the race, gender or age of a photo of a person "
|
|
72
|
+
"([Karkkainen et al., 2019](https://arxiv.org/abs/1908.04913))."
|
|
73
|
+
)
|
|
74
|
+
tags = ["vision-language", "fairness"]
|
|
75
|
+
|
|
76
|
+
def __init__(self, attribute: str, subgroup: str) -> None:
|
|
77
|
+
super().__init__()
|
|
78
|
+
|
|
79
|
+
subgroups: List[str]
|
|
80
|
+
if attribute == self.RACE_ATTRIBUTE:
|
|
81
|
+
subgroups = self.RACE_SUBGROUPS
|
|
82
|
+
elif attribute == self.GENDER_ATTRIBUTE:
|
|
83
|
+
subgroups = self.GENDER_SUBGROUPS
|
|
84
|
+
elif attribute == self.AGE_ATTRIBUTE:
|
|
85
|
+
subgroups = self.AGE_SUBGROUPS
|
|
86
|
+
else:
|
|
87
|
+
raise ValueError(f"Invalid attribute: {attribute}")
|
|
88
|
+
|
|
89
|
+
# Validate the value passed in for the subgroup argument and set possible subgroup choices.
|
|
90
|
+
# The subgroup passed in has a _ for spaces in the string.
|
|
91
|
+
subgroup = subgroup.replace("_", " ")
|
|
92
|
+
assert subgroup in subgroups, f"Invalid subgroup for {attribute} attribute: {subgroup}"
|
|
93
|
+
self._subgroup_choices: List[str] = subgroups
|
|
94
|
+
self._correct_subgroup_index: int = subgroups.index(subgroup)
|
|
95
|
+
|
|
96
|
+
self._attribute: str = attribute # For answer column
|
|
97
|
+
self._question: str = self.QUESTION_TEMPLATE.format(attribute=attribute) # What text to prompt the model?
|
|
98
|
+
|
|
99
|
+
def get_instances(self, output_path: str) -> List[Instance]:
|
|
100
|
+
instances: List[Instance] = []
|
|
101
|
+
for split in [TRAIN_SPLIT, VALID_SPLIT]:
|
|
102
|
+
for row in tqdm(
|
|
103
|
+
load_dataset(
|
|
104
|
+
self.HUGGINGFACE_DATASET_NAME,
|
|
105
|
+
"1.25",
|
|
106
|
+
split="validation" if split == VALID_SPLIT else split,
|
|
107
|
+
cache_dir=output_path,
|
|
108
|
+
)
|
|
109
|
+
):
|
|
110
|
+
# Filter out rows that do not match the subgroup
|
|
111
|
+
if row[self._attribute] != self._correct_subgroup_index:
|
|
112
|
+
continue
|
|
113
|
+
|
|
114
|
+
# Save the image to disk
|
|
115
|
+
image = row["image"]
|
|
116
|
+
image_file_name: str = generate_hash(image) + ".jpg"
|
|
117
|
+
local_image_path: str = os.path.join(output_path, image_file_name)
|
|
118
|
+
if not os.path.exists(local_image_path):
|
|
119
|
+
image.save(local_image_path)
|
|
120
|
+
|
|
121
|
+
content: List[MediaObject] = [
|
|
122
|
+
MediaObject(location=local_image_path, content_type="image/jpeg"),
|
|
123
|
+
MediaObject(text=self._question, content_type="text/plain"),
|
|
124
|
+
]
|
|
125
|
+
references: List[Reference] = [
|
|
126
|
+
Reference(
|
|
127
|
+
output=Output(text=subgroup),
|
|
128
|
+
tags=[CORRECT_TAG] if i == self._correct_subgroup_index else [],
|
|
129
|
+
)
|
|
130
|
+
for i, subgroup in enumerate(self._subgroup_choices)
|
|
131
|
+
]
|
|
132
|
+
instances.append(
|
|
133
|
+
Instance(Input(multimedia_content=MultimediaObject(content)), references=references, split=split)
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
return instances
|
|
@@ -41,7 +41,7 @@ class Flickr30KScenario(Scenario):
|
|
|
41
41
|
name = "flickr30k"
|
|
42
42
|
description = (
|
|
43
43
|
"An image caption corpus consisting of 158,915 crowd-sourced captions describing 31,783 Flickr "
|
|
44
|
-
"images ([
|
|
44
|
+
"images ([Young et al., 2014](https://shannon.cs.illinois.edu/DenotationGraph/TACLDenotationGraph.pdf))."
|
|
45
45
|
)
|
|
46
46
|
tags = ["vision-language"]
|
|
47
47
|
|
|
@@ -31,7 +31,7 @@ class GQAScenario(Scenario):
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
Paper: https://arxiv.org/abs/1902.09506
|
|
34
|
-
Website: https://
|
|
34
|
+
Website: https://cs.stanford.edu/people/dorarad/gqa/about.html
|
|
35
35
|
"""
|
|
36
36
|
|
|
37
37
|
QUESTIONS_URL: str = "https://downloads.cs.stanford.edu/nlp/data/gqa/questions1.2.zip"
|
|
@@ -40,7 +40,7 @@ class GQAScenario(Scenario):
|
|
|
40
40
|
name = "gqa"
|
|
41
41
|
description = (
|
|
42
42
|
"Questions about real-world visual reasoning and compositional QA "
|
|
43
|
-
"([
|
|
43
|
+
"([Hudson and Manning, 2019](https://arxiv.org/abs/1902.09506))."
|
|
44
44
|
)
|
|
45
45
|
tags = ["vision-language", "reasoning"]
|
|
46
46
|
|
|
@@ -49,7 +49,7 @@ class HatefulMemesScenario(Scenario):
|
|
|
49
49
|
QUESTION: str = "Is this meme mean?"
|
|
50
50
|
|
|
51
51
|
name = "hateful_memes"
|
|
52
|
-
description = "Identify if a meme is hateful or not ([
|
|
52
|
+
description = "Identify if a meme is hateful or not ([Kiela et al., 2020](https://arxiv.org/abs/2005.04790))."
|
|
53
53
|
tags = ["vision-language"]
|
|
54
54
|
|
|
55
55
|
def get_instances(self, output_path: str) -> List[Instance]:
|
helm/benchmark/scenarios/vision_language/{image2structure → image2struct}/chart2csv_scenario.py
RENAMED
|
@@ -20,7 +20,7 @@ class Chart2CSVScenario(Scenario):
|
|
|
20
20
|
|
|
21
21
|
name = "chart2csv"
|
|
22
22
|
description = "Convert a chart to CSV."
|
|
23
|
-
tags = ["vision-language", "
|
|
23
|
+
tags = ["vision-language", "image2struct"]
|
|
24
24
|
|
|
25
25
|
def get_instances(self, output_path: str) -> List[Instance]:
|
|
26
26
|
assert os.path.exists(output_path), f"Dataset does not exist at {output_path}"
|