Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
-
from huggingface_hub import HfApi, ModelCard
|
| 4 |
from huggingface_hub.utils import RepositoryNotFoundError, RevisionNotFoundError
|
| 5 |
import re
|
| 6 |
from io import StringIO
|
|
@@ -16,26 +16,21 @@ def cached_model_info(_api, model):
|
|
| 16 |
"""Fetch model information from the Hugging Face API and cache the result."""
|
| 17 |
try:
|
| 18 |
return _api.model_info(repo_id=str(model))
|
| 19 |
-
except (RepositoryNotFoundError, RevisionNotFoundError)
|
| 20 |
-
st.error(f"Error fetching model info for {model}: {str(e)}")
|
| 21 |
-
return None
|
| 22 |
-
except Exception as e:
|
| 23 |
-
st.error(f"Unexpected error fetching model info for {model}: {str(e)}")
|
| 24 |
return None
|
| 25 |
|
| 26 |
@st.cache_data
|
| 27 |
def get_model_info(df):
|
| 28 |
"""Get model information and update the DataFrame with likes and tags."""
|
| 29 |
api = HfApi()
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
df.loc[index, 'Tags'] = ''
|
| 39 |
return df
|
| 40 |
|
| 41 |
def convert_markdown_table_to_dataframe(md_content):
|
|
@@ -99,23 +94,11 @@ def fetch_merge_configs(df):
|
|
| 99 |
except Exception as e:
|
| 100 |
st.error(f"Error while fetching merge configs: {str(e)}")
|
| 101 |
|
| 102 |
-
def authenticate_hf():
|
| 103 |
-
"""Authenticate with the Hugging Face API."""
|
| 104 |
-
token = st.text_input("Enter your Hugging Face API token", type="password")
|
| 105 |
-
if token:
|
| 106 |
-
login(token=token)
|
| 107 |
-
st.success("Authenticated successfully")
|
| 108 |
-
else:
|
| 109 |
-
st.warning("You need to enter a Hugging Face API token to access private or gated models")
|
| 110 |
-
|
| 111 |
def main():
|
| 112 |
"""Main function to set up the Streamlit app and display the leaderboard."""
|
| 113 |
st.set_page_config(page_title="YALL - Yet Another LLM Leaderboard", layout="wide")
|
| 114 |
st.title("π YALL - Yet Another LLM Leaderboard")
|
| 115 |
st.markdown("Leaderboard made with π§ [LLM AutoEval](https://github.com/mlabonne/llm-autoeval) using [Nous](https://huggingface.co/NousResearch) benchmark suite.")
|
| 116 |
-
|
| 117 |
-
authenticate_hf()
|
| 118 |
-
|
| 119 |
content = create_yall()
|
| 120 |
tab1, tab2 = st.tabs(["π Leaderboard", "π About"])
|
| 121 |
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
+
from huggingface_hub import HfApi, ModelCard
|
| 4 |
from huggingface_hub.utils import RepositoryNotFoundError, RevisionNotFoundError
|
| 5 |
import re
|
| 6 |
from io import StringIO
|
|
|
|
| 16 |
"""Fetch model information from the Hugging Face API and cache the result."""
|
| 17 |
try:
|
| 18 |
return _api.model_info(repo_id=str(model))
|
| 19 |
+
except (RepositoryNotFoundError, RevisionNotFoundError):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
return None
|
| 21 |
|
| 22 |
@st.cache_data
|
| 23 |
def get_model_info(df):
|
| 24 |
"""Get model information and update the DataFrame with likes and tags."""
|
| 25 |
api = HfApi()
|
| 26 |
+
for index, row in df.iterrows():
|
| 27 |
+
model_info = cached_model_info(api, row['Model'].strip())
|
| 28 |
+
if model_info:
|
| 29 |
+
df.loc[index, 'Likes'] = model_info.likes
|
| 30 |
+
df.loc[index, 'Tags'] = ', '.join(model_info.tags)
|
| 31 |
+
else:
|
| 32 |
+
df.loc[index, 'Likes'] = -1
|
| 33 |
+
df.loc[index, 'Tags'] = ''
|
|
|
|
| 34 |
return df
|
| 35 |
|
| 36 |
def convert_markdown_table_to_dataframe(md_content):
|
|
|
|
| 94 |
except Exception as e:
|
| 95 |
st.error(f"Error while fetching merge configs: {str(e)}")
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
def main():
|
| 98 |
"""Main function to set up the Streamlit app and display the leaderboard."""
|
| 99 |
st.set_page_config(page_title="YALL - Yet Another LLM Leaderboard", layout="wide")
|
| 100 |
st.title("π YALL - Yet Another LLM Leaderboard")
|
| 101 |
st.markdown("Leaderboard made with π§ [LLM AutoEval](https://github.com/mlabonne/llm-autoeval) using [Nous](https://huggingface.co/NousResearch) benchmark suite.")
|
|
|
|
|
|
|
|
|
|
| 102 |
content = create_yall()
|
| 103 |
tab1, tab2 = st.tabs(["π Leaderboard", "π About"])
|
| 104 |
|