Upload 6 files
Browse files- README.md +8 -6
- app.py +148 -0
- constants.py +115 -0
- init.py +129 -0
- requirements.txt +61 -0
- utils_display.py +39 -0
README.md
CHANGED
@@ -1,12 +1,14 @@
|
|
1 |
---
|
2 |
-
title: Open
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.
|
8 |
app_file: app.py
|
9 |
-
pinned:
|
|
|
|
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: Open ASR Leaderboard
|
3 |
+
emoji: 🏆
|
4 |
+
colorFrom: red
|
5 |
+
colorTo: blue
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.41.0
|
8 |
app_file: app.py
|
9 |
+
pinned: true
|
10 |
+
tags:
|
11 |
+
- leaderboard
|
12 |
---
|
13 |
|
14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
import json
|
4 |
+
from constants import BANNER, INTRODUCTION_TEXT, CITATION_TEXT, METRICS_TAB_TEXT, DIR_OUTPUT_REQUESTS
|
5 |
+
from init import is_model_on_hub, upload_file, load_all_info_from_dataset_hub
|
6 |
+
from utils_display import AutoEvalColumn, fields, make_clickable_model, styled_error, styled_message
|
7 |
+
from datetime import datetime, timezone
|
8 |
+
|
9 |
+
LAST_UPDATED = "OCT 2nd 2024"
|
10 |
+
|
11 |
+
column_names = {
|
12 |
+
"MODEL": "Model",
|
13 |
+
"Avg. WER": "Average WER ⬇️",
|
14 |
+
"Avg. RTFx": "RTFx ⬆️️",
|
15 |
+
"AMI WER": "AMI",
|
16 |
+
"Earnings22 WER": "Earnings22",
|
17 |
+
"Gigaspeech WER": "Gigaspeech",
|
18 |
+
"LS Clean WER": "LS Clean",
|
19 |
+
"LS Other WER": "LS Other",
|
20 |
+
"SPGISpeech WER": "SPGISpeech",
|
21 |
+
"Tedlium WER": "Tedlium",
|
22 |
+
"Voxpopuli WER": "Voxpopuli",
|
23 |
+
}
|
24 |
+
|
25 |
+
eval_queue_repo, requested_models, csv_results = load_all_info_from_dataset_hub()
|
26 |
+
|
27 |
+
if not csv_results.exists():
|
28 |
+
raise Exception(f"CSV file {csv_results} does not exist locally")
|
29 |
+
|
30 |
+
# Get csv with data and parse columns
|
31 |
+
original_df = pd.read_csv(csv_results)
|
32 |
+
|
33 |
+
# Formats the columns
|
34 |
+
def formatter(x):
|
35 |
+
if type(x) is str:
|
36 |
+
x = x
|
37 |
+
else:
|
38 |
+
x = round(x, 2)
|
39 |
+
return x
|
40 |
+
|
41 |
+
for col in original_df.columns:
|
42 |
+
if col == "model":
|
43 |
+
original_df[col] = original_df[col].apply(lambda x: x.replace(x, make_clickable_model(x)))
|
44 |
+
else:
|
45 |
+
original_df[col] = original_df[col].apply(formatter) # For numerical values
|
46 |
+
|
47 |
+
original_df.rename(columns=column_names, inplace=True)
|
48 |
+
original_df.sort_values(by='Average WER ⬇️', inplace=True)
|
49 |
+
|
50 |
+
COLS = [c.name for c in fields(AutoEvalColumn)]
|
51 |
+
TYPES = [c.type for c in fields(AutoEvalColumn)]
|
52 |
+
|
53 |
+
|
54 |
+
def request_model(model_text, chbcoco2017):
|
55 |
+
|
56 |
+
# Determine the selected checkboxes
|
57 |
+
dataset_selection = []
|
58 |
+
if chbcoco2017:
|
59 |
+
dataset_selection.append("ESB Datasets tests only")
|
60 |
+
|
61 |
+
if len(dataset_selection) == 0:
|
62 |
+
return styled_error("You need to select at least one dataset")
|
63 |
+
|
64 |
+
base_model_on_hub, error_msg = is_model_on_hub(model_text)
|
65 |
+
|
66 |
+
if not base_model_on_hub:
|
67 |
+
return styled_error(f"Base model '{model_text}' {error_msg}")
|
68 |
+
|
69 |
+
# Construct the output dictionary
|
70 |
+
current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
71 |
+
required_datasets = ', '.join(dataset_selection)
|
72 |
+
eval_entry = {
|
73 |
+
"date": current_time,
|
74 |
+
"model": model_text,
|
75 |
+
"datasets_selected": required_datasets
|
76 |
+
}
|
77 |
+
|
78 |
+
# Prepare file path
|
79 |
+
DIR_OUTPUT_REQUESTS.mkdir(parents=True, exist_ok=True)
|
80 |
+
|
81 |
+
fn_datasets = '@ '.join(dataset_selection)
|
82 |
+
filename = model_text.replace("/","@") + "@@" + fn_datasets
|
83 |
+
if filename in requested_models:
|
84 |
+
return styled_error(f"A request for this model '{model_text}' and dataset(s) was already made.")
|
85 |
+
try:
|
86 |
+
filename_ext = filename + ".txt"
|
87 |
+
out_filepath = DIR_OUTPUT_REQUESTS / filename_ext
|
88 |
+
|
89 |
+
# Write the results to a text file
|
90 |
+
with open(out_filepath, "w") as f:
|
91 |
+
f.write(json.dumps(eval_entry))
|
92 |
+
|
93 |
+
upload_file(filename, out_filepath)
|
94 |
+
|
95 |
+
# Include file in the list of uploaded files
|
96 |
+
requested_models.append(filename)
|
97 |
+
|
98 |
+
# Remove the local file
|
99 |
+
out_filepath.unlink()
|
100 |
+
|
101 |
+
return styled_message("🤗 Your request has been submitted and will be evaluated soon!</p>")
|
102 |
+
except Exception as e:
|
103 |
+
return styled_error(f"Error submitting request!")
|
104 |
+
|
105 |
+
with gr.Blocks() as demo:
|
106 |
+
gr.HTML(BANNER, elem_id="banner")
|
107 |
+
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
108 |
+
|
109 |
+
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
110 |
+
with gr.TabItem("🏅 Leaderboard", elem_id="od-benchmark-tab-table", id=0):
|
111 |
+
leaderboard_table = gr.components.Dataframe(
|
112 |
+
value=original_df,
|
113 |
+
datatype=TYPES,
|
114 |
+
elem_id="leaderboard-table",
|
115 |
+
interactive=False,
|
116 |
+
visible=True,
|
117 |
+
)
|
118 |
+
|
119 |
+
with gr.TabItem("📈 Metrics", elem_id="od-benchmark-tab-table", id=1):
|
120 |
+
gr.Markdown(METRICS_TAB_TEXT, elem_classes="markdown-text")
|
121 |
+
|
122 |
+
with gr.TabItem("✉️✨ Request a model here!", elem_id="od-benchmark-tab-table", id=2):
|
123 |
+
with gr.Column():
|
124 |
+
gr.Markdown("# ✉️✨ Request results for a new model here!", elem_classes="markdown-text")
|
125 |
+
with gr.Column():
|
126 |
+
gr.Markdown("Select a dataset:", elem_classes="markdown-text")
|
127 |
+
with gr.Column():
|
128 |
+
model_name_textbox = gr.Textbox(label="Model name (user_name/model_name)")
|
129 |
+
chb_coco2017 = gr.Checkbox(label="COCO validation 2017 dataset", visible=False, value=True, interactive=False)
|
130 |
+
with gr.Column():
|
131 |
+
mdw_submission_result = gr.Markdown()
|
132 |
+
btn_submitt = gr.Button(value="🚀 Request")
|
133 |
+
btn_submitt.click(request_model,
|
134 |
+
[model_name_textbox, chb_coco2017],
|
135 |
+
mdw_submission_result)
|
136 |
+
|
137 |
+
gr.Markdown(f"Last updated on **{LAST_UPDATED}**", elem_classes="markdown-text")
|
138 |
+
|
139 |
+
with gr.Row():
|
140 |
+
with gr.Accordion("📙 Citation", open=False):
|
141 |
+
gr.Textbox(
|
142 |
+
value=CITATION_TEXT, lines=7,
|
143 |
+
label="Copy the BibTeX snippet to cite this source",
|
144 |
+
elem_id="citation-button",
|
145 |
+
show_copy_button=True,
|
146 |
+
)
|
147 |
+
|
148 |
+
demo.launch()
|
constants.py
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pathlib import Path
|
2 |
+
|
3 |
+
# Directory where request by models are stored
|
4 |
+
DIR_OUTPUT_REQUESTS = Path("requested_models")
|
5 |
+
EVAL_REQUESTS_PATH = Path("eval_requests")
|
6 |
+
|
7 |
+
##########################
|
8 |
+
# Text definitions #
|
9 |
+
##########################
|
10 |
+
|
11 |
+
banner_url = "https://huggingface.co/datasets/reach-vb/random-images/resolve/main/asr_leaderboard.png"
|
12 |
+
BANNER = f'<div style="display: flex; justify-content: space-around;"><img src="{banner_url}" alt="Banner" style="width: 40vw; min-width: 300px; max-width: 600px;"> </div>'
|
13 |
+
|
14 |
+
TITLE = "<html> <head> <style> h1 {text-align: center;} </style> </head> <body> <h1> 🤗 Open Automatic Speech Recognition Leaderboard </b> </body> </html>"
|
15 |
+
|
16 |
+
INTRODUCTION_TEXT = "📐 The 🤗 Open ASR Leaderboard ranks and evaluates speech recognition models \
|
17 |
+
on the Hugging Face Hub. \
|
18 |
+
\nWe report the Average [WER](https://huggingface.co/spaces/evaluate-metric/wer) (⬇️ lower the better) and [RTFx](https://github.com/NVIDIA/DeepLearningExamples/blob/master/Kaldi/SpeechRecognition/README.md#metrics) (⬆️ higher the better). Models are ranked based on their Average WER, from lowest to highest. Check the 📈 Metrics tab to understand how the models are evaluated. \
|
19 |
+
\nIf you want results for a model that is not listed here, you can submit a request for it to be included ✉️✨. \
|
20 |
+
\nThe leaderboard currently focuses on English speech recognition, and will be expanded to multilingual evaluation in later versions."
|
21 |
+
|
22 |
+
CITATION_TEXT = """@misc{open-asr-leaderboard,
|
23 |
+
title = {Open Automatic Speech Recognition Leaderboard},
|
24 |
+
author = {Srivastav, Vaibhav and Majumdar, Somshubra and Koluguri, Nithin and Moumen, Adel and Gandhi, Sanchit and others},
|
25 |
+
year = 2023,
|
26 |
+
publisher = {Hugging Face},
|
27 |
+
howpublished = "\\url{https://huggingface.co/spaces/hf-audio/open_asr_leaderboard}"
|
28 |
+
}
|
29 |
+
"""
|
30 |
+
|
31 |
+
METRICS_TAB_TEXT = """
|
32 |
+
Here you will find details about the speech recognition metrics and datasets reported in our leaderboard.
|
33 |
+
|
34 |
+
## Metrics
|
35 |
+
|
36 |
+
Models are evaluated jointly using the Word Error Rate (WER) and Inverse Real Time Factor (RTFx) metrics. The WER metric
|
37 |
+
is used to assess the accuracy of a system, and the RTFx the inference speed. Models are ranked in the leaderboard based
|
38 |
+
on their WER, lowest to highest.
|
39 |
+
|
40 |
+
Crucially, the WER and RTFx values are computed for the same inference run using a single script. The implication of this is two-fold:
|
41 |
+
1. The WER and RTFx values are coupled: for a given WER, one can expect to achieve the corresponding RTFx. This allows the proposer to trade-off lower WER for higher RTFx should they wish.
|
42 |
+
2. The WER and RTFx values are averaged over all audios in the benchmark (in the order of thousands of audios).
|
43 |
+
|
44 |
+
For details on reproducing the benchmark numbers, refer to the [Open ASR GitHub repository](https://github.com/huggingface/open_asr_leaderboard#evaluate-a-model).
|
45 |
+
|
46 |
+
### Word Error Rate (WER)
|
47 |
+
|
48 |
+
Word Error Rate is used to measure the **accuracy** of automatic speech recognition systems. It calculates the percentage
|
49 |
+
of words in the system's output that differ from the reference (correct) transcript. **A lower WER value indicates higher accuracy**.
|
50 |
+
|
51 |
+
Take the following example:
|
52 |
+
|
53 |
+
| Reference: | the | cat | sat | on | the | mat |
|
54 |
+
|-------------|-----|-----|---------|-----|-----|-----|
|
55 |
+
| Prediction: | the | cat | **sit** | on | the | | |
|
56 |
+
| Label: | ✅ | ✅ | S | ✅ | ✅ | D |
|
57 |
+
|
58 |
+
Here, we have:
|
59 |
+
* 1 substitution ("sit" instead of "sat")
|
60 |
+
* 0 insertions
|
61 |
+
* 1 deletion ("mat" is missing)
|
62 |
+
|
63 |
+
This gives 2 errors in total. To get our word error rate, we divide the total number of errors (substitutions + insertions + deletions) by the total number of words in our
|
64 |
+
reference (N), which for this example is 6:
|
65 |
+
|
66 |
+
```
|
67 |
+
WER = (S + I + D) / N = (1 + 0 + 1) / 6 = 0.333
|
68 |
+
```
|
69 |
+
|
70 |
+
Giving a WER of 0.33, or 33%. For a fair comparison, we calculate **zero-shot** (i.e. pre-trained models only) *normalised WER* for all the model checkpoints, meaning punctuation and casing is removed from the references and predictions. You can find the evaluation code on our [Github repository](https://github.com/huggingface/open_asr_leaderboard). To read more about how the WER is computed, refer to the [Audio Transformers Course](https://huggingface.co/learn/audio-course/chapter5/evaluation).
|
71 |
+
|
72 |
+
### Inverse Real Time Factor (RTFx)
|
73 |
+
|
74 |
+
Inverse Real Time Factor is a measure of the **latency** of automatic speech recognition systems, i.e. how long it takes an
|
75 |
+
model to process a given amount of speech. It is defined as:
|
76 |
+
```
|
77 |
+
RTFx = (number of seconds of audio inferred) / (compute time in seconds)
|
78 |
+
```
|
79 |
+
|
80 |
+
Therefore, and RTFx of 1 means a system processes speech as fast as it's spoken, while an RTFx of 2 means it takes half the time.
|
81 |
+
Thus, **a higher RTFx value indicates lower latency**.
|
82 |
+
|
83 |
+
## How to reproduce our results
|
84 |
+
|
85 |
+
The ASR Leaderboard will be a continued effort to benchmark open source/access speech recognition models where possible.
|
86 |
+
Along with the Leaderboard we're open-sourcing the codebase used for running these evaluations.
|
87 |
+
For more details head over to our repo at: https://github.com/huggingface/open_asr_leaderboard
|
88 |
+
|
89 |
+
P.S. We'd love to know which other models you'd like us to benchmark next. Contributions are more than welcome! ♥️
|
90 |
+
|
91 |
+
## Benchmark datasets
|
92 |
+
|
93 |
+
Evaluating Speech Recognition systems is a hard problem. We use the multi-dataset benchmarking strategy proposed in the
|
94 |
+
[ESB paper](https://arxiv.org/abs/2210.13352) to obtain robust evaluation scores for each model.
|
95 |
+
|
96 |
+
ESB is a benchmark for evaluating the performance of a single automatic speech recognition (ASR) system across a broad
|
97 |
+
set of speech datasets. It comprises eight English speech recognition datasets, capturing a broad range of domains,
|
98 |
+
acoustic conditions, speaker styles, and transcription requirements. As such, it gives a better indication of how
|
99 |
+
a model is likely to perform on downstream ASR compared to evaluating it on one dataset alone.
|
100 |
+
|
101 |
+
The ESB score is calculated as a macro-average of the WER scores across the ESB datasets. The models in the leaderboard
|
102 |
+
are ranked based on their average WER scores, from lowest to highest.
|
103 |
+
|
104 |
+
| Dataset | Domain | Speaking Style | Train (h) | Dev (h) | Test (h) | Transcriptions | License |
|
105 |
+
|-----------------------------------------------------------------------------------------|-----------------------------|-----------------------|-----------|---------|----------|--------------------|-----------------|
|
106 |
+
| [LibriSpeech](https://huggingface.co/datasets/librispeech_asr) | Audiobook | Narrated | 960 | 11 | 11 | Normalised | CC-BY-4.0 |
|
107 |
+
| [VoxPopuli](https://huggingface.co/datasets/facebook/voxpopuli) | European Parliament | Oratory | 523 | 5 | 5 | Punctuated | CC0 |
|
108 |
+
| [TED-LIUM](https://huggingface.co/datasets/LIUM/tedlium) | TED talks | Oratory | 454 | 2 | 3 | Normalised | CC-BY-NC-ND 3.0 |
|
109 |
+
| [GigaSpeech](https://huggingface.co/datasets/speechcolab/gigaspeech) | Audiobook, podcast, YouTube | Narrated, spontaneous | 2500 | 12 | 40 | Punctuated | apache-2.0 |
|
110 |
+
| [SPGISpeech](https://huggingface.co/datasets/kensho/spgispeech) | Financial meetings | Oratory, spontaneous | 4900 | 100 | 100 | Punctuated & Cased | User Agreement |
|
111 |
+
| [Earnings-22](https://huggingface.co/datasets/revdotcom/earnings22) | Financial meetings | Oratory, spontaneous | 105 | 5 | 5 | Punctuated & Cased | CC-BY-SA-4.0 |
|
112 |
+
| [AMI](https://huggingface.co/datasets/edinburghcstr/ami) | Meetings | Spontaneous | 78 | 9 | 9 | Punctuated & Cased | CC-BY-4.0 |
|
113 |
+
|
114 |
+
For more details on the individual datasets and how models are evaluated to give the ESB score, refer to the [ESB paper](https://arxiv.org/abs/2210.13352).
|
115 |
+
"""
|
init.py
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from constants import EVAL_REQUESTS_PATH
|
3 |
+
from pathlib import Path
|
4 |
+
from huggingface_hub import HfApi, Repository
|
5 |
+
|
6 |
+
TOKEN_HUB = os.environ.get("TOKEN_HUB", None)
|
7 |
+
QUEUE_REPO = os.environ.get("QUEUE_REPO", None)
|
8 |
+
QUEUE_PATH = os.environ.get("QUEUE_PATH", None)
|
9 |
+
|
10 |
+
hf_api = HfApi(
|
11 |
+
endpoint="https://huggingface.co",
|
12 |
+
token=TOKEN_HUB,
|
13 |
+
)
|
14 |
+
|
15 |
+
# Language code for Persian
|
16 |
+
PERSIAN_LANGUAGE_CODE = "fa"
|
17 |
+
|
18 |
+
def load_all_info_from_dataset_hub():
|
19 |
+
eval_queue_repo = None
|
20 |
+
requested_models = None
|
21 |
+
|
22 |
+
passed = True
|
23 |
+
if TOKEN_HUB is None:
|
24 |
+
passed = False
|
25 |
+
else:
|
26 |
+
print("Pulling evaluation requests and results.")
|
27 |
+
|
28 |
+
eval_queue_repo = Repository(
|
29 |
+
local_dir=QUEUE_PATH,
|
30 |
+
clone_from=QUEUE_REPO,
|
31 |
+
use_auth_token=TOKEN_HUB,
|
32 |
+
repo_type="dataset",
|
33 |
+
)
|
34 |
+
eval_queue_repo.git_pull()
|
35 |
+
|
36 |
+
# Local directory where dataset repo is cloned + folder with eval requests
|
37 |
+
directory = QUEUE_PATH / EVAL_REQUESTS_PATH
|
38 |
+
requested_models = get_all_requested_models(directory)
|
39 |
+
requested_models = [p.stem for p in requested_models]
|
40 |
+
|
41 |
+
# Filter models to only include those supporting Persian language
|
42 |
+
requested_models = filter_persian_models(requested_models)
|
43 |
+
|
44 |
+
# Local directory where dataset repo is cloned
|
45 |
+
csv_results = get_csv_with_results(QUEUE_PATH)
|
46 |
+
if csv_results is None:
|
47 |
+
passed = False
|
48 |
+
if not passed:
|
49 |
+
raise ValueError("No Hugging Face token provided. Skipping evaluation requests and results.")
|
50 |
+
|
51 |
+
return eval_queue_repo, requested_models, csv_results
|
52 |
+
|
53 |
+
|
54 |
+
def upload_file(requested_model_name, path_or_fileobj):
|
55 |
+
dest_repo_file = Path(EVAL_REQUESTS_PATH) / path_or_fileobj.name
|
56 |
+
dest_repo_file = str(dest_repo_file)
|
57 |
+
hf_api.upload_file(
|
58 |
+
path_or_fileobj=path_or_fileobj,
|
59 |
+
path_in_repo=str(dest_repo_file),
|
60 |
+
repo_id=QUEUE_REPO,
|
61 |
+
token=TOKEN_HUB,
|
62 |
+
repo_type="dataset",
|
63 |
+
commit_message=f"Add {requested_model_name} to eval queue")
|
64 |
+
|
65 |
+
|
66 |
+
def get_all_requested_models(directory):
|
67 |
+
directory = Path(directory)
|
68 |
+
all_requested_models = list(directory.glob("*.txt"))
|
69 |
+
return all_requested_models
|
70 |
+
|
71 |
+
|
72 |
+
def get_csv_with_results(directory):
|
73 |
+
directory = Path(directory)
|
74 |
+
all_csv_files = list(directory.glob("*.csv"))
|
75 |
+
latest = [f for f in all_csv_files if f.stem.endswith("latest")]
|
76 |
+
if len(latest) != 1:
|
77 |
+
return None
|
78 |
+
return latest[0]
|
79 |
+
|
80 |
+
|
81 |
+
def is_model_on_hub(model_name, revision="main") -> bool:
|
82 |
+
try:
|
83 |
+
model_name = model_name.replace(" ","")
|
84 |
+
author = model_name.split("/")[0]
|
85 |
+
model_id = model_name.split("/")[1]
|
86 |
+
if len(author) == 0 or len(model_id) == 0:
|
87 |
+
return False, "is not a valid model name. Please use the format `author/model_name`."
|
88 |
+
except Exception as e:
|
89 |
+
return False, "is not a valid model name. Please use the format `author/model_name`."
|
90 |
+
|
91 |
+
try:
|
92 |
+
models = list(hf_api.list_models(author=author, search=model_id))
|
93 |
+
matched = [model_name for m in models if m.modelId == model_name]
|
94 |
+
if len(matched) != 1:
|
95 |
+
return False, "was not found on the hub!"
|
96 |
+
else:
|
97 |
+
return True, None
|
98 |
+
except Exception as e:
|
99 |
+
print(f"Could not get the model from the hub.: {e}")
|
100 |
+
return False, "was not found on hub!"
|
101 |
+
|
102 |
+
|
103 |
+
def filter_persian_models(model_list):
|
104 |
+
"""
|
105 |
+
Filters the provided list of models to include only those that support Persian (fa).
|
106 |
+
|
107 |
+
Args:
|
108 |
+
model_list (list): List of model names to filter.
|
109 |
+
|
110 |
+
Returns:
|
111 |
+
list: List of models that support Persian.
|
112 |
+
"""
|
113 |
+
persian_models = []
|
114 |
+
for model_name in model_list:
|
115 |
+
try:
|
116 |
+
# Get model information from Hugging Face Hub
|
117 |
+
model_info = hf_api.model_info(model_name)
|
118 |
+
languages = model_info.cardData.get("languages", [])
|
119 |
+
|
120 |
+
# Check if Persian ('fa') is listed in the model's languages
|
121 |
+
if PERSIAN_LANGUAGE_CODE in languages:
|
122 |
+
persian_models.append(model_name)
|
123 |
+
print(f"{model_name} supports Persian language.")
|
124 |
+
else:
|
125 |
+
print(f"{model_name} does not support Persian language. Skipping.")
|
126 |
+
except Exception as e:
|
127 |
+
print(f"Error fetching model info for {model_name}: {str(e)}")
|
128 |
+
|
129 |
+
return persian_models
|
requirements.txt
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
aiohttp==3.8.4
|
2 |
+
aiosignal==1.3.1
|
3 |
+
async-timeout==4.0.2
|
4 |
+
attrs==23.1.0
|
5 |
+
certifi==2023.7.22
|
6 |
+
charset-normalizer==3.2.0
|
7 |
+
cmake==3.26.4
|
8 |
+
contourpy==1.1.0
|
9 |
+
Cython==3.0.0
|
10 |
+
datasets==2.13.1
|
11 |
+
dill==0.3.6
|
12 |
+
filelock==3.12.2
|
13 |
+
fonttools==4.40.0
|
14 |
+
frozenlist==1.4.0
|
15 |
+
fsspec==2023.6.0
|
16 |
+
huggingface-hub==0.16.4
|
17 |
+
idna==3.4
|
18 |
+
Jinja2==3.1.2
|
19 |
+
kiwisolver==1.4.4
|
20 |
+
lit==16.0.6
|
21 |
+
MarkupSafe==2.1.3
|
22 |
+
matplotlib==3.7.2
|
23 |
+
mpmath==1.3.0
|
24 |
+
multidict==6.0.4
|
25 |
+
multiprocess==0.70.14
|
26 |
+
networkx==3.1
|
27 |
+
numpy==1.25.2
|
28 |
+
nvidia-cublas-cu11==11.10.3.66
|
29 |
+
nvidia-cuda-cupti-cu11==11.7.101
|
30 |
+
nvidia-cuda-nvrtc-cu11==11.7.99
|
31 |
+
nvidia-cuda-runtime-cu11==11.7.99
|
32 |
+
nvidia-cudnn-cu11==8.5.0.96
|
33 |
+
nvidia-cufft-cu11==10.9.0.58
|
34 |
+
nvidia-curand-cu11==10.2.10.91
|
35 |
+
nvidia-cusolver-cu11==11.4.0.1
|
36 |
+
nvidia-cusparse-cu11==11.7.4.91
|
37 |
+
nvidia-nccl-cu11==2.14.3
|
38 |
+
nvidia-nvtx-cu11==11.7.91
|
39 |
+
packaging==23.1
|
40 |
+
pandas==2.0.3
|
41 |
+
Pillow==10.0.0
|
42 |
+
pyarrow==12.0.1
|
43 |
+
python-dateutil==2.8.2
|
44 |
+
pytz==2023.3
|
45 |
+
PyYAML==6.0.1
|
46 |
+
regex==2023.6.3
|
47 |
+
requests==2.31.0
|
48 |
+
responses==0.18.0
|
49 |
+
safetensors==0.3.1
|
50 |
+
six==1.16.0
|
51 |
+
sympy==1.12
|
52 |
+
tokenizers==0.13.3
|
53 |
+
torch==2.0.1
|
54 |
+
torchvision==0.15.2
|
55 |
+
tqdm==4.65.0
|
56 |
+
triton==2.0.0
|
57 |
+
typing_extensions==4.7.1
|
58 |
+
tzdata==2023.3
|
59 |
+
urllib3==2.0.4
|
60 |
+
xxhash==3.2.0
|
61 |
+
yarl==1.9.2
|
utils_display.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from dataclasses import dataclass
|
2 |
+
|
3 |
+
# These classes are for user facing column names, to avoid having to change them
|
4 |
+
# all around the code when a modif is needed
|
5 |
+
@dataclass
|
6 |
+
class ColumnContent:
|
7 |
+
name: str
|
8 |
+
type: str
|
9 |
+
|
10 |
+
def fields(raw_class):
|
11 |
+
return [v for k, v in raw_class.__dict__.items() if k[:2] != "__" and k[-2:] != "__"]
|
12 |
+
|
13 |
+
@dataclass(frozen=True)
|
14 |
+
class AutoEvalColumn: # Auto evals column
|
15 |
+
model = ColumnContent("Model", "markdown")
|
16 |
+
avg_wer = ColumnContent("Average WER ⬇️", "number")
|
17 |
+
rtf = ColumnContent("RTFx ⬆️️", "number")
|
18 |
+
ami_wer = ColumnContent("AMI", "number")
|
19 |
+
e22_wer = ColumnContent("Earnings22", "number")
|
20 |
+
gs_wer = ColumnContent("Gigaspeech", "number")
|
21 |
+
lsc_wer = ColumnContent("LS Clean", "number")
|
22 |
+
lso_wer = ColumnContent("LS Other", "number")
|
23 |
+
ss_wer = ColumnContent("SPGISpeech", "number")
|
24 |
+
tl_wer = ColumnContent("Tedlium", "number")
|
25 |
+
vp_wer = ColumnContent("Voxpopuli", "number")
|
26 |
+
|
27 |
+
|
28 |
+
def make_clickable_model(model_name):
|
29 |
+
link = f"https://huggingface.co/{model_name}"
|
30 |
+
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
|
31 |
+
|
32 |
+
def styled_error(error):
|
33 |
+
return f"<p style='color: red; font-size: 20px; text-align: center;'>{error}</p>"
|
34 |
+
|
35 |
+
def styled_warning(warn):
|
36 |
+
return f"<p style='color: orange; font-size: 20px; text-align: center;'>{warn}</p>"
|
37 |
+
|
38 |
+
def styled_message(message):
|
39 |
+
return f"<p style='color: green; font-size: 20px; text-align: center;'>{message}</p>"
|