File size: 5,847 Bytes
a2c2f1e | 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 | """Frontier-CS: Evolving Challenges for Evolving Intelligence"""
import os
import datasets
_DESCRIPTION = """
Frontier-CS is an unsolved, open-ended, verifiable, and diverse benchmark
for evaluating AI on challenging computer science problems.
"""
_HOMEPAGE = "https://frontier-cs.org"
_LICENSE = "Apache-2.0"
class FrontierCSConfig(datasets.BuilderConfig):
def __init__(self, **kwargs):
super().__init__(**kwargs)
class FrontierCS(datasets.GeneratorBasedBuilder):
VERSION = datasets.Version("1.0.0")
BUILDER_CONFIGS = [
FrontierCSConfig(name="algorithmic", description="118 algorithmic problems"),
FrontierCSConfig(name="research", description="63 research problems"),
FrontierCSConfig(name="all", description="All problems"),
]
DEFAULT_CONFIG_NAME = "all"
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features({
"problem_id": datasets.Value("string"),
"category": datasets.Value("string"),
"statement": datasets.Value("string"),
"config": datasets.Value("string"),
}),
homepage=_HOMEPAGE,
license=_LICENSE,
)
def _split_generators(self, dl_manager):
return [
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={"config_name": self.config.name},
),
]
def _generate_examples(self, config_name):
base_path = os.path.dirname(os.path.abspath(__file__))
idx = 0
# Algorithmic problems
if config_name in ["algorithmic", "all"]:
algo_path = os.path.join(base_path, "algorithmic", "problems")
if os.path.exists(algo_path):
for problem_id in sorted(os.listdir(algo_path)):
problem_dir = os.path.join(algo_path, problem_id)
if not os.path.isdir(problem_dir):
continue
statement = ""
config = ""
statement_file = os.path.join(problem_dir, "statement.txt")
if os.path.exists(statement_file):
with open(statement_file, "r", encoding="utf-8") as f:
statement = f.read()
config_file = os.path.join(problem_dir, "config.yaml")
if os.path.exists(config_file):
with open(config_file, "r", encoding="utf-8") as f:
config = f.read()
yield idx, {
"problem_id": problem_id,
"category": "algorithmic",
"statement": statement,
"config": config,
}
idx += 1
# Research problems
if config_name in ["research", "all"]:
research_path = os.path.join(base_path, "research", "problems")
if os.path.exists(research_path):
for category in sorted(os.listdir(research_path)):
category_dir = os.path.join(research_path, category)
if not os.path.isdir(category_dir):
continue
# Check if this is a problem dir or a parent dir
readme_file = os.path.join(category_dir, "readme")
config_file = os.path.join(category_dir, "config.yaml")
if os.path.exists(readme_file) or os.path.exists(config_file):
# This is a problem directory
statement = ""
config = ""
if os.path.exists(readme_file):
with open(readme_file, "r", encoding="utf-8") as f:
statement = f.read()
if os.path.exists(config_file):
with open(config_file, "r", encoding="utf-8") as f:
config = f.read()
yield idx, {
"problem_id": category,
"category": "research",
"statement": statement,
"config": config,
}
idx += 1
else:
# Check subdirectories
for subproblem in sorted(os.listdir(category_dir)):
subproblem_dir = os.path.join(category_dir, subproblem)
if not os.path.isdir(subproblem_dir):
continue
readme_file = os.path.join(subproblem_dir, "readme")
config_file = os.path.join(subproblem_dir, "config.yaml")
statement = ""
config = ""
if os.path.exists(readme_file):
with open(readme_file, "r", encoding="utf-8") as f:
statement = f.read()
if os.path.exists(config_file):
with open(config_file, "r", encoding="utf-8") as f:
config = f.read()
if statement or config:
yield idx, {
"problem_id": f"{category}/{subproblem}",
"category": "research",
"statement": statement,
"config": config,
}
idx += 1
|