Spaces:
Running
Running
verbose mode
Browse files125 unmodified lines1261271281291301311321331341 unmodified line136137138139140141142143144145146147297 unmodified lines445446447448449450451125 unmodified lineselse:responses = decode_choice(responses)return [int(response == reference) for reference, response in zip(references, responses)]class Metrics:1 unmodified linemmlu = multichoicedef gsm8k(responses: list[str], answers: list[str | int]):scores = []for response, answer in zip(responses, answers):pred = extract_numeric(response)gold = extract_numeric(answer) if isinstance(answer, str) else str(answer)scores.append(1.0 * (pred == gold))return scoresdef MATH(responses: list[str], answers: list[str]):scores = []297 unmodified lineslabel_column=cls.label_column,prompt=partial(cls.prompt_mmlu, chat=chat),few_shot=0 if chat else 5,few_shot_from="validation")for subcategories in finer_categories[subject]]125 unmodified lines1261271281291301311321331341351 unmodified line137138139140141142143144145146147148149150151152153154297 unmodified lines452453454455456457458125 unmodified lineselse:responses = decode_choice(responses)# return [# int(response == reference) for reference, response in zip(references, responses)# ]return responses, referencesclass Metrics:1 unmodified linemmlu = multichoicedef gsm8k(responses: list[str], answers: list[str | int]):# scores = []# for response, answer in zip(responses, answers):# pred = extract_numeric(response)# gold = extract_numeric(answer) if isinstance(answer, str) else str(answer)# scores.append(1.0 * (pred == gold))responses = [extract_numeric(response) for response in responses]answers = [extract_numeric(answer) if isinstance(answer, str) else str(answer)for answer in answers]return responses, answersdef MATH(responses: list[str], answers: list[str]):scores = []297 unmodified lineslabel_column=cls.label_column,prompt=partial(cls.prompt_mmlu, chat=chat),few_shot=0 if chat else 5,few_shot_from="validation",)for subcategories in finer_categories[subject]]
5 unmodified lines6789101158 unmodified lines707172737475767778795 unmodified linesimport loggingfrom typing import Any, Optional, Protocol, Iterable, Callablefrom tqdm.auto import tqdmfrom evaluate.evaluation_suite import EvaluationSuiteimport evaluate58 unmodified linesreference_urls=["http://path.to.reference.url/new_module"],)def _compute(self, responses, references):scores = getattr(Metrics, self.config_name)(responses, references)results = {"Accuracy": np.nanmean(scores)}logging.info(results)return results5 unmodified lines678910111258 unmodified lines71727374757677787980818283848586878889909192939495965 unmodified linesimport loggingfrom typing import Any, Optional, Protocol, Iterable, Callablefrom numpy.lib import extractfrom tqdm.auto import tqdmfrom evaluate.evaluation_suite import EvaluationSuiteimport evaluate58 unmodified linesreference_urls=["http://path.to.reference.url/new_module"],)def _compute(self, responses, references, verbose=False):extract_responses, extract_references = getattr(Metrics, self.config_name)(responses, references)df = pd.DataFrame({"responses": responses,"references": references,})df["extract_responses"] = extract_responsesdf["extract_references"] = extract_referencesresults = {"Accuracy": (df["extract_references"] == df["extract_responses"]).astype(int).mean(),}logging.info(results)if verbose:results["df"] = dfreturn results
tasks.py+17-10
tlem.py+20-3