Spaces:
Runtime error
Runtime error
| import pandas as pd | |
| from pathlib import Path | |
| abs_path = Path(__file__).parent.parent.parent | |
| # ORDER_LIST = ["Name", "Lang", "Score", "Parameters (B)", "Date"] | |
| # COLUMN_HEADERS = ["Name", "Language", "Score", "Parameters (B)", "Date"] | |
| # DATA_TYPES = ["markdown", "str", "number", "number", "str"] | |
| ORDER_LIST = ["Name", "Lang", "Score", "Parameters (B)"] | |
| COLUMN_HEADERS = ["Name", "Language", "Score", "Parameters (B)"] | |
| DATA_TYPES = ["markdown", "str", "number", "number"] | |
| def filter_data(selected_columns, search_query): | |
| df = LB_LLMZSZL[selected_columns] | |
| if search_query: | |
| df = df[df['Name'].str.contains(search_query, case=False, na=False)] | |
| return df | |
| def filter_row(language): | |
| if language: | |
| return LB_LLMZSZL[LB_LLMZSZL["Lang"] == language] | |
| return LB_LLMZSZL | |
| def filter_columns(column_choices): | |
| selected_columns = [col for col in ORDER_LIST if col in column_choices] | |
| return LB_LLMZSZL[selected_columns] | |
| def load_json_data(file_path, order_list): | |
| LB_LLMZSZL = pd.read_json(file_path) | |
| for column in LB_LLMZSZL.columns: | |
| if LB_LLMZSZL[column].apply(type).eq(dict).any(): | |
| LB_LLMZSZL[column] = LB_LLMZSZL[column].apply(str) | |
| LB_LLMZSZL["Name"] = LB_LLMZSZL["Name"].apply( | |
| lambda name: f"[{name}](https://huggingface.co/{name})" | |
| ) | |
| lang_replacements = { | |
| 'E': 'English', | |
| 'P': 'Polish', | |
| 'm': 'Multilingual' | |
| } | |
| LB_LLMZSZL["Lang"] = LB_LLMZSZL["Lang"].apply( | |
| lambda lang_code: lang_replacements.get(lang_code, lang_code) # Replace using the dictionary, keep original if not found | |
| ) | |
| if "Parameters (B)" in LB_LLMZSZL.columns: | |
| LB_LLMZSZL["Parameters (B)"] = LB_LLMZSZL["Parameters (B)"].astype(float).round(1) | |
| ordered_columns = [col for col in order_list if col in LB_LLMZSZL.columns] | |
| LB_LLMZSZL = LB_LLMZSZL[ordered_columns] | |
| LB_LLMZSZL = LB_LLMZSZL.sort_values(by="Score", ascending=False) | |
| return LB_LLMZSZL | |
| file_path = str(abs_path / "leaderboards/llmzszl.json") | |
| LB_LLMZSZL = load_json_data(file_path, ORDER_LIST) | |