Spaces:
Running
Running
File size: 11,828 Bytes
0aa9a49 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 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 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
"""
Constants and mappings for PazaBench.
This module contains all mapping dictionaries and configuration constants
that are shared across the application.
"""
from pathlib import Path
# =============================================================================
# File Paths
# =============================================================================
RESULTS_CSV_PATH = Path("results_summary.csv")
RESULTS_CSV_FILENAME = "results_summary.csv"
# =============================================================================
# Filter Configuration
# =============================================================================
FILTER_COLUMN_ORDER = ["model", "language", "dataset_group"]
FILTER_PARAM_MAP = {
"model": "models",
"language": "languages",
"dataset_group": "dataset_groups",
}
# =============================================================================
# Display Configuration
# =============================================================================
ASR_DISPLAY_COLUMNS = [
"model_family",
"model",
"dataset_group",
"split",
"language",
"region",
"cer",
"wer",
"rtfx",
"duration_sec",
"inference_time_sec",
"num_samples",
]
ASR_NUMERIC_COLUMNS = ["wer", "cer", "rtfx", "duration_sec", "inference_time_sec", "num_samples"]
ASR_TEXT_COLUMNS = ["model_family", "model", "dataset_group", "split", "language", "region"]
# =============================================================================
# Metric Configuration
# =============================================================================
METRIC_CONFIGS = {
"cer": {"label": "CER", "better": "lower", "fmt": "{:.2f}"},
"wer": {"label": "WER", "better": "lower", "fmt": "{:.2f}"},
"rtfx": {"label": "RTFx", "better": "higher", "fmt": "{:.2f}"},
}
VIEW_MODE_COLUMNS = {
"Model families": "model_family",
"Individual models": "model",
}
DEFAULT_VIEW_MODE = "Model families"
# =============================================================================
# Language Normalization
# =============================================================================
LANGUAGE_NAME_MAPPING = {
"Ganda": "Luganda",
"Luganda": "Luganda",
"Dholuo": "Dholuo",
}
# =============================================================================
# Geographic Mappings
# =============================================================================
# Language to country mapping for Africa map (using ISO 3166-1 alpha-3 codes)
LANGUAGE_COUNTRY_MAP = {
"Afrikaans": ["ZAF"],
"Amharic": ["ETH"],
"Arabic": ["EGY", "MAR", "DZA", "TUN", "LBY", "SDN"],
"Basaa": ["CMR"],
"Dholuo": ["KEN"],
"Dioula": ["BFA", "CIV"],
"Ekoti": ["MOZ"],
"Fula": ["SEN", "MLI", "NGA", "GIN", "CMR", "NER"],
"Luganda": ["UGA"],
"Hausa": ["NGA", "NER"],
"Igbo": ["NGA"],
"Kabyle": ["DZA"],
"Kalenjin": ["KEN"],
"Kamba": ["KEN"],
"Kidaw'ida": ["KEN"],
"Kikuyu": ["KEN"],
"Kinyarwanda": ["RWA"],
"Lingala": ["COD", "COG"],
"Maasai": ["KEN"],
"Northern Sotho": ["ZAF"],
"Nyanja": ["MWI", "ZMB"],
"Nyungwe": ["MOZ"],
"Oromo": ["ETH"],
"Sesotho": ["ZAF", "LSO"],
"Setswana": ["ZAF", "BWA"],
"Shona": ["ZWE"],
"Somali": ["KEN", "SOM"],
"Swahili": ["KEN", "TZA", "COD"],
"Tamazight": ["MAR", "DZA"],
"Tigre": ["ERI"],
"Tigrinya": ["ERI", "ETH"],
"Tshivenda": ["ZAF", "ZWE"],
"Twi": ["GHA"],
"Umbundu": ["AGO"],
"Wolof": ["SEN", "GMB"],
"Xhosa": ["ZAF"],
"Xitsonga": ["ZAF", "MOZ"],
"Yoruba": ["NGA", "BEN"],
"Zulu": ["ZAF"],
}
# Country code to name mapping
COUNTRY_NAMES = {
"ZAF": "South Africa", "ETH": "Ethiopia", "EGY": "Egypt", "MAR": "Morocco",
"DZA": "Algeria", "TUN": "Tunisia", "LBY": "Libya", "SDN": "Sudan",
"CMR": "Cameroon", "MOZ": "Mozambique", "KEN": "Kenya", "BFA": "Burkina Faso",
"CIV": "Côte d'Ivoire", "SEN": "Senegal", "MLI": "Mali", "NGA": "Nigeria",
"GIN": "Guinea", "NER": "Niger", "UGA": "Uganda", "RWA": "Rwanda",
"COD": "DR Congo", "COG": "Congo", "TZA": "Tanzania", "MWI": "Malawi",
"ZMB": "Zambia", "LSO": "Lesotho", "BWA": "Botswana", "ZWE": "Zimbabwe",
"SOM": "Somalia", "ERI": "Eritrea", "GHA": "Ghana", "AGO": "Angola",
"GMB": "Gambia", "BEN": "Benin",
}
# Language to countries mapping (full country names)
# Used for language metadata and region lookups
LANGUAGE_TO_COUNTRIES_MAP: dict[str, list[str]] = {
# East Africa
"Swahili": ["Kenya", "Tanzania", "Uganda", "DR Congo"],
"Dholuo": ["Kenya"],
"Dholuo (Luo)": ["Kenya"],
"Kalenjin": ["Kenya"],
"Kikuyu": ["Kenya"],
"Kamba": ["Kenya"],
"Maasai": ["Kenya", "Tanzania"],
"Kidaw'ida": ["Kenya", "Tanzania"],
"Luganda": ["Uganda"],
"Kinyarwanda": ["Rwanda"],
"Somali": ["Somalia", "Kenya", "Ethiopia"],
"Amharic": ["Ethiopia"],
"Tigrinya": ["Eritrea", "Ethiopia"],
"Tigre": ["Eritrea"],
"Oromo": ["Ethiopia"],
# Southern Africa
"Afrikaans": ["South Africa", "Namibia"],
"Zulu": ["South Africa"],
"Xhosa": ["South Africa"],
"Setswana": ["Botswana", "South Africa"],
"Sesotho": ["South Africa", "Lesotho"],
"Northern Sotho": ["South Africa"],
"Xitsonga": ["South Africa", "Mozambique"],
"Tshivenda": ["South Africa"],
"Shona": ["Zimbabwe"],
"Nyanja": ["Malawi", "Zambia"],
"Nyungwe": ["Mozambique"],
"Ekoti": ["Mozambique"],
# West Africa
"Yoruba": ["Nigeria"],
"Igbo": ["Nigeria"],
"Hausa": ["Nigeria", "Niger"],
"Wolof": ["Senegal", "Gambia"],
"Fula": ["Senegal", "Guinea", "Mali", "Nigeria"],
"Twi": ["Ghana"],
"Dioula": ["Burkina Faso", "Côte d'Ivoire", "Mali"],
"Basaa": ["Cameroon"],
# Central Africa
"Lingala": ["DR Congo", "Republic of Congo"],
"Umbundu": ["Angola"],
# North Africa
"Arabic": ["Egypt", "Libya", "Tunisia", "Algeria", "Morocco", "Sudan"],
"Kabyle": ["Algeria"],
"Tamazight": ["Morocco", "Algeria"],
}
# Country to African region mapping (geographical)
COUNTRY_TO_REGION_MAP: dict[str, str] = {
# East Africa
"Kenya": "East Africa",
"Tanzania": "East Africa",
"Uganda": "East Africa",
"Rwanda": "East Africa",
"Burundi": "East Africa",
"Ethiopia": "East Africa",
"Eritrea": "East Africa",
"Somalia": "East Africa",
"Djibouti": "East Africa",
# Southern Africa
"South Africa": "Southern Africa",
"Namibia": "Southern Africa",
"Botswana": "Southern Africa",
"Zimbabwe": "Southern Africa",
"Zambia": "Southern Africa",
"Malawi": "Southern Africa",
"Mozambique": "Southern Africa",
"Angola": "Southern Africa",
"Lesotho": "Southern Africa",
"Eswatini": "Southern Africa",
# West Africa
"Nigeria": "West Africa",
"Ghana": "West Africa",
"Senegal": "West Africa",
"Gambia": "West Africa",
"Guinea": "West Africa",
"Mali": "West Africa",
"Burkina Faso": "West Africa",
"Côte d'Ivoire": "West Africa",
"Niger": "West Africa",
"Cameroon": "West Africa",
# Central Africa
"DR Congo": "Central Africa",
"Republic of Congo": "Central Africa",
"Central African Republic": "Central Africa",
"Gabon": "Central Africa",
# North Africa
"Egypt": "North Africa",
"Libya": "North Africa",
"Tunisia": "North Africa",
"Algeria": "North Africa",
"Morocco": "North Africa",
"Sudan": "North Africa",
}
# =============================================================================
# Sample Counts
# =============================================================================
# Language sample count data from PazaBench (39 African languages)
# Note: These counts represent unique samples per language
# Total: 204,492 samples
LANGUAGE_SAMPLE_COUNTS = {
"Hausa": 22628,
"Yoruba": 20612,
"Igbo": 18582,
"Kabyle": 15003,
"Kinyarwanda": 14800,
"Swahili": 14422,
"Kikuyu": 12980,
"Luganda": 12598, # Combined Luganda (11875) and Ganda (723)
"Arabic": 10508,
"Kalenjin": 8881,
"Dholuo": 7111,
"Setswana": 5633,
"Somali": 5601,
"Xhosa": 4679,
"Xitsonga": 4394,
"Zulu": 3880,
"Sesotho": 3719,
"Maasai": 2903,
"Wolof": 2371,
"Tshivenda": 1652,
"Tigre": 1607,
"Basaa": 1550,
"Amharic": 1132,
"Kidaw'ida": 1004,
"Shona": 925,
"Kamba": 827,
"Northern Sotho": 790,
"Nyanja": 761,
"Fula": 660,
"Lingala": 478,
"Ekoti": 414,
"Afrikaans": 389,
"Umbundu": 379,
"Nyungwe": 248,
"Tamazight": 230,
"Dioula": 63,
"Oromo": 41,
"Twi": 21,
"Tigrinya": 16,
}
# =============================================================================
# Visualization Interpretation Text
# =============================================================================
INTERPRETATIONS = {
'speed_accuracy': """
- Each bubble represents a specific model; **bubble size = model parameter count**
- **X-axis (WER)**: Left is better (more accurate)
- **Y-axis (RTFx)**: Up is better (faster processing)
- **Top-left quadrant (⭐)**: Ideal zone - fast AND accurate models
- Gray dashed lines show median values for reference
- Uses median values to reduce impact of outliers
- Hover over bubbles to see exact parameter counts (e.g., 1.5B, 300M)
""",
'leaderboard': """
- **No language selected**: Shows model families (aggregated across all languages)
- **Language(s) selected**: Shows top 15 individual models for those languages
- The horizontal bars show the median Word Error Rate (WER)
- Lower WER values (left side) indicate better accuracy
- Error bars represent the standard deviation, showing variability
- Bar colors correspond to each model family's assigned color
- Hover over bars to see additional metrics like RTFx (speed) and total samples evaluated
- Uses median instead of mean to reduce impact of outliers
""",
'cer_leaderboard': """
- **No language selected**: Shows model families (aggregated across all languages)
- **Language(s) selected**: Shows top 15 individual models for those languages
- The horizontal bars show the median Character Error Rate (CER)
- Lower CER values (left side) indicate better accuracy
- CER is especially important for agglutinative and low-resource languages
- Error bars represent the standard deviation, showing variability
- Bar colors correspond to each model family's assigned color
- Hover over bars to see additional metrics like WER, RTFx (speed) and total samples evaluated
- Uses median instead of mean to reduce impact of outliers
""",
'correlation': """
- Each point represents one evaluation result
- Strong positive correlation means CER and WER move together
- Models with high character errors typically also have high word errors
- The trend line shows the overall relationship
- **Below the line**: Models make more accurate character-level predictions (phonetically closer errors)
- **Above the line**: Models make more severe character-level errors per word mistake
- Can be filtered by language to analyze specific language patterns
""",
'consistency': """
- Coefficient of Variation (CV) = (Standard Deviation / Median) × 100%
- **Lower CV** = more consistent performance across different languages
- **Higher CV** = performance varies widely depending on the language
- Bar colors correspond to each model family's assigned color
- Important for production deployment - you want consistent models
- Outliers have been removed using IQR method for more robust analysis
- Uses median instead of mean for more robust central tendency measure
"""
}
|