Spaces:
Runtime error
Runtime error
Clémentine commited on
Commit ·
f26addb
1
Parent(s): 818f024
added automatic update of the best LLM models
Browse filesFiles changed (3)
- app.py+3-1
- requirements.txt+1-1
- src/manage_collections.pyAdded+65
26 unmodified lines27282930313255 unmodified lines888990919293212 unmodified lines30630730830931031131226 unmodified linesstyled_message,styled_warning,)from 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_permission55 unmodified linesrequested_models, users_to_submission_dates = get_all_requested_models(EVAL_REQUESTS_PATH)original_df = get_leaderboard_df(EVAL_RESULTS_PATH, COLS, BENCHMARK_COLS)leaderboard_df = original_df.copy()models = original_df["model_name_for_query"].tolist() # needed for model backlinks in their to the leaderboard212 unmodified linesif show_deleted:filtered_df = dfelse: # Show only still on the hub modelsfiltered_df = df[df[AutoEvalColumn.still_on_hub.name] is True]type_emoji = [t[0] for t in type_query]filtered_df = filtered_df[df[AutoEvalColumn.model_type_symbol.name].isin(type_emoji)]26 unmodified lines2728293031323355 unmodified lines89909192939495212 unmodified lines30830931031131231331426 unmodified linesstyled_message,styled_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_permission55 unmodified linesrequested_models, users_to_submission_dates = get_all_requested_models(EVAL_REQUESTS_PATH)original_df = get_leaderboard_df(EVAL_RESULTS_PATH, COLS, BENCHMARK_COLS)update_collections(original_df.copy())leaderboard_df = original_df.copy()models = original_df["model_name_for_query"].tolist() # needed for model backlinks in their to the leaderboard212 unmodified linesif show_deleted:filtered_df = dfelse: # Show only still on the hub modelsfiltered_df = df[df[AutoEvalColumn.still_on_hub.name] == True]type_emoji = [t[0] for t in type_query]filtered_df = filtered_df[df[AutoEvalColumn.model_type_symbol.name].isin(type_emoji)]
24 unmodified lines2526272829303124 unmodified linesh11==0.14.0httpcore==0.17.0httpx==0.24.0huggingface-hub==0.16.4idna==3.4Jinja2==3.1.2jsonschema==4.17.324 unmodified lines2526272829303124 unmodified linesh11==0.14.0httpcore==0.17.0httpx==0.24.0huggingface-hub==0.18.0idna==3.4Jinja2==3.1.2jsonschema==4.17.3
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465import osimport pandas as pdfrom pandas import DataFramefrom huggingface_hub import get_collection, add_collection_item, delete_collection_itemfrom huggingface_hub.utils._errors import HfHubHTTPError
from src.display_models.model_metadata_type import ModelTypefrom src.display_models.utils import AutoEvalColumn
H4_TOKEN = os.environ.get("H4_TOKEN", None)
path_to_collection = "HuggingFaceH4/current-best-models-of-the-open-llm-leaderboard-652d64cf619fc62beef5c2a3"intervals = { "1B": pd.Interval(0, 1.5, closed="right"), "3B": pd.Interval(2.5, 3.5, closed="neither"), "7B": pd.Interval(6, 8, closed="neither"), "13B": pd.Interval(10, 14, closed="neither"), "30B":pd.Interval(25, 35, closed="neither"), "60B": pd.Interval(55, 65, closed="neither"),}
def update_collections(df: DataFrame): """This function updates the Open LLM Leaderboard model collection with the latest best models for each size category and type. """ params_column = pd.to_numeric(df[AutoEvalColumn.params.name], errors="coerce")
cur_best_models = []
for type in ModelType: if type.value.name == "": continue for size in intervals: # We filter the df to gather the relevant models type_emoji = [t[0] for t in type.value.symbol] filtered_df = df[df[AutoEvalColumn.model_type_symbol.name].isin(type_emoji)]
numeric_interval = pd.IntervalIndex([intervals[size]]) mask = params_column.apply(lambda x: any(numeric_interval.contains(x))) filtered_df = filtered_df.loc[mask]
best_models = list(filtered_df.sort_values(AutoEvalColumn.average.name, ascending=False)[AutoEvalColumn.dummy.name])
# We add them one by one to the leaderboard for model in best_models: # We can use collection = get_collection to grab the id of the last item, then place it where we want using update_collection but it's costly... # We could also remove exists_ok to update the note to include the date of apparition of the model for ex. try: add_collection_item( path_to_collection, item_id=model, item_type="model", exists_ok=True, note=f"Best {type.to_str(' ')} model of {size} on the leaderboard today!", token=H4_TOKEN ) cur_best_models.append(model) break except HfHubHTTPError: continue
collection = get_collection(path_to_collection, token=H4_TOKEN) for item in collection.items: if item.item_id not in cur_best_models: delete_collection_item(collection_slug=path_to_collection, item_object_id=item.item_object_id, token=H4_TOKEN)
app.py+3-1
requirements.txt+1-1
src/manage_collections.pyAdded+65