id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
16,197
import random from dataclasses import dataclass, field from functools import partial from pathlib import Path import numpy as np from datasets import Dataset, load_dataset from .model.text import TextNormalizer from helm.common.optional_dependencies import handle_module_not_found_error def shift_tokens_right(input_ids:...
null
16,198
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error person_token = [("a person", 282265), ("someone", 121194), ("somebody", 12219)] The provided code snippet include...
Used for CC12M
16,199
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error def fix_html(t): # from OpenAI CLIP return html.unescape(html.unescape(t))
null
16,200
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error def replace_punctuation_with_commas(t): return re.sub("[()[\].,|:;?!=+~\-\/{}]", ",", t)
null
16,201
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error def simplify_quotes(t): return re.sub("""['"`]""", ' " ', t)
null
16,202
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error def merge_quotes(t): return re.sub('(\s*"+\s*)+', ' " ', t)
null
16,203
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error def remove_comma_numbers(t): def _f(t): return re.sub("(\d),(\d{3})", r"\1\2", t) return _f(_f(t...
null
16,204
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error temp_token = "xtokx" def pre_process_dot_numbers(t): return re.sub("(\w)\.(\w)", rf"\1{temp_token}dot{temp_to...
null
16,205
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error temp_token = "xtokx" def post_process_dot_numbers(t): return re.sub(f"{temp_token}dot{temp_token}", ".", t)
null
16,206
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error temp_token = "xtokx" def pre_process_quotes(t): # allows quotes only for 's, 't, 'd, 'm, 'll, 're, 've re...
null
16,207
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error temp_token = "xtokx" def post_process_quotes(t): return re.sub(f"{temp_token}quote{temp_token}", "'", t)
null
16,208
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error temp_token = "xtokx" def pre_process_dates(t): return re.sub("(\d)/(\d)", rf"\1{temp_token}slash{temp_token}\...
null
16,209
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error temp_token = "xtokx" def post_process_dates(t): return re.sub(f"{temp_token}slash{temp_token}", "/", t)
null
16,210
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error def merge_commas(t): return re.sub("(\s*,+\s*)+", ", ", t)
null
16,211
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error def add_space_after_commas(t): return re.sub(",", ", ", t)
null
16,212
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error The provided code snippet includes necessary dependencies for implementing the `handle_special_chars` function. W...
Handle special characters
16,213
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error The provided code snippet includes necessary dependencies for implementing the `expand_hashtags` function. Write ...
Remove # and try to split words
16,214
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error _re_ignore_chars = r"[_#\\]" The provided code snippet includes necessary dependencies for implementing the `igno...
Ignore useless characters
16,215
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error The provided code snippet includes necessary dependencies for implementing the `remove_extra_spaces` function. Wr...
Remove extra spaces (including \t and \n)
16,216
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error The provided code snippet includes necessary dependencies for implementing the `remove_repeating_chars` function....
If the same character is present 4+ times (not 3 because of roman 'VIII'), replace with single instance
16,217
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error def remove_urls(t): return re.sub(r"http\S+", "", t)
null
16,218
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error def remove_html_tags(t): return re.sub("<[^<]+?>", " ", t)
null
16,219
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error def remove_first_last_commas(t): t = t.strip() t = t[:-1] if t and t[-1] == "," else t t = t[1:] if t...
null
16,220
import html import math import random import re from pathlib import Path import emoji from huggingface_hub import hf_hub_download from helm.common.optional_dependencies import handle_module_not_found_error def remove_wiki_ref(t): t = re.sub(r"\A\s*\[\d+\]", "", t) return re.sub(r"\[\d+\]\s*\Z", "", t)
null
16,221
import math from functools import partial from typing import Any, Dict, Optional, Tuple from transformers.modeling_flax_outputs import ( FlaxBaseModelOutput, FlaxBaseModelOutputWithPastAndCrossAttentions, FlaxCausalLMOutputWithCrossAttentions, FlaxSeq2SeqLMOutput, ) from transformers.modeling_flax_utils...
Implementation of "Real World Large Scale Recommendation Systems Reproducibility and Smooth Activations" https://arxiv.org/abs/2202.06499
16,222
import math from functools import partial from typing import Any, Dict, Optional, Tuple from transformers.modeling_flax_outputs import ( FlaxBaseModelOutput, FlaxBaseModelOutputWithPastAndCrossAttentions, FlaxCausalLMOutputWithCrossAttentions, FlaxSeq2SeqLMOutput, ) from transformers.modeling_flax_utils...
null
16,223
import math from functools import partial from typing import Any, Dict, Optional, Tuple from transformers.modeling_flax_outputs import ( FlaxBaseModelOutput, FlaxBaseModelOutputWithPastAndCrossAttentions, FlaxCausalLMOutputWithCrossAttentions, FlaxSeq2SeqLMOutput, ) from transformers.modeling_flax_utils...
null
16,224
import math from functools import partial from typing import Any, Dict, Optional, Tuple from transformers.modeling_flax_outputs import ( FlaxBaseModelOutput, FlaxBaseModelOutputWithPastAndCrossAttentions, FlaxCausalLMOutputWithCrossAttentions, FlaxSeq2SeqLMOutput, ) from transformers.modeling_flax_utils...
Computes dot-product attention weights given query and key. mask is included into the bias. Adapted from flax.linen.attention.dot_product_attention_weights"
16,225
import re from helm.common.optional_dependencies import handle_module_not_found_error _unmatched = object() def _replacement_rules(rules): def replace(key, val): for rule, replacement in rules: if _match(rule, key): return replacement return val return replace def _ge...
null
16,226
from helm.common.media_object import MediaObject, MultimediaObject class MediaObject: """A media object e.g., image, video, audio, etc.""" content_type: str """A valid Multipurpose Internet Mail Extensions (MIME) type for this media object in the format `<type>/<subtype>`. IANA is the official registr...
Returns a `MultimediaObject` containing a single image file used for text-to-image generation clients.
16,227
from typing import Dict class AI21RequestError(Exception): pass def handle_failed_request(api_type: str, response: Dict): error_message: str = f"AI21 {api_type} API error -" # Error messages are returned via 'detail' or 'Error' in response if "detail" in response: error_message += f" Detail: {...
null
16,228
import re import subprocess from typing import Mapping, Set, Union from retrying import retry from helm.common.optional_dependencies import handle_module_not_found_error The provided code snippet includes necessary dependencies for implementing the `submit_slurm_job` function. Write a Python function `def submit_slurm...
Submit a Slurm job.
16,229
import re import subprocess from typing import Mapping, Set, Union from retrying import retry from helm.common.optional_dependencies import handle_module_not_found_error The provided code snippet includes necessary dependencies for implementing the `get_slurm_job_state` function. Write a Python function `def get_slurm...
Get the state of a Slurm job.
16,230
import re import subprocess from typing import Mapping, Set, Union from retrying import retry from helm.common.optional_dependencies import handle_module_not_found_error The provided code snippet includes necessary dependencies for implementing the `cancel_slurm_job` function. Write a Python function `def cancel_slurm...
Cancel a Slurm job.
16,231
from abc import ABC, abstractmethod from dataclasses import replace from random import Random from typing import List, Optional from .perturbation_description import PerturbationDescription from helm.benchmark.scenarios.scenario import Input, Instance, Reference, Output from helm.common.object_spec import ObjectSpec, c...
Creates Perturbation from PerturbationSpec.
16,232
import os import re from collections import defaultdict from dataclasses import dataclass, replace from functools import reduce from pathlib import Path from random import Random from typing import Dict, List, Optional, Set from helm.benchmark.scenarios.scenario import Input, Instance, Reference, Output from helm.commo...
null
16,233
from dataclasses import dataclass, field from typing import List from helm.common.hierarchical_logger import htrack, hlog from helm.common.general import parallel_map from helm.benchmark.augmentations.perturbation import ( Perturbation, PerturbationSpec, create_perturbation, ) from helm.benchmark.scenarios....
Creates a DataAugmenter from a DataAugmenterSpec.
16,234
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,235
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,236
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,237
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,238
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,239
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,240
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,241
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,242
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,243
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,244
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,245
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,246
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,247
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,248
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,249
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,250
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,251
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,252
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,253
from abc import ABC, abstractmethod from dataclasses import replace from typing import Any, List, Dict, Optional, Tuple, Type from helm.benchmark.model_metadata_registry import ( get_all_instruction_following_models, get_all_code_models, get_all_models, get_all_text_models, get_model_names_with_tag,...
null
16,254
import argparse from collections import defaultdict from dataclasses import dataclass from datetime import date import json import os from typing import List, Dict, Optional, Any, Callable, Union, Mapping, Tuple, Set import numpy as np from scipy.stats import pearsonr from helm.benchmark.config_registry import register...
Convert raw table dict to a Table. Ignores strongly contaminated table entries.
16,255
import argparse from collections import defaultdict from dataclasses import dataclass from datetime import date import json import os from typing import List, Dict, Optional, Any, Callable, Union, Mapping, Tuple, Set import numpy as np from scipy.stats import pearsonr from helm.benchmark.config_registry import register...
null
16,256
import argparse from collections import defaultdict from dataclasses import dataclass from datetime import date import json import os from typing import List, Dict, Optional, Any, Callable, Union, Mapping, Tuple, Set import numpy as np from scipy.stats import pearsonr from helm.benchmark.config_registry import register...
Given a mapping from string to floats, draw a box plot on the given axis ax. For instance, this might be a mapping from scenario_name to a list of model accuracies in which case the box plot captures aggregate model performance and highlights outliers.
16,257
from dataclasses import dataclass from typing import List, Optional import dacite import importlib_resources as resources import yaml from helm.common.hierarchical_logger import htrack, hlog from helm.benchmark.model_metadata_registry import MODEL_NAME_TO_MODEL_METADATA from helm.benchmark.presentation.schema import Sc...
Make sure models and groups in contamination are defined according to `schema`.
16,258
from dataclasses import dataclass from typing import List, Optional import dacite import importlib_resources as resources import yaml from helm.common.hierarchical_logger import htrack, hlog from helm.benchmark.model_metadata_registry import MODEL_NAME_TO_MODEL_METADATA from helm.benchmark.presentation.schema import Sc...
null
16,259
from dataclasses import dataclass, field from typing import Any, Optional, List, Dict class Table: title: str header: List[HeaderCell] rows: List[List[Cell]] # Extra information to show at the bottom links: List[Hyperlink] = field(default_factory=list) # Optional name name: Optional[str] = N...
Return a string representing the latex version of the table.
16,260
import argparse import cattrs import os import datetime import urllib.parse import json import yaml from collections import defaultdict from dataclasses import dataclass, replace from statistics import mean, median from typing import List, Optional, Dict, Any, Tuple, Set from tqdm import tqdm from helm.benchmark.model_...
Return the single stat that matches.
16,261
import argparse import cattrs import os import datetime import urllib.parse import json import yaml from collections import defaultdict from dataclasses import dataclass, replace from statistics import mean, median from typing import List, Optional, Dict, Any, Tuple, Set from tqdm import tqdm from helm.benchmark.model_...
null
16,262
import argparse import cattrs import os import datetime import urllib.parse import json import yaml from collections import defaultdict from dataclasses import dataclass, replace from statistics import mean, median from typing import List, Optional, Dict, Any, Tuple, Set from tqdm import tqdm from helm.benchmark.model_...
null
16,263
import argparse import cattrs import os import datetime import urllib.parse import json import yaml from collections import defaultdict from dataclasses import dataclass, replace from statistics import mean, median from typing import List, Optional, Dict, Any, Tuple, Set from tqdm import tqdm from helm.benchmark.model_...
Return the ModelMetadata for the model in the given AdapterSpec.
16,264
import argparse import cattrs import os import datetime import urllib.parse import json import yaml from collections import defaultdict from dataclasses import dataclass, replace from statistics import mean, median from typing import List, Optional, Dict, Any, Tuple, Set from tqdm import tqdm from helm.benchmark.model_...
Return an abstraction of an AdapterSpec that corresponds to the method (e.g., model, decoding parameters), and not the part that contains scenario-specific things like instructions. This is not an easy thing to disentangle, so just try our best in a necessarily scenario-specific way.
16,265
import argparse import cattrs import os import datetime import urllib.parse import json import yaml from collections import defaultdict from dataclasses import dataclass, replace from statistics import mean, median from typing import List, Optional, Dict, Any, Tuple, Set from tqdm import tqdm from helm.benchmark.model_...
Return a nice name to display for `adapter_spec` which denotes a method. `info` contains the decoding parameters. Format: Model (info...)
16,266
import argparse import cattrs import os import datetime import urllib.parse import json import yaml from collections import defaultdict from dataclasses import dataclass, replace from statistics import mean, median from typing import List, Optional, Dict, Any, Tuple, Set from tqdm import tqdm from helm.benchmark.model_...
Computes the aggregate win rate of each row across columns. For a given row r1 and column c1, the win rate of r1 wrt to c1 corresponds to: if we pick another row r2 uniformly at random, what is the probability that r1c1 is better that r2c1? `aggregation` determines how we aggregate win rates across columns, currently c...
16,267
from dataclasses import dataclass, field from typing import List, Optional, Dict import dacite import mako.template import yaml import importlib_resources as resources from helm.common.general import hlog from helm.benchmark.metrics.metric_name import MetricName from helm.benchmark.augmentations.perturbation_descriptio...
null
16,268
from collections import OrderedDict, defaultdict from dataclasses import dataclass, replace import os from typing import Dict, Iterable, List, Optional, Set, Tuple from helm.benchmark.adaptation.adapter_spec import ( ADAPT_MULTIPLE_CHOICE_SEPARATE_METHODS, ADAPT_MULTIPLE_CHOICE_SEPARATE_CALIBRATED, ) from helm....
Write run JSON files that are used by the web frontend. The derived JSON files that are used by the web frontend are much more compact than the source JSON files. This speeds up web frontend loading significantly. Reads: - ScenarioState from `scenario_state.json` - List[PerInstanceStats] from `per_instance_stats.json` ...
16,269
from dataclasses import dataclass from typing import Optional, List import dacite from helm.common.general import parse_hocon from helm.common.hierarchical_logger import hlog class RunEntries: entries: List[RunEntry] def merge_run_entries(run_entries1: RunEntries, run_entries2: RunEntries): return RunEntries(ru...
Read a HOCON file `path` and return the `RunEntry`s.
16,270
import json import os import argparse from typing import List, DefaultDict, Set from collections import defaultdict from helm.common.general import asdict_without_nones, ensure_directory_exists from helm.common.hierarchical_logger import hlog, htrack_block from helm.benchmark.scenarios.scenario import ( Scenario, ...
Create a list of LightInstances given a ScenarioSpec. Only keep the text of the input and references. Note that one LightScenario object is created for each split of the Scenario for simplification.
16,271
import json import os import argparse from typing import List, DefaultDict, Set from collections import defaultdict from helm.common.general import asdict_without_nones, ensure_directory_exists from helm.common.hierarchical_logger import hlog, htrack_block from helm.benchmark.scenarios.scenario import ( Scenario, ...
Save a list of LightInstance to a jsonl file where each line represents a LightScenario object.
16,272
import json import os from typing import Dict, List from helm.common.general import ensure_file_downloaded def get_split_to_class_to_pinned_file_order(download_dir: str): """Lazily download and return a nested mapping of split to class to pinned file order.""" global _split_to_class_to_pinned_file_order if ...
List files for the split in a pinned order for IMDB to ensure reproducibility. Unfortunately, the previous official HELM runs used the arbitrary file order produced by os.listdir() and did not sort the files, so future runs must use the same file order in order to sample the same instances to reproduce the official HEL...
16,273
from collections import defaultdict from dataclasses import dataclass, field from itertools import combinations_with_replacement, product import math from math import comb import numpy as np import numpy.typing as npt import random from typing import List, Optional, Tuple, Dict from helm.benchmark.adaptation.adapters.a...
null
16,274
from collections import defaultdict from dataclasses import dataclass, field from itertools import combinations_with_replacement, product import math from math import comb import numpy as np import numpy.typing as npt import random from typing import List, Optional, Tuple, Dict from helm.benchmark.adaptation.adapters.a...
Formatting utility for multisets.
16,275
from collections import defaultdict from dataclasses import dataclass, field from itertools import combinations_with_replacement, product import math from math import comb import numpy as np import numpy.typing as npt import random from typing import List, Optional, Tuple, Dict from helm.benchmark.adaptation.adapters.a...
null
16,276
from collections import defaultdict from dataclasses import dataclass, field from itertools import combinations_with_replacement, product import math from math import comb import numpy as np import numpy.typing as npt import random from typing import List, Optional, Tuple, Dict from helm.benchmark.adaptation.adapters.a...
null
16,277
from collections import defaultdict from dataclasses import dataclass, field from itertools import combinations_with_replacement, product import math from math import comb import numpy as np import numpy.typing as npt import random from typing import List, Optional, Tuple, Dict from helm.benchmark.adaptation.adapters.a...
null
16,278
from collections import defaultdict from dataclasses import dataclass, field from itertools import combinations_with_replacement, product import math from math import comb import numpy as np import numpy.typing as npt import random from typing import List, Optional, Tuple, Dict from helm.benchmark.adaptation.adapters.a...
Unused.
16,279
from collections import defaultdict from dataclasses import dataclass, field from itertools import combinations_with_replacement, product import math from math import comb import numpy as np import numpy.typing as npt import random from typing import List, Optional, Tuple, Dict from helm.benchmark.adaptation.adapters.a...
Returns the minimum distance from the given point to the relation given by `rel_str` which has the form: A x - y + B = 0
16,280
from collections import defaultdict from dataclasses import dataclass, field from itertools import combinations_with_replacement, product import math from math import comb import numpy as np import numpy.typing as npt import random from typing import List, Optional, Tuple, Dict from helm.benchmark.adaptation.adapters.a...
Returns the minimum distance from the given point to the relation given by `rel_str` which has the form: y = A x^2 + B x + C
16,281
from collections import defaultdict from dataclasses import dataclass, field from itertools import combinations_with_replacement, product import math from math import comb import numpy as np import numpy.typing as npt import random from typing import List, Optional, Tuple, Dict from helm.benchmark.adaptation.adapters.a...
Returns the minimum distance from the given point to the relation given by `rel_str` which has the form: A x + B y - z + C = 0
16,282
from collections import defaultdict from dataclasses import dataclass, field from itertools import combinations_with_replacement, product import math from math import comb import numpy as np import numpy.typing as npt import random from typing import List, Optional, Tuple, Dict from helm.benchmark.adaptation.adapters.a...
Returns the minimum distance from the given point to the relation given by `rel_str` which has the form: z = A x^2 + B x y + C y^2 + D x + E y + F Uses method of Lagrange multipliers.
16,283
from collections import defaultdict from dataclasses import dataclass, field from itertools import combinations_with_replacement, product import math from math import comb import numpy as np import numpy.typing as npt import random from typing import List, Optional, Tuple, Dict from helm.benchmark.adaptation.adapters.a...
Choose disjoint intervals from which to sample points, where the test points lie within a region bounded by the region that the train points are sampled from.
16,284
from collections import defaultdict from dataclasses import dataclass, field from itertools import combinations_with_replacement, product import math from math import comb import numpy as np import numpy.typing as npt import random from typing import List, Optional, Tuple, Dict from helm.benchmark.adaptation.adapters.a...
null
16,285
from pathlib import Path from typing import List, Optional, Any import datasets from datasets import load_dataset from .scenario import Scenario, Instance, Reference, TRAIN_SPLIT, VALID_SPLIT, TEST_SPLIT, CORRECT_TAG, Input, Output def _clean_and_truncate(text: str, max_num_words: Optional[int] = None) -> str: tex...
null
16,286
import io import json import os import sys from typing import List, Dict, Iterable, Optional, cast from helm.common.general import ensure_file_downloaded from helm.common.hierarchical_logger import hlog from .code_scenario_helper import run as run_reindent from .code_scenario_apps_pinned_file_order import apps_listdir_...
null
16,287
import io import json import os import sys from typing import List, Dict, Iterable, Optional, cast from helm.common.general import ensure_file_downloaded from helm.common.hierarchical_logger import hlog from .code_scenario_helper import run as run_reindent from .code_scenario_apps_pinned_file_order import apps_listdir_...
Read APPS dataset. Adapted from https://github.com/lxuechen/apps/blob/main/train/dataset_apps/APPSBaseDataset.py
16,288
import numpy as np from typing import List, Dict, Tuple from .scenario import Scenario, Instance, Reference, TRAIN_SPLIT, VALID_SPLIT, TEST_SPLIT, CORRECT_TAG, Input, Output def subst(pattern: List[str], rule_symbol: str, substitute_str: str) -> List[str]: """ We substitute one rule symbols in a pattern accordi...
We substitute the rule symbols in a pattern according to a substitution dictionary. example: pattern = "A+B=B+A" rule_symbols = ["A", "B"] substitute_dict = {"A":"apple", "B":"peach"} return: "apple+peach=peach+apple" :param pattern: A Pattern representing the rule. :param rule_symbols: The set of rule symbols. :param ...
16,289
from collections import defaultdict from dataclasses import dataclass, field, replace from functools import cached_property from typing import List, Optional from helm.common.hierarchical_logger import hlog import dacite import re import yaml class Grammar: """ A grammar, specified by a set of `rules` defines a...
Read a grammar from `path` and return it.
16,290
from collections import defaultdict from dataclasses import dataclass, field, replace from functools import cached_property from typing import List, Optional from helm.common.hierarchical_logger import hlog import dacite import re import yaml ROOT_CATEGORY = "Root" def get_category(text: str) -> Optional[str]: """ ...
null
16,291
from collections import defaultdict from dataclasses import dataclass, field, replace from functools import cached_property from typing import List, Optional from helm.common.hierarchical_logger import hlog import dacite import re import yaml class Derivation: """ A `Derivation` corresponds to a node in a parse...
Return all the `values` that are collected recursively.
16,292
from collections import defaultdict from dataclasses import dataclass, field, replace from functools import cached_property from typing import List, Optional from helm.common.hierarchical_logger import hlog import dacite import re import yaml class Derivation: """ A `Derivation` corresponds to a node in a parse...
Return all the `tags` that are collected recursively.
16,293
import json import os from typing import Dict, Tuple import numpy as np from helm.common.general import ensure_file_downloaded def get_split_to_fixed_random_seed(download_dir: str): """Lazily download and return a dict of dataset to fixed random seed.""" global _split_to_fixed_random_seed if not _split_to_f...
Set the fixed random state for entity_matching_scenario to ensure reproducibility. Unfortunately, the previous official HELM runs did not initialize the numpy random state to zero, so future runs must use the same random states in order to sample the same test instances to reproduce the official HELM runs.
16,294
import os import json from typing import Dict, List from helm.common.general import ensure_file_downloaded def get_path_to_pinned_file_order(download_dir: str): """Lazily download and return a dict of path to pinned file order.""" global _path_to_pinned_file_order if not _path_to_pinned_file_order: ...
List files for the path in a pinned order for ICE to ensure reproducibility. Unfortunately, the previous official HELM runs used the arbitrary file order produced by os.listdir() and did not sort the files, so future runs must use the same file order in order to sample the same instances to reproduce the official HELM ...
16,295
from abc import ABC, abstractmethod from dataclasses import dataclass, field, replace from typing import List, Optional, Tuple import os from pathlib import PurePath import inspect from helm.common.media_object import MultimediaObject from helm.common.object_spec import ObjectSpec, create_object from helm.common.genera...
Make a relevance tag. Relevance value is an integer bigger than or equal to 0.
16,296
from abc import ABC, abstractmethod from dataclasses import dataclass, field, replace from typing import List, Optional, Tuple import os from pathlib import PurePath import inspect from helm.common.media_object import MultimediaObject from helm.common.object_spec import ObjectSpec, create_object from helm.common.genera...
Make a rank tag. Rank value is an integer bigger than or equal to 1.