Commit
·
2736f1e
1
Parent(s):
7feaac0
longform
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ column_names = {
|
|
27 |
"Voxpopuli WER": "Voxpopuli",
|
28 |
}
|
29 |
|
30 |
-
eval_queue_repo, requested_models, csv_results, multilingual_csv_path = load_all_info_from_dataset_hub()
|
31 |
|
32 |
if not csv_results.exists():
|
33 |
raise Exception(f"CSV file {csv_results} does not exist locally")
|
@@ -230,32 +230,57 @@ def toggle_language_expansion(language_code):
|
|
230 |
multilingual_df = create_multilingual_dataframe()
|
231 |
|
232 |
def create_longform_dataframe():
|
233 |
-
"""Create longform dataframe
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
|
258 |
-
longform_df = pd.DataFrame(longform_data)
|
259 |
longform_df = longform_df.sort_values(by='Average WER ⬇️')
|
260 |
return longform_df
|
261 |
|
|
|
27 |
"Voxpopuli WER": "Voxpopuli",
|
28 |
}
|
29 |
|
30 |
+
eval_queue_repo, requested_models, csv_results, multilingual_csv_path, longform_csv_path = load_all_info_from_dataset_hub()
|
31 |
|
32 |
if not csv_results.exists():
|
33 |
raise Exception(f"CSV file {csv_results} does not exist locally")
|
|
|
230 |
multilingual_df = create_multilingual_dataframe()
|
231 |
|
232 |
def create_longform_dataframe():
|
233 |
+
"""Create longform dataframe from CSV data"""
|
234 |
+
if longform_csv_path is None or not longform_csv_path.exists():
|
235 |
+
print("Longform CSV not found, creating sample data")
|
236 |
+
# Fallback to sample data if CSV not available
|
237 |
+
longform_data = []
|
238 |
+
sample_models = [
|
239 |
+
{"model": "openai/whisper-large-v3", "earnings21": 8.2, "mustc": 12.4, "rtfx": 2.1},
|
240 |
+
{"model": "openai/whisper-large-v2", "earnings21": 9.1, "mustc": 13.8, "rtfx": 1.8},
|
241 |
+
{"model": "nvidia/canary-1b", "earnings21": 7.5, "mustc": 11.2, "rtfx": 3.2},
|
242 |
+
{"model": "microsoft/speecht5_asr", "earnings21": 15.3, "mustc": 18.7, "rtfx": 1.4},
|
243 |
+
]
|
244 |
+
|
245 |
+
for model_data in sample_models:
|
246 |
+
row = {
|
247 |
+
"Model": make_clickable_model(model_data["model"]),
|
248 |
+
"Average WER ⬇️": round((model_data["earnings21"] + model_data["mustc"]) / 2, 2),
|
249 |
+
"RTFx ⬆️️": model_data["rtfx"] if model_data["rtfx"] > 0 else "NA",
|
250 |
+
"Earnings21": model_data["earnings21"],
|
251 |
+
"MustC": model_data["mustc"]
|
252 |
+
}
|
253 |
+
longform_data.append(row)
|
254 |
+
|
255 |
+
longform_df = pd.DataFrame(longform_data)
|
256 |
+
else:
|
257 |
+
# Load from CSV
|
258 |
+
longform_raw_df = pd.read_csv(longform_csv_path)
|
259 |
+
longform_data = []
|
260 |
+
|
261 |
+
for _, row_data in longform_raw_df.iterrows():
|
262 |
+
model_name = row_data['model']
|
263 |
+
|
264 |
+
# Get values from CSV, similar to other tabs
|
265 |
+
earnings21_wer = row_data.get('earnings21_wer', -1)
|
266 |
+
mustc_wer = row_data.get('mustc_wer', -1)
|
267 |
+
rtfx_value = row_data.get('rtfx', 0)
|
268 |
+
|
269 |
+
# Calculate average WER from available datasets
|
270 |
+
available_wers = [w for w in [earnings21_wer, mustc_wer] if w != -1 and w > 0]
|
271 |
+
avg_wer = round(np.mean(available_wers), 2) if available_wers else 0.0
|
272 |
+
|
273 |
+
row = {
|
274 |
+
"Model": make_clickable_model(model_name),
|
275 |
+
"Average WER ⬇️": avg_wer,
|
276 |
+
"RTFx ⬆️️": rtfx_value if rtfx_value > 0 else "NA",
|
277 |
+
"Earnings21": earnings21_wer if earnings21_wer != -1 else "NA",
|
278 |
+
"MustC": mustc_wer if mustc_wer != -1 else "NA"
|
279 |
+
}
|
280 |
+
longform_data.append(row)
|
281 |
+
|
282 |
+
longform_df = pd.DataFrame(longform_data)
|
283 |
|
|
|
284 |
longform_df = longform_df.sort_values(by='Average WER ⬇️')
|
285 |
return longform_df
|
286 |
|
init.py
CHANGED
@@ -6,8 +6,10 @@ from huggingface_hub import HfApi, Repository
|
|
6 |
TOKEN_HUB = os.environ.get("TOKEN_HUB", None)
|
7 |
QUEUE_REPO = os.environ.get("QUEUE_REPO", None)
|
8 |
QUEUE_REPO_MULTI = os.environ.get("QUEUE_REPO_MULTI", None)
|
|
|
9 |
QUEUE_PATH = os.environ.get("QUEUE_PATH", None)
|
10 |
QUEUE_PATH_MULTI = os.environ.get("QUEUE_PATH_MULTI", None)
|
|
|
11 |
|
12 |
hf_api = HfApi(
|
13 |
endpoint="https://huggingface.co",
|
@@ -45,8 +47,11 @@ def load_all_info_from_dataset_hub():
|
|
45 |
|
46 |
# Load multilingual data in the same way
|
47 |
multilingual_csv_results = load_multilingual_data()
|
|
|
|
|
|
|
48 |
|
49 |
-
return eval_queue_repo, requested_models, csv_results, multilingual_csv_results
|
50 |
|
51 |
def load_multilingual_data():
|
52 |
"""Load multilingual evaluation data from CSV"""
|
@@ -81,6 +86,39 @@ def load_multilingual_data():
|
|
81 |
print(f"Error loading multilingual data: {e}")
|
82 |
return None
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
def upload_file(requested_model_name, path_or_fileobj):
|
86 |
dest_repo_file = Path(EVAL_REQUESTS_PATH) / path_or_fileobj.name
|
@@ -118,6 +156,18 @@ def get_multilingual_csv_with_results(directory):
|
|
118 |
return None
|
119 |
return multilingual_csv_files[0]
|
120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
|
123 |
def is_model_on_hub(model_name, revision="main") -> bool:
|
|
|
6 |
TOKEN_HUB = os.environ.get("TOKEN_HUB", None)
|
7 |
QUEUE_REPO = os.environ.get("QUEUE_REPO", None)
|
8 |
QUEUE_REPO_MULTI = os.environ.get("QUEUE_REPO_MULTI", None)
|
9 |
+
QUEUE_REPO_LONGFORM = os.environ.get("QUEUE_REPO_LONGFORM", None)
|
10 |
QUEUE_PATH = os.environ.get("QUEUE_PATH", None)
|
11 |
QUEUE_PATH_MULTI = os.environ.get("QUEUE_PATH_MULTI", None)
|
12 |
+
QUEUE_PATH_LONGFORM = os.environ.get("QUEUE_PATH_LONGFORM", None)
|
13 |
|
14 |
hf_api = HfApi(
|
15 |
endpoint="https://huggingface.co",
|
|
|
47 |
|
48 |
# Load multilingual data in the same way
|
49 |
multilingual_csv_results = load_multilingual_data()
|
50 |
+
|
51 |
+
# Load longform data in the same way
|
52 |
+
longform_csv_results = load_longform_data()
|
53 |
|
54 |
+
return eval_queue_repo, requested_models, csv_results, multilingual_csv_results, longform_csv_results
|
55 |
|
56 |
def load_multilingual_data():
|
57 |
"""Load multilingual evaluation data from CSV"""
|
|
|
86 |
print(f"Error loading multilingual data: {e}")
|
87 |
return None
|
88 |
|
89 |
+
def load_longform_data():
|
90 |
+
"""Load longform evaluation data from CSV"""
|
91 |
+
longform_queue_path = QUEUE_PATH_LONGFORM
|
92 |
+
|
93 |
+
try:
|
94 |
+
# Try to get from dedicated longform HF repo first
|
95 |
+
if TOKEN_HUB is not None:
|
96 |
+
print("Pulling longform evaluation data.")
|
97 |
+
try:
|
98 |
+
longform_repo = Repository(
|
99 |
+
local_dir=longform_queue_path,
|
100 |
+
clone_from=QUEUE_REPO_LONGFORM,
|
101 |
+
use_auth_token=TOKEN_HUB,
|
102 |
+
repo_type="dataset",
|
103 |
+
)
|
104 |
+
longform_repo.git_pull()
|
105 |
+
longform_csv = get_longform_csv_with_results(longform_queue_path)
|
106 |
+
except Exception as e:
|
107 |
+
print(f"Failed to pull from longform repo: {e}")
|
108 |
+
longform_csv = None
|
109 |
+
else:
|
110 |
+
longform_csv = None
|
111 |
+
|
112 |
+
# Fallback to local file
|
113 |
+
if longform_csv is None:
|
114 |
+
print("Using local longform CSV file.")
|
115 |
+
longform_csv = get_longform_csv_with_results(".")
|
116 |
+
|
117 |
+
return longform_csv
|
118 |
+
except Exception as e:
|
119 |
+
print(f"Error loading longform data: {e}")
|
120 |
+
return None
|
121 |
+
|
122 |
|
123 |
def upload_file(requested_model_name, path_or_fileobj):
|
124 |
dest_repo_file = Path(EVAL_REQUESTS_PATH) / path_or_fileobj.name
|
|
|
156 |
return None
|
157 |
return multilingual_csv_files[0]
|
158 |
|
159 |
+
def get_longform_csv_with_results(directory):
|
160 |
+
"""Get longform CSV results file"""
|
161 |
+
directory = Path(directory)
|
162 |
+
longform_csv_files = list(directory.glob("longform_results_latest.csv"))
|
163 |
+
if len(longform_csv_files) != 1:
|
164 |
+
# Try local directory as fallback
|
165 |
+
local_longform = Path("longform_results_latest.csv")
|
166 |
+
if local_longform.exists():
|
167 |
+
return local_longform
|
168 |
+
return None
|
169 |
+
return longform_csv_files[0]
|
170 |
+
|
171 |
|
172 |
|
173 |
def is_model_on_hub(model_name, revision="main") -> bool:
|