Datasets:
Download scripts/ds_signals.py from Lilambd/empire-eval: direct link, hf CLI and curl.
- Browser
- Download file 8.81 kB
-
https://huggingface.co/datasets/Lilambd/empire-eval/resolve/main/scripts/ds_signals.py
- Command line
-
hf download hf://datasets/Lilambd/empire-eval/scripts/ds_signals.py
-
curl -L -o ds_signals.py https://huggingface.co/datasets/Lilambd/empire-eval/resolve/main/scripts/ds_signals.py
8.81 kB
| from remote_util import latest, day_of, has, uniq | |
| from common import cname2 | |
| DS = 'Lilambd/world-signals' | |
| LICENSE = 'CC BY 4.0' | |
| STR = {} | |
| KEYS = {} | |
| SH = 'World Signals' | |
| def clean(B, f): | |
| """True if the file exists and has no exact duplicate rows. The 2026-11-03 | |
| export repeated rows (gdelt_events: 12,013 rows, 871 distinct); counts and | |
| rankings over such a file would be wrong, so a file with duplicates is skipped.""" | |
| if not latest(B.store.root, f): | |
| return False | |
| d = B.store[f] | |
| dup = int(d.drop(columns=['_row']).duplicated().sum()) | |
| if dup: | |
| print(f' skip {f}: {dup} exact duplicate rows') | |
| return False | |
| return True | |
| def build(B): | |
| root = B.store.root | |
| day = day_of(latest(root, 'data/*/steam_top.csv')) | |
| if not day: | |
| return | |
| on = f'In {SH} for {day}' | |
| f = f'data/{day}/steam_top.csv' | |
| if clean(B, f): | |
| KEYS[f] = ['rank', 'appid', 'name'] | |
| st = B.store[f] | |
| for r in uniq(st, 'name').head(60).pipe(lambda d: d.loc[B.sample(d.index, 25)]).itertuples(): | |
| col = B.rng.choice(['rank', 'peak_players']) | |
| B.add('lookup', f'{on}, ' + (f'what rank does "{r.name}" hold in the Steam top list?' if col == 'rank' else f'what is the peak concurrent player count of "{r.name}"?'), | |
| {'op': 'lookup', 'file': f, 'where': [['name', '==', r.name]], 'col': col}, tol={'abs': 0}, skills=['table_lookup', 'fresh_data']) | |
| for k in (1, 3, 5): | |
| B.add('rank', f'{on}, which {k} Steam games have the highest peak players, highest first?' if k > 1 else f'{on}, which Steam game has the highest peak players?', | |
| {'op': 'topk' if k > 1 else 'argmax', 'k': k, 'file': f, 'col': 'peak_players', 'return': 'name'}, difficulty=2, skills=['ranking', 'fresh_data'], answer_format='JSON list' if k > 1 else None) | |
| for g in ['Free To Play', 'Indie', 'RPG', 'Strategy', 'Simulation', 'Action']: | |
| B.add('count', f'{on}, how many games in the Steam top list have the genre "{g}"?', {'op': 'count', 'file': f, 'where': [['genres', 'contains', g]]}, difficulty=2, skills=['filter', 'count', 'fresh_data']) | |
| f = f'data/{day}/github_new_repos.csv' | |
| if clean(B, f): | |
| KEYS[f] = ['repo'] | |
| g = B.store[f] | |
| for r in uniq(g, 'repo').pipe(lambda d: d.loc[B.sample(d.index, 25)]).itertuples(): | |
| col = B.rng.choice(['stars', 'forks', 'language']) | |
| if col == 'language' and r.language != r.language: | |
| continue | |
| B.add('lookup', f'{on}, how many {col} does the new GitHub repo {r.repo} have?' if col != 'language' else f'{on}, what is the main language of the new GitHub repo {r.repo}?', | |
| {'op': 'lookup', 'file': f, 'where': [['repo', '==', r.repo]], 'col': col}, tol={'abs': 0}, skills=['table_lookup', 'fresh_data']) | |
| langs = g.language.value_counts() | |
| for lg in list(langs[langs >= 3].index)[:12]: | |
| B.add('count', f'{on}, how many of the new GitHub repos are written mainly in {lg}?', {'op': 'count', 'file': f, 'where': [['language', '==', lg]]}, skills=['filter', 'count', 'fresh_data']) | |
| B.add('rank', f'{on}, which new GitHub repo in {lg} has the most stars?', {'op': 'argmax', 'file': f, 'where': [['language', '==', lg]], 'col': 'stars', 'return': 'repo'}, difficulty=2, skills=['ranking', 'fresh_data']) | |
| f = f'data/{day}/hf_trending.csv' | |
| if clean(B, f): | |
| KEYS[f] = ['kind', 'repo_id'] | |
| h = B.store[f] | |
| for r in uniq(h, 'repo_id').pipe(lambda d: d.loc[B.sample(d.index, 25)]).itertuples(): | |
| col = B.rng.choice(['likes', 'downloads_month', 'trending_score']) | |
| B.add('lookup', f'{on}, what is the {col.replace("_", " ")} of the Hugging Face repo {r.repo_id}?', {'op': 'lookup', 'file': f, 'where': [['repo_id', '==', r.repo_id]], 'col': col}, tol={'abs': 0}, skills=['table_lookup', 'fresh_data']) | |
| for k in sorted(h.kind.dropna().unique()): | |
| B.add('rank', f'{on}, which {k.replace("hf_", "Hugging Face ")} has the highest trending score?', {'op': 'argmax', 'file': f, 'where': [['kind', '==', k]], 'col': 'trending_score', 'return': 'repo_id'}, difficulty=2, skills=['ranking', 'fresh_data']) | |
| B.add('count', f'{on}, how many trending {k.replace("hf_", "Hugging Face ")}s are listed?', {'op': 'count', 'file': f, 'where': [['kind', '==', k]]}, skills=['count', 'fresh_data']) | |
| for p in list(h.pipeline.dropna().value_counts().index)[:8]: | |
| B.add('count', f'{on}, how many trending Hugging Face models have the pipeline "{p}"?', {'op': 'count', 'file': f, 'where': [['pipeline', '==', p]]}, skills=['filter', 'count', 'fresh_data']) | |
| f = f'data/{day}/package_downloads.csv' | |
| if clean(B, f): | |
| KEYS[f] = ['ecosystem', 'package'] | |
| pk = B.store[f] | |
| pku = pk[~pk.duplicated(['ecosystem', 'package'], keep=False) & pk.downloads_month.notna()] | |
| for r in pku.loc[B.sample(pku.index, 30)].itertuples(): | |
| B.add('lookup', f'{on}, how many monthly downloads does the {r.ecosystem} package "{r.package}" have?', {'op': 'lookup', 'file': f, 'where': [['ecosystem', '==', r.ecosystem], ['package', '==', r.package]], 'col': 'downloads_month'}, tol={'rel': 0.0001}, skills=['table_lookup', 'fresh_data']) | |
| for e in sorted(pk.ecosystem.dropna().unique()): | |
| B.add('rank', f'{on}, which {e} package has the most monthly downloads?', {'op': 'argmax', 'file': f, 'where': [['ecosystem', '==', e]], 'col': 'downloads_month', 'return': 'package'}, difficulty=2, skills=['ranking', 'fresh_data']) | |
| B.add('rank', f'{on}, list the 3 {e} packages with the most monthly downloads, most first.', {'op': 'topk', 'k': 3, 'file': f, 'where': [['ecosystem', '==', e]], 'col': 'downloads_month', 'return': 'package'}, difficulty=2, skills=['ranking', 'fresh_data'], answer_format='JSON list') | |
| for _ in range(10): | |
| a, b = pku.sample(2, random_state=B.rng.randint(0, 1 << 30)).to_dict('records') | |
| B.add('compare', f"{on}, which package has more monthly downloads: {a['package']} ({a['ecosystem']}) or {b['package']} ({b['ecosystem']})?", | |
| {'op': 'compare', 'labels': [a['package'], b['package']], 'parts': [ | |
| {'op': 'lookup', 'file': f, 'where': [['ecosystem', '==', a['ecosystem']], ['package', '==', a['package']]], 'col': 'downloads_month'}, | |
| {'op': 'lookup', 'file': f, 'where': [['ecosystem', '==', b['ecosystem']], ['package', '==', b['package']]], 'col': 'downloads_month'}]}, difficulty=2, skills=['comparison', 'fresh_data']) | |
| f = f'data/{day}/podcast_charts.csv' | |
| if clean(B, f): | |
| KEYS[f] = ['country', 'rank', 'name'] | |
| pc = B.store[f] | |
| for c in B.sample(sorted(pc.country.dropna().unique()), 25): | |
| rk = B.rng.choice([1, 1, 2, 3, 5, 10]) | |
| B.add('lookup', f'{on}, which podcast is ranked #{rk} on the Apple Podcasts chart for {cname2(c.upper())}?', {'op': 'lookup', 'file': f, 'where': [['country', '==', c], ['rank', '==', rk]], 'col': 'name'}, skills=['table_lookup', 'fresh_data', 'multilingual_entity']) | |
| for c in B.sample(sorted(pc.country.dropna().unique()), 10): | |
| B.add('rank', f'{on}, which genre appears most often on the Apple Podcasts chart for {cname2(c.upper())}?', {'op': 'group_top', 'file': f, 'where': [['country', '==', c]], 'by': 'genre'}, difficulty=3, skills=['group_by', 'fresh_data']) | |
| f = f'data/{day}/search_trends.csv' | |
| if clean(B, f): | |
| KEYS[f] = ['country', 'term'] | |
| s = B.store[f] | |
| su = s[~s.duplicated(['country', 'term'], keep=False)] | |
| for r in su.loc[B.sample(su.index, 20)].itertuples(): | |
| B.add('lookup', f'{on}, what approximate search traffic is shown for the trending term "{r.term}" in {cname2(str(r.country).upper())}?', {'op': 'lookup', 'file': f, 'where': [['country', '==', r.country], ['term', '==', r.term]], 'col': 'approx_traffic'}, tol={'abs': 0}, skills=['table_lookup', 'fresh_data', 'multilingual_entity']) | |
| for c in B.sample(sorted(s.country.dropna().unique()), 12): | |
| B.add('count', f'{on}, how many trending search terms are listed for {cname2(c.upper())}?', {'op': 'count', 'file': f, 'where': [['country', '==', c]]}, skills=['count', 'fresh_data']) | |
| for nm in ['Lilambd Quest Online', 'Hibe Riverfolk Simulator']: | |
| f = f'data/{day}/steam_top.csv' | |
| if clean(B, f): | |
| B.add('unanswerable', f'{on}, what rank does "{nm}" hold in the Steam top list? If it is not listed, answer null.', {'op': 'absent', 'file': f, 'where': [['name', '==', nm]]}, skills=['abstention', 'fresh_data']) | |