Datasets:
Download scripts/ds_sound.py from Lilambd/empire-eval: direct link, hf CLI and curl.
- Browser
- Download file 11.1 kB
-
https://huggingface.co/datasets/Lilambd/empire-eval/resolve/main/scripts/ds_sound.py
- Command line
-
hf download hf://datasets/Lilambd/empire-eval/scripts/ds_sound.py
-
curl -L -o ds_sound.py https://huggingface.co/datasets/Lilambd/empire-eval/resolve/main/scripts/ds_sound.py
11.1 kB
| DS = 'Lilambd/world-sound' | |
| REVISION = 'build 2026-11-02 (upload pending)' | |
| LICENSE = 'CC BY 4.0 (tables CC BY 4.0 / CC0; Scala tunings credited to the Scala archive)' | |
| SH = 'World Sound dataset' | |
| P = 'data/' | |
| STR = {P + 'songs_cantometrics.parquet': ['song_id', 'society_id'], P + 'instruments_by_society.parquet': ['instrument_id', 'society_id', 'hs_number'], | |
| P + 'tunings_scala.parquet': ['scale_id'], P + 'instrument_classes_hs.parquet': ['hs_code'], P + 'singing_style_by_society.parquet': ['society_id']} | |
| KEYS = {P + 'songs_cantometrics.parquet': ['song_id', 'society'], P + 'instruments_by_society.parquet': ['instrument_id', 'name', 'society'], | |
| P + 'instrument_names_mimo.parquet': ['name_en'], P + 'tunings_scala.parquet': ['scale_id'], P + 'song_genres.parquet': ['genre'], | |
| P + 'song_sound_sources.parquet': ['sound_source'], P + 'instrument_classes_hs.parquet': ['hs_code', 'label_en'], P + 'song_functions.parquet': ['song_id', 'function'], | |
| P + 'singing_style_by_society.parquet': ['society_id', 'var_id'], P + 'ensembles_by_society.parquet': ['ensemble_id']} | |
| LANG = {'name_de': 'German', 'name_fr': 'French', 'name_es': 'Spanish', 'name_it': 'Italian', 'name_nl': 'Dutch', 'name_sv': 'Swedish', 'name_zh': 'Chinese', 'name_ko': 'Korean', 'name_pl': 'Polish', 'name_ca': 'Catalan'} | |
| def build(B): | |
| s = B.store | |
| sc = s[P + 'songs_cantometrics.parquet'] | |
| scu = sc[sc.song.notna()] | |
| for r in scu.loc[B.sample(scu.index, 30)].itertuples(): | |
| col = B.rng.choice(['year', 'genre', 'society', 'duration']) | |
| t = {'year': f'In the {SH} (Cantometrics songs), in what year was song {r.song_id} ("{r.song}") recorded?', | |
| 'genre': f'In the {SH} (Cantometrics songs), what genre is song {r.song_id} ("{r.song}") listed as?', | |
| 'society': f'In the {SH} (Cantometrics songs), which society is song {r.song_id} ("{r.song}") from?', | |
| 'duration': f'In the {SH} (Cantometrics songs), what is the duration of song {r.song_id} ("{r.song}") as written (h:mm:ss)?'}[col] | |
| B.add('lookup', t, {'op': 'lookup', 'file': P + 'songs_cantometrics.parquet', 'where': [['song_id', '==', r.song_id]], 'col': col}, skills=['id_lookup']) | |
| socs = sc.groupby('society').size() | |
| for so in B.sample(list(socs[socs >= 5].index), 30): | |
| B.add('count', f'In the {SH}, how many Cantometrics songs are recorded for the society "{so}"?', | |
| {'op': 'count', 'file': P + 'songs_cantometrics.parquet', 'where': [['society', '==', so]]}, skills=['filter', 'count']) | |
| for rg in sorted(sc.region.dropna().unique()): | |
| B.add('count', f'In the {SH}, how many Cantometrics songs come from the region "{rg}"?', | |
| {'op': 'count', 'file': P + 'songs_cantometrics.parquet', 'where': [['region', '==', rg]]}, skills=['filter', 'count']) | |
| B.add('rank', f'In the {SH}, which society in the region "{rg}" has the most Cantometrics songs?', | |
| {'op': 'group_top', 'file': P + 'songs_cantometrics.parquet', 'where': [['region', '==', rg]], 'by': 'society'}, difficulty=2, skills=['group_by', 'ranking']) | |
| ib = s[P + 'instruments_by_society.parquet'] | |
| for r in ib[ib.local_names.notna()].pipe(lambda d: d.loc[B.sample(d.index, 25)]).itertuples(): | |
| B.add('lookup', f'In the {SH} (Global Jukebox instruments), what local name is recorded for instrument {r.instrument_id} ("{r.name}", {r.society})?', | |
| {'op': 'lookup', 'file': P + 'instruments_by_society.parquet', 'where': [['instrument_id', '==', r.instrument_id]], 'col': 'local_names'}, skills=['id_lookup', 'multilingual_entity']) | |
| for r in ib.loc[B.sample(ib.index, 20)].itertuples(): | |
| B.add('lookup', f'In the {SH}, which Hornbostel-Sachs top class (hs_top) is instrument {r.instrument_id} ("{r.name}", {r.society})?', | |
| {'op': 'lookup', 'file': P + 'instruments_by_society.parquet', 'where': [['instrument_id', '==', r.instrument_id]], 'col': 'hs_top'}, skills=['id_lookup', 'taxonomy']) | |
| for rg in sorted(ib.region.dropna().unique()): | |
| B.add('rank', f'In the {SH}, which Hornbostel-Sachs top class is most common among recorded instruments in the region "{rg}"?', | |
| {'op': 'group_top', 'file': P + 'instruments_by_society.parquet', 'where': [['region', '==', rg]], 'by': 'hs_top'}, difficulty=2, skills=['group_by', 'ranking']) | |
| top = ib[ib.region == rg].hs_top.dropna().unique() | |
| for h in B.sample(list(top), 2): | |
| B.add('count', f'In the {SH}, how many recorded instruments in the region "{rg}" are {h}s?', | |
| {'op': 'count', 'file': P + 'instruments_by_society.parquet', 'where': [['region', '==', rg], ['hs_top', '==', h]]}, difficulty=2, skills=['filter', 'count']) | |
| co = ib.groupby('country').size() | |
| for c in B.sample(list(co[co >= 8].index), 12): | |
| B.add('nunique', f'In the {SH}, how many distinct societies in {c} have recorded instruments?', | |
| {'op': 'nunique', 'file': P + 'instruments_by_society.parquet', 'where': [['country', '==', c]], 'col': 'society'}, difficulty=2, skills=['aggregation']) | |
| mm = s[P + 'instrument_names_mimo.parquet'] | |
| mm = mm[~mm.duplicated(['name_en'], keep=False)] | |
| for r in mm.loc[B.sample(mm.index, 40)].to_dict('records'): | |
| lang = B.rng.choice([k for k in LANG if r.get(k) and r.get(k) != r['name_en']] or ['name_ko']) | |
| B.add('lookup', f"In the {SH} (MIMO thesaurus), what is the {LANG[lang]} name of the instrument \"{r['name_en']}\"?", | |
| {'op': 'lookup', 'file': P + 'instrument_names_mimo.parquet', 'where': [['name_en', '==', r['name_en']]], 'col': lang}, skills=['multilingual_entity']) | |
| for r in mm.loc[B.sample(mm.index, 15)].itertuples(): | |
| B.add('lookup', f'In the {SH} (MIMO thesaurus), what Hornbostel-Sachs code(s) are given for "{r.name_en}"?', | |
| {'op': 'lookup', 'file': P + 'instrument_names_mimo.parquet', 'where': [['name_en', '==', r.name_en]], 'col': 'hs_codes'}, skills=['taxonomy']) | |
| hs = s[P + 'instrument_classes_hs.parquet'] | |
| for r in hs.loc[B.sample(hs.index, 20)].itertuples(): | |
| B.add('lookup', f'In the {SH}, what is the English label of Hornbostel-Sachs class {r.hs_code}?', | |
| {'op': 'lookup', 'file': P + 'instrument_classes_hs.parquet', 'where': [['hs_code', '==', r.hs_code]], 'col': 'label_en'}, skills=['taxonomy']) | |
| tu = s[P + 'tunings_scala.parquet'] | |
| for r in tu.loc[B.sample(tu.index, 25)].itertuples(): | |
| col = B.rng.choice(['n_notes', 'min_step_cents', 'max_step_cents', 'period_cents']) | |
| txt = {'n_notes': 'how many notes does', 'min_step_cents': 'what is the smallest step, in cents, of', 'max_step_cents': 'what is the largest step, in cents, of', 'period_cents': 'what is the period, in cents, of'}[col] | |
| B.add('lookup', f'In the {SH} (Scala archive), {txt} the scale {r.scale_id}?', | |
| {'op': 'lookup', 'file': P + 'tunings_scala.parquet', 'where': [['scale_id', '==', r.scale_id]], 'col': col}, tol={'abs': 0.01} if col != 'n_notes' else {'abs': 0}, skills=['id_lookup']) | |
| for n in [5, 7, 12, 19, 22, 24, 31, 53]: | |
| B.add('count', f'In the {SH} (Scala archive), how many tunings have exactly {n} notes?', {'op': 'count', 'file': P + 'tunings_scala.parquet', 'where': [['n_notes', '==', n]]}, skills=['filter', 'count']) | |
| B.add('rank', f'In the {SH} (Scala archive), which scale id has the most notes?', {'op': 'argmax', 'file': P + 'tunings_scala.parquet', 'col': 'n_notes', 'return': 'scale_id'}, difficulty=2, skills=['ranking']) | |
| tags = tu.tradition_tags.dropna().unique() | |
| for t in B.sample(list(tags), 8): | |
| B.add('count', f'In the {SH} (Scala archive), how many tunings are tagged with the tradition "{t}"?', {'op': 'count', 'file': P + 'tunings_scala.parquet', 'where': [['tradition_tags', '==', t]]}, skills=['filter', 'count']) | |
| g = s[P + 'song_genres.parquet'] | |
| for r in g[g.n_songs >= 10].pipe(lambda d: d.loc[B.sample(d.index, 18)]).itertuples(): | |
| col = B.rng.choice(['n_songs', 'n_societies', 'n_regions']) | |
| B.add('lookup', f'In the {SH}, for the song genre "{r.genre}", what is {col}?', {'op': 'lookup', 'file': P + 'song_genres.parquet', 'where': [['genre', '==', r.genre]], 'col': col}, skills=['table_lookup']) | |
| B.add('rank', f'In the {SH}, which song genre has the most songs?', {'op': 'argmax', 'file': P + 'song_genres.parquet', 'col': 'n_songs', 'return': 'genre'}, skills=['ranking']) | |
| B.add('rank', f'In the {SH}, list the 5 song genres with the most songs, most first.', {'op': 'topk', 'k': 5, 'file': P + 'song_genres.parquet', 'col': 'n_songs', 'return': 'genre'}, difficulty=2, skills=['ranking'], answer_format='JSON list') | |
| ss = s[P + 'song_sound_sources.parquet'] | |
| for r in ss[ss.n_songs >= 20].pipe(lambda d: d.loc[B.sample(d.index, 12)]).itertuples(): | |
| B.add('lookup', f'In the {SH}, in how many songs does the sound source "{r.sound_source}" appear?', {'op': 'lookup', 'file': P + 'song_sound_sources.parquet', 'where': [['sound_source', '==', r.sound_source]], 'col': 'n_songs'}, skills=['table_lookup']) | |
| sf = s[P + 'song_functions.parquet'] | |
| for fn in sorted(sf.function.dropna().unique()): | |
| B.add('count', f'In the {SH} (Natural History of Song), how many recordings have the function "{fn}"?', {'op': 'count', 'file': P + 'song_functions.parquet', 'where': [['function', '==', fn]]}, skills=['filter', 'count']) | |
| B.add('nunique', f'In the {SH} (Natural History of Song), how many distinct societies have at least one "{fn}" recording?', {'op': 'nunique', 'file': P + 'song_functions.parquet', 'where': [['function', '==', fn]], 'col': 'society'}, difficulty=2, skills=['aggregation']) | |
| st = s[P + 'singing_style_by_society.parquet'] | |
| for r in st.loc[B.sample(st.index, 20)].itertuples(): | |
| B.add('lookup', f'In the {SH} (Cantometrics), what is the modal coding (name) of "{r.short_title}" ({r.var_id}) for the society {r.society}?', | |
| {'op': 'lookup', 'file': P + 'singing_style_by_society.parquet', 'where': [['society_id', '==', r.society_id], ['var_id', '==', r.var_id]], 'col': 'name'}, skills=['table_lookup']) | |
| for so in ['Lilambd Highlanders', 'Hibe Riverfolk', 'Kumori Islanders', 'Sasaneki']: | |
| B.add('unanswerable', f'In the {SH}, how many Cantometrics songs are recorded for the society "{so}"? If the society is not in the dataset, answer null.', | |
| {'op': 'absent', 'file': P + 'songs_cantometrics.parquet', 'where': [['society', '==', so]]}, skills=['abstention'], note='Fictional society name.') | |
| noloc = ib[ib.local_names.isna()] | |
| for r in noloc.loc[B.sample(noloc.index, 8)].itertuples(): | |
| B.add('unanswerable', f'In the {SH}, what local name is recorded for instrument {r.instrument_id} ("{r.name}", {r.society})? If none is recorded, answer null.', | |
| {'op': 'absent', 'file': P + 'instruments_by_society.parquet', 'where': [['instrument_id', '==', r.instrument_id], ['local_names', 'notna', None]]}, difficulty=2, skills=['abstention']) | |