Spaces:
Running
Running
verbose mode
Browse files125 unmodified lines1261271281291301311291301311321331341351 unmodified line137138139139140141142143144140141142143144145146147148149150151152153154297 unmodified lines452453454448455456457458125 unmodified lines else: responses = decode_choice(responses)
return [ int(response == reference) for reference, response in zip(references, responses) ] # return [ # int(response == reference) for reference, response in zip(references, responses) # ] return responses, references
class Metrics:1 unmodified line mmlu = multichoice
def 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 scores # 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, answers
def MATH(responses: list[str], answers: list[str]): scores = []297 unmodified lines label_column=cls.label_column, prompt=partial(cls.prompt_mmlu, chat=chat), few_shot=0 if chat else 5, few_shot_from="validation" few_shot_from="validation", ) for subcategories in finer_categories[subject] ]5 unmodified lines678910111258 unmodified lines71727373747574757677787980818283848586878889909192939495965 unmodified lines import logging
from typing import Any, Optional, Protocol, Iterable, Callablefrom numpy.lib import extractfrom tqdm.auto import tqdmfrom evaluate.evaluation_suite import EvaluationSuiteimport evaluate58 unmodified lines reference_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)} 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_responses df["extract_references"] = extract_references results = { "Accuracy": (df["extract_references"] == df["extract_responses"]) .astype(int) .mean(), } logging.info(results) if verbose: results["df"] = df return results
tasks.py+17-10
tlem.py+20-3