Spaces:
Runtime error
Runtime error
Clémentine commited on
Commit ·
c0da33d
1
Parent(s): 238e793
reorg to simplify nav in code base
Browse filesFiles changed (14)
- app.py+23-37
- src/assets/hardcoded_evals.py+1-1
- src/assets/text_content.py+7-6
- src/display_models/modelcard_filter.py → src/filters.pyRenamed+40
- src/display_models/get_model_metadata.py → src/get_model_info/apply_metadata_to_df.pyRenamed+4-4
- src/get_model_info/get_metadata_from_hub.pyAdded+19
- src/display_models/model_metadata_flags.py → src/get_model_info/hardocded_metadata/flags.pyRenamed
- src/display_models/model_metadata_type.py → src/get_model_info/hardocded_metadata/types.pyRenamed
- src/display_models/utils.py → src/get_model_info/utils.pyRenamed
- src/load_from_hub.py+3-18
- src/manage_collections.py+2-2
- src/display_models/plot_results.py → src/plots/plot_results.pyRenamed+1-1
- src/display_models/read_results.py → src/plots/read_results.pyRenamed+2-2
- src/rate_limiting.pyDeleted-13
16 unmodified lines171819202122232425262728293031322 unmodified lines353637383940414284 unmodified lines12712812913013113213313413513613713813914014 unmodified lines15515615715815916016116216316416516616716816917017117217317417517617717817918018118296 unmodified lines27928028128228328428528628728828929029116 unmodified linesLLM_BENCHMARKS_TEXT,TITLE,)from src.display_models.plot_results import (create_metric_plot_obj,create_scores_df,create_plot_df,join_model_info_with_results,HUMAN_BASELINES,)from src.display_models.get_model_metadata import DO_NOT_SUBMIT_MODELS, ModelTypefrom src.display_models.modelcard_filter import check_model_cardfrom src.display_models.utils import (AutoEvalColumn,EvalQueueColumn,fields,2 unmodified linesstyled_warning,)from src.manage_collections import update_collectionsfrom src.load_from_hub import get_all_requested_models, get_evaluation_queue_df, get_leaderboard_df, is_model_on_hubfrom src.rate_limiting import user_submission_permissionpd.set_option("display.precision", 1)84 unmodified linesreturn styled_error("Please select a model type.")# Is the user rate limited?num_models_submitted_in_period = user_submission_permission(model, users_to_submission_dates, RATE_LIMIT_PERIOD)if num_models_submitted_in_period > RATE_LIMIT_QUOTA:error_msg = f"Organisation or user `{model.split('/')[0]}`"error_msg += f"already has {num_models_submitted_in_period} model requests submitted to the leaderboard "error_msg += f"in the last {RATE_LIMIT_PERIOD} days.\n"error_msg += ("Please wait a couple of days before resubmitting, so that everybody can enjoy using the leaderboard 🤗")return styled_error(error_msg)# Did the model authors forbid its submission to the leaderboard?14 unmodified linesif not model_on_hub:return styled_error(f'Model "{model}" {error}')model_info = api.model_info(repo_id=model, revision=revision)size_pattern = size_pattern = re.compile(r"(\d\.)?\d+(b|m)")try:model_size = round(model_info.safetensors["total"] / 1e9, 3)except AttributeError:try:size_match = re.search(size_pattern, model.lower())model_size = size_match.group(0)model_size = round(float(model_size[:-1]) if model_size[-1] == "b" else float(model_size[:-1]) / 1e3, 3)except AttributeError:return 65size_factor = 8 if (precision == "GPTQ" or "GPTQ" in model) else 1model_size = size_factor * model_sizetry:license = model_info.cardData["license"]except Exception:license = "?"# Were the model card and license filled?modelcard_OK, error_msg = check_model_card(model)if not modelcard_OK:return styled_error(error_msg)96 unmodified linesNUMERIC_INTERVALS = {"?": pd.Interval(-1, 0, closed="right"),"0~1.5": pd.Interval(0, 1.5, closed="right"),"1.5~3": pd.Interval(1.5, 3, closed="right"),"3~7": pd.Interval(3, 7, closed="right"),"7~13": pd.Interval(7, 13, closed="right"),"13~35": pd.Interval(13, 35, closed="right"),"35~60": pd.Interval(35, 60, closed="right"),"60+": pd.Interval(60, 10000, closed="right"),}16 unmodified lines17181920212223242526272829303132332 unmodified lines363738394041424384 unmodified lines12812913013113213313413514 unmodified lines15015115215315415515615715815916016116216316416516616716896 unmodified lines26526626726826927027127227327427527627716 unmodified linesLLM_BENCHMARKS_TEXT,TITLE,)from src.plots.plot_results import (create_metric_plot_obj,create_scores_df,create_plot_df,join_model_info_with_results,HUMAN_BASELINES,)from src.get_model_info.apply_metadata_to_df import DO_NOT_SUBMIT_MODELS, ModelTypefrom src.get_model_info.get_metadata_from_hub import get_model_sizefrom src.filters import check_model_cardfrom src.get_model_info.utils import (AutoEvalColumn,EvalQueueColumn,fields,2 unmodified linesstyled_warning,)from src.manage_collections import update_collectionsfrom src.load_from_hub import get_all_requested_models, get_evaluation_queue_df, get_leaderboard_dffrom src.filters import is_model_on_hub, user_submission_permissionpd.set_option("display.precision", 1)84 unmodified linesreturn styled_error("Please select a model type.")# Is the user rate limited?user_can_submit, error_msg = user_submission_permission(model, users_to_submission_dates, RATE_LIMIT_PERIOD, RATE_LIMIT_QUOTA)if not user_can_submit:return styled_error(error_msg)# Did the model authors forbid its submission to the leaderboard?14 unmodified linesif not model_on_hub:return styled_error(f'Model "{model}" {error}')try:model_info = api.model_info(repo_id=model, revision=revision)except Exception:return styled_error("Could not get your model information. Please fill it up properly.")model_size = get_model_size(model_info=model_info , precision= precision)# Were the model card and license filled?try:license = model_info.cardData["license"]except Exception:return styled_error("Please select a license for your model")modelcard_OK, error_msg = check_model_card(model)if not modelcard_OK:return styled_error(error_msg)96 unmodified linesNUMERIC_INTERVALS = {"?": pd.Interval(-1, 0, closed="right"),"~1.5": pd.Interval(0, 2, closed="right"),"~3": pd.Interval(2, 4, closed="right"),"~7": pd.Interval(4, 9, closed="right"),"~13": pd.Interval(9, 20, closed="right"),"~35": pd.Interval(20, 45, closed="right"),"~60": pd.Interval(45, 70, closed="right"),"70+": pd.Interval(70, 10000, closed="right"),}
1234from src.display_models.utils import AutoEvalColumn, model_hyperlinkgpt4_values = {AutoEvalColumn.model.name: model_hyperlink("https://arxiv.org/abs/2303.08774", "gpt4"),1234from src.get_model_info.utils import AutoEvalColumn, model_hyperlinkgpt4_values = {AutoEvalColumn.model.name: model_hyperlink("https://arxiv.org/abs/2303.08774", "gpt4"),
12349 unmodified lines14151617181920212223242526from src.display_models.model_metadata_type import ModelTypeTITLE = """<h1 align="center" id="space-title">🤗 Open LLM Leaderboard</h1>"""9 unmodified linesWith the plethora of large language models (LLMs) and chatbots being released week upon week, often with grandiose claims of their performance, it can be hard to filter out the genuine progress that is being made by the open-source community and which model is the current state of the art.## Icons{ModelType.PT.to_str(" : ")} model{ModelType.FT.to_str(" : ")} model{ModelType.IFT.to_str(" : ")} model{ModelType.RL.to_str(" : ")} modelIf there is no icon, we have not uploaded the information on the model yet, feel free to open an issue with the model information!🏴☠️ indicates that this model has been flagged by the community, and should probably be ignored! Clicking the icon will redirect you to the discussion about the model.(For ex, the model was trained on the evaluation data, and is therefore cheating on the leaderboard.)## How it works12349 unmodified lines1415161718192021222324252627from src.get_model_info.hardocded_metadata.types import ModelTypeTITLE = """<h1 align="center" id="space-title">🤗 Open LLM Leaderboard</h1>"""9 unmodified linesWith the plethora of large language models (LLMs) and chatbots being released week upon week, often with grandiose claims of their performance, it can be hard to filter out the genuine progress that is being made by the open-source community and which model is the current state of the art.## Icons{ModelType.PT.to_str(" : ")} model: new, base models, trained on a given corpora{ModelType.FT.to_str(" : ")} model: pretrained models finetuned on more dataSpecific fine-tune subcategories (more adapted to chat):{ModelType.IFT.to_str(" : ")} model: instruction fine-tunes, which are model fine-tuned specifically on datasets of task instruction{ModelType.RL.to_str(" : ")} model: reinforcement fine-tunes, which usually change the model loss a bit with an added policy.If there is no icon, we have not uploaded the information on the model yet, feel free to open an issue with the model information!"Flagged" indicates that this model has been flagged by the community, and should probably be ignored! Clicking the link will redirect you to the discussion about the model.(For ex, the model was trained on the evaluation data, and is therefore cheating on the leaderboard.)## How it works
1234518 unmodified lines242526import huggingface_hubfrom huggingface_hub import ModelCard# ht to @Wauplin, thank you for the snippet!18 unmodified linesreturn False, "Please add a description to your model card, it is too short."return True, ""1234567818 unmodified lines27282930313233343536373839404142434445464748495051525354555657585960616263646566import huggingface_hubfrom huggingface_hub import ModelCardfrom transformers import AutoConfigfrom datetime import datetime, timedelta, timezone# ht to @Wauplin, thank you for the snippet!18 unmodified linesreturn False, "Please add a description to your model card, it is too short."return True, ""def is_model_on_hub(model_name: str, revision: str) -> bool:try:AutoConfig.from_pretrained(model_name, revision=revision, trust_remote_code=False)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 user_submission_permission(submission_name, users_to_submission_dates, rate_limit_period, rate_limit_quota):org_or_user, _ = submission_name.split("/")if org_or_user not in users_to_submission_dates:return True, ""submission_dates = sorted(users_to_submission_dates[org_or_user])time_limit = (datetime.now(timezone.utc) - timedelta(days=rate_limit_period)).strftime("%Y-%m-%dT%H:%M:%SZ")submissions_after_timelimit = [d for d in submission_dates if d > time_limit]num_models_submitted_in_period = len(submissions_after_timelimit)if num_models_submitted_in_period > rate_limit_quota:error_msg = f"Organisation or user `{org_or_user}`"error_msg += f"already has {num_models_submitted_in_period} model requests submitted to the leaderboard "error_msg += f"in the last {rate_limit_period} days.\n"error_msg += ("Please wait a couple of days before resubmitting, so that everybody can enjoy using the leaderboard 🤗")return False, error_msgreturn True, ""
5 unmodified lines6789101112131426 unmodified lines414243444546475 unmodified linesfrom huggingface_hub import HfApifrom tqdm import tqdmfrom src.display_models.model_metadata_flags import DO_NOT_SUBMIT_MODELS, FLAGGED_MODELSfrom src.display_models.model_metadata_type import MODEL_TYPE_METADATA, ModelType, model_type_from_strfrom src.display_models.utils import AutoEvalColumn, model_hyperlinkapi = HfApi(token=os.environ.get("H4_TOKEN", None))26 unmodified linesrequest = json.load(f)model_type = model_type_from_str(request["model_type"])model_data[AutoEvalColumn.model_type.name] = model_type.value.namemodel_data[AutoEvalColumn.model_type_symbol.name] = model_type.value.symbol # + ("🔺" if is_delta else "")model_data[AutoEvalColumn.license.name] = request["license"]model_data[AutoEvalColumn.likes.name] = request["likes"]model_data[AutoEvalColumn.params.name] = request["params"]5 unmodified lines6789101112131426 unmodified lines414243444546475 unmodified linesfrom huggingface_hub import HfApifrom tqdm import tqdmfrom src.get_model_info.hardocded_metadata.flags import DO_NOT_SUBMIT_MODELS, FLAGGED_MODELSfrom src.get_model_info.hardocded_metadata.types import MODEL_TYPE_METADATA, ModelType, model_type_from_strfrom src.get_model_info.utils import AutoEvalColumn, model_hyperlinkapi = HfApi(token=os.environ.get("H4_TOKEN", None))26 unmodified linesrequest = json.load(f)model_type = model_type_from_str(request["model_type"])model_data[AutoEvalColumn.model_type.name] = model_type.value.namemodel_data[AutoEvalColumn.model_type_symbol.name] = model_type.value.symbolmodel_data[AutoEvalColumn.license.name] = request["license"]model_data[AutoEvalColumn.likes.name] = request["likes"]model_data[AutoEvalColumn.params.name] = request["params"]
12345678910111213141516171819import refrom huggingface_hub.hf_api import ModelInfo
def get_model_size(model_info: ModelInfo, precision: str): size_pattern = size_pattern = re.compile(r"(\d\.)?\d+(b|m)") try: model_size = round(model_info.safetensors["total"] / 1e9, 3) except AttributeError: try: size_match = re.search(size_pattern, model_info.modelId.lower()) model_size = size_match.group(0) model_size = round(float(model_size[:-1]) if model_size[-1] == "b" else float(model_size[:-1]) / 1e3, 3) except AttributeError: return 0 # Unknown model sizes are indicated as 0, see NUMERIC_INTERVALS in app.py
size_factor = 8 if (precision == "GPTQ" or "gptq" in model_info.modelId.lower()) else 1 model_size = size_factor * model_size return model_size2 unmodified lines3456789101112131475 unmodified lines909192939495969798991001011021031041051062 unmodified linesfrom collections import defaultdictimport pandas as pdfrom transformers import AutoConfigfrom src.assets.hardcoded_evals import baseline, gpt4_values, gpt35_valuesfrom src.display_models.get_model_metadata import apply_metadatafrom src.display_models.read_results import get_eval_results_dicts, make_clickable_modelfrom src.display_models.utils import AutoEvalColumn, EvalQueueColumn, has_no_nan_valuesIS_PUBLIC = bool(os.environ.get("IS_PUBLIC", True))75 unmodified linesdf_finished = pd.DataFrame.from_records(finished_list, columns=cols)return df_finished[cols], df_running[cols], df_pending[cols]def is_model_on_hub(model_name: str, revision: str) -> bool:try:AutoConfig.from_pretrained(model_name, revision=revision, trust_remote_code=False)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!"2 unmodified lines34567891011121375 unmodified lines8990912 unmodified linesfrom collections import defaultdictimport pandas as pdfrom src.assets.hardcoded_evals import baseline, gpt4_values, gpt35_valuesfrom src.get_model_info.apply_metadata_to_df import apply_metadatafrom src.plots.read_results import get_eval_results_dicts, make_clickable_modelfrom src.get_model_info.utils import AutoEvalColumn, EvalQueueColumn, has_no_nan_valuesIS_PUBLIC = bool(os.environ.get("IS_PUBLIC", True))75 unmodified linesdf_finished = pd.DataFrame.from_records(finished_list, columns=cols)return df_finished[cols], df_running[cols], df_pending[cols]
4 unmodified lines567891011124 unmodified linesfrom huggingface_hub import get_collection, add_collection_item, update_collection_item, delete_collection_itemfrom huggingface_hub.utils._errors import HfHubHTTPErrorfrom src.display_models.model_metadata_type import ModelTypefrom src.display_models.utils import AutoEvalColumnH4_TOKEN = os.environ.get("H4_TOKEN", None)4 unmodified lines567891011124 unmodified linesfrom huggingface_hub import get_collection, add_collection_item, update_collection_item, delete_collection_itemfrom huggingface_hub.utils._errors import HfHubHTTPErrorfrom src.get_model_info.hardocded_metadata.types import ModelTypefrom src.get_model_info.utils import AutoEvalColumnH4_TOKEN = os.environ.get("H4_TOKEN", None)
3 unmodified lines456789103 unmodified linesimport picklefrom datetime import datetime, timezonefrom typing import List, Dict, Tuple, Anyfrom src.display_models.model_metadata_flags import FLAGGED_MODELS# Average ⬆️ human baseline is 0.897 (source: averaging human baselines below)# ARC human baseline is 0.80 (source: https://lab42.global/arc/)3 unmodified lines456789103 unmodified linesimport picklefrom datetime import datetime, timezonefrom typing import List, Dict, Tuple, Anyfrom src.get_model_info.hardocded_metadata.flags import FLAGGED_MODELS# Average ⬆️ human baseline is 0.897 (source: averaging human baselines below)# ARC human baseline is 0.80 (source: https://lab42.global/arc/)
5 unmodified lines678910111218 unmodified lines313233343536375 unmodified linesimport dateutilimport numpy as npfrom src.display_models.utils import AutoEvalColumn, make_clickable_modelMETRICS = ["acc_norm", "acc_norm", "acc", "mc2"]BENCHMARKS = ["arc:challenge", "hellaswag", "hendrycksTest", "truthfulqa:mc"]18 unmodified linesdate: str = ""def to_dict(self):from src.load_from_hub import is_model_on_hubif self.org is not None:base_model = f"{self.org}/{self.model}"5 unmodified lines678910111218 unmodified lines313233343536375 unmodified linesimport dateutilimport numpy as npfrom src.get_model_info.utils import AutoEvalColumn, make_clickable_modelMETRICS = ["acc_norm", "acc_norm", "acc", "mc2"]BENCHMARKS = ["arc:challenge", "hellaswag", "hendrycksTest", "truthfulqa:mc"]18 unmodified linesdate: str = ""def to_dict(self):from src.filters import is_model_on_hubif self.org is not None:base_model = f"{self.org}/{self.model}"
12345678910111213from datetime import datetime, timedelta, timezone
def user_submission_permission(submission_name, users_to_submission_dates, rate_limit_period): org_or_user, _ = submission_name.split("/") if org_or_user not in users_to_submission_dates: return 0 submission_dates = sorted(users_to_submission_dates[org_or_user])
time_limit = (datetime.now(timezone.utc) - timedelta(days=rate_limit_period)).strftime("%Y-%m-%dT%H:%M:%SZ") submissions_after_timelimit = [d for d in submission_dates if d > time_limit]
return len(submissions_after_timelimit)app.py+23-37
src/assets/hardcoded_evals.py+1-1
src/assets/text_content.py+7-6
src/display_models/modelcard_filter.py → src/filters.pyRenamed+40
src/display_models/get_model_metadata.py → src/get_model_info/apply_metadata_to_df.pyRenamed+4-4
src/get_model_info/get_metadata_from_hub.pyAdded+19
src/display_models/model_metadata_flags.py → src/get_model_info/hardocded_metadata/flags.pyRenamed
src/display_models/model_metadata_type.py → src/get_model_info/hardocded_metadata/types.pyRenamed
src/display_models/utils.py → src/get_model_info/utils.pyRenamed
src/load_from_hub.py+3-18
src/manage_collections.py+2-2
src/display_models/plot_results.py → src/plots/plot_results.pyRenamed+1-1
src/display_models/read_results.py → src/plots/read_results.pyRenamed+2-2
src/rate_limiting.pyDeleted-13