Spaces:
Runtime error
Runtime error
Clémentine commited on
Commit ·
1ba1924
1
Parent(s): a6eaff8
add model architecture as column
Browse filesFiles changed (6)
53 unmodified lines5455565758596053 unmodified linesrestart_space()raw_data, original_df = get_leaderboard_df(EVAL_RESULTS_PATH, COLS, BENCHMARK_COLS)update_collections(original_df.copy())leaderboard_df = original_df.copy()53 unmodified lines5455565758596053 unmodified linesrestart_space()raw_data, original_df = get_leaderboard_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH, COLS, BENCHMARK_COLS)update_collections(original_df.copy())leaderboard_df = original_df.copy()
33 unmodified lines34353637383933 unmodified linesgsm8k = ColumnContent("GSM8K", "number", True)drop = ColumnContent("DROP", "number", True)model_type = ColumnContent("Type", "str", False)weight_type = ColumnContent("Weight type", "str", False, True)precision = ColumnContent("Precision", "str", False) # , True)license = ColumnContent("Hub License", "str", False)33 unmodified lines3435363738394033 unmodified linesgsm8k = ColumnContent("GSM8K", "number", True)drop = ColumnContent("DROP", "number", True)model_type = ColumnContent("Type", "str", False)architecture = ColumnContent("Architecture", "str", False)weight_type = ColumnContent("Weight type", "str", False, True)precision = ColumnContent("Precision", "str", False) # , True)license = ColumnContent("Hub License", "str", False)
5 unmodified lines678910113 unmodified lines15161718192021222324252627282930313233343536373819 unmodified lines58596061626364656629 unmodified lines969798991001011021031041051061071081091101111121132 unmodified lines1161171181191201211 unmodified line12312412512612712810 unmodified lines13914014114214314414514614712 unmodified lines1601611621631641651661676 unmodified lines1741751761771781791801811821831841851861871885 unmodified linesimport dateutilfrom datetime import datetimeimport numpy as npfrom src.display.formatting import make_clickable_model3 unmodified lines@dataclassclass EvalResult:eval_name: strfull_model: strorg: strmodel: strrevision: strresults: dictprecision: str = ""model_type: ModelType = ModelType.Unknownweight_type: str = "Original"architecture: str = "Unknown"license: str = "?"likes: int = 0num_params: int = 0date: str = ""still_on_hub: bool = False@classmethoddef init_from_json_file(self, json_filepath):with open(json_filepath) as fp:data = json.load(fp)19 unmodified linesresult_key = f"{org}_{model}_{precision}"full_model = "/".join(org_and_model)still_on_hub, error = is_model_on_hub(full_model, config.get("model_sha", "main"), trust_remote_code=True)# Extract results available in this file (some results are split in several files)results = {}29 unmodified linesorg=org,model=model,results=results,precision=precision, # todo model_type=, weight_type=revision=config.get("model_sha", ""),still_on_hub=still_on_hub,)def update_with_request_file(self):request_file = get_request_file_for_model(self.full_model, self.precision)try:with open(request_file, "r") as f:request = json.load(f)self.model_type = ModelType.from_str(request.get("model_type", ""))self.license = request.get("license", "?")self.likes = request.get("likes", 0)self.num_params = request.get("params", 0)2 unmodified linesprint(f"Could not find request file for {self.org}/{self.model}")def to_dict(self):average = sum([v for v in self.results.values() if v is not None]) / len(Tasks)data_dict = {"eval_name": self.eval_name, # not a column, just a save name,1 unmodified lineAutoEvalColumn.model_type.name: self.model_type.value.name,AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,AutoEvalColumn.weight_type.name: self.weight_type,AutoEvalColumn.model.name: make_clickable_model(self.full_model),AutoEvalColumn.dummy.name: self.full_model,AutoEvalColumn.revision.name: self.revision,10 unmodified linesreturn data_dictdef get_request_file_for_model(model_name, precision):request_files = os.path.join("eval-queue",f"{model_name}_eval_request_*.json",)request_files = glob.glob(request_files)12 unmodified linesreturn request_filedef get_raw_eval_results(results_path: str) -> list[EvalResult]:json_filepaths = []for root, _, files in os.walk(results_path):# We should only have json files in model results6 unmodified linesexcept dateutil.parser._parser.ParserError:files = [files[-1]]# up_to_date = files[-1]for file in files:json_filepaths.append(os.path.join(root, file))eval_results = {}for json_filepath in json_filepaths:# Creation of resulteval_result = EvalResult.init_from_json_file(json_filepath)eval_result.update_with_request_file()# Store results of same eval togethereval_name = eval_result.eval_name5 unmodified lines67891011123 unmodified lines161718192021222324252627282930313233343536373839404119 unmodified lines616263646566676869707172737429 unmodified lines1041051061071081091101111121131141151161171181191201211221231242 unmodified lines1271281291301311321331 unmodified line13513613713813914014110 unmodified lines15215315415515615715815916016112 unmodified lines1741751761771781791801811826 unmodified lines1891901911921931941951961971981992002012025 unmodified linesimport dateutilfrom datetime import datetimefrom transformers import AutoConfigimport numpy as npfrom src.display.formatting import make_clickable_model3 unmodified lines@dataclassclass EvalResult:# Also see src.display.utils.AutoEvalColumn for what will be displayed.eval_name: str # org_model_precision (uid)full_model: str # org/model (path on hub)org: strmodel: strrevision: str # commit hash, "" if mainresults: dictprecision: str = ""model_type: ModelType = ModelType.Unknown # Pretrained, fine tuned, ...weight_type: str = "Original" # Original or Adapterarchitecture: str = "Unknown" # From config filelicense: str = "?"likes: int = 0num_params: int = 0date: str = "" # submission date of request filestill_on_hub: bool = False@classmethoddef init_from_json_file(self, json_filepath):"""Inits the result from the specific model result file"""with open(json_filepath) as fp:data = json.load(fp)19 unmodified linesresult_key = f"{org}_{model}_{precision}"full_model = "/".join(org_and_model)still_on_hub, error, model_config = is_model_on_hub(full_model, config.get("model_sha", "main"), trust_remote_code=True)architecture = "?"if model_config is not None:architectures = getattr(model_config, "architectures", None)if architectures:architecture = ";".join(architectures)# Extract results available in this file (some results are split in several files)results = {}29 unmodified linesorg=org,model=model,results=results,precision=precision,revision= config.get("model_sha", ""),still_on_hub=still_on_hub,architecture=architecture)def update_with_request_file(self, requests_path):"""Finds the relevant request file for the current model and updates info with it"""request_file = get_request_file_for_model(requests_path, self.full_model, self.precision)try:with open(request_file, "r") as f:request = json.load(f)self.model_type = ModelType.from_str(request.get("model_type", ""))self.weight_type = request.get("weight_type", "?")self.license = request.get("license", "?")self.likes = request.get("likes", 0)self.num_params = request.get("params", 0)2 unmodified linesprint(f"Could not find request file for {self.org}/{self.model}")def to_dict(self):"""Converts the Eval Result to a dict compatible with our dataframe display"""average = sum([v for v in self.results.values() if v is not None]) / len(Tasks)data_dict = {"eval_name": self.eval_name, # not a column, just a save name,1 unmodified lineAutoEvalColumn.model_type.name: self.model_type.value.name,AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,AutoEvalColumn.weight_type.name: self.weight_type,AutoEvalColumn.architecture.name: self.architecture,AutoEvalColumn.model.name: make_clickable_model(self.full_model),AutoEvalColumn.dummy.name: self.full_model,AutoEvalColumn.revision.name: self.revision,10 unmodified linesreturn data_dictdef get_request_file_for_model(requests_path, model_name, precision):"""Selects the correct request file for a given model. Only keeps runs tagged as FINISHED"""request_files = os.path.join(requests_path,f"{model_name}_eval_request_*.json",)request_files = glob.glob(request_files)12 unmodified linesreturn request_filedef get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResult]:"""From the path of the results folder root, extract all needed info for results"""model_result_filepaths = []for root, _, files in os.walk(results_path):# We should only have json files in model results6 unmodified linesexcept dateutil.parser._parser.ParserError:files = [files[-1]]for file in files:model_result_filepaths.append(os.path.join(root, file))eval_results = {}for model_result_filepath in model_result_filepaths:# Creation of resulteval_result = EvalResult.init_from_json_file(model_result_filepath)eval_result.update_with_request_file(requests_path)# Store results of same eval togethereval_name = eval_result.eval_name
8 unmodified lines9101112131415168 unmodified linesfrom src.leaderboard.read_evals import get_raw_eval_resultsdef get_leaderboard_df(results_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:raw_data = get_raw_eval_results(results_path)all_data_json = [v.to_dict() for v in raw_data]all_data_json.append(baseline_row)filter_models(all_data_json)8 unmodified lines9101112131415168 unmodified linesfrom src.leaderboard.read_evals import get_raw_eval_resultsdef get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:raw_data = get_raw_eval_results(results_path, requests_path)all_data_json = [v.to_dict() for v in raw_data]all_data_json.append(baseline_row)filter_models(all_data_json)
37 unmodified lines383940414243444546474849505152535437 unmodified linesdef is_model_on_hub(model_name: str, revision: str, token: str = None, trust_remote_code=False) -> tuple[bool, str]:try:AutoConfig.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)return True, Noneexcept ValueError:return (False,"needs to be launched with `trust_remote_code=True`. For safety reason, we do not allow these models to be automatically submitted to the leaderboard.",)except Exception:return False, "was not found on hub!"def get_model_size(model_info: ModelInfo, precision: str):37 unmodified lines38394041424344454647484950515253545537 unmodified linesdef is_model_on_hub(model_name: str, revision: str, token: str = None, trust_remote_code=False) -> tuple[bool, str]:try:config = AutoConfig.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)return True, None, configexcept ValueError:return (False,"needs to be launched with `trust_remote_code=True`. For safety reason, we do not allow these models to be automatically submitted to the leaderboard.",None)except Exception:return False, "was not found on hub!", Nonedef get_model_size(model_info: ModelInfo, precision: str):
47 unmodified lines48495051525354555657585947 unmodified lines# Is the model on the hub?if weight_type in ["Delta", "Adapter"]:base_model_on_hub, error = is_model_on_hub(base_model, revision, H4_TOKEN)if not base_model_on_hub:return styled_error(f'Base model "{base_model}" {error}')if not weight_type == "Adapter":model_on_hub, error = is_model_on_hub(model, revision)if not model_on_hub:return styled_error(f'Model "{model}" {error}')47 unmodified lines48495051525354555657585947 unmodified lines# Is the model on the hub?if weight_type in ["Delta", "Adapter"]:base_model_on_hub, error, _ = is_model_on_hub(base_model, revision, H4_TOKEN)if not base_model_on_hub:return styled_error(f'Base model "{base_model}" {error}')if not weight_type == "Adapter":model_on_hub, error, _ = is_model_on_hub(model, revision)if not model_on_hub:return styled_error(f'Model "{model}" {error}')
app.py+1-1
src/display/utils.py+1
src/leaderboard/read_evals.py+36-22
src/populate.py+2-2
src/submission/check_validity.py+4-3
src/submission/submit.py+2-2