File size: 22,420 Bytes
0584798 | 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 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | from __future__ import annotations
import json
import sys
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent
if str(BASE_DIR) not in sys.path:
sys.path.insert(0, str(BASE_DIR))
from config import IAB_BENCHMARK_PATH, IAB_DIFFICULTY_DATA_DIR
def write_jsonl(path: Path, rows: list[dict]) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
with path.open("w", encoding="utf-8") as handle:
for row in rows:
handle.write(json.dumps(row, sort_keys=True) + "\n")
def shopping_prompts(fields: dict[str, str]) -> dict[str, tuple[str, ...]]:
return {
"easy": (
f"best {fields['item_plural']}",
f"which {fields['item']} should i buy in {fields['year']}",
f"{fields['provider_a']} vs {fields['provider_b']}",
f"{fields['item']} buying guide",
),
"medium": (
f"best {fields['item']} for {fields['audience']}",
f"compare {fields['provider_a']} and {fields['provider_b']} before buying",
f"affordable {fields['item_plural']} for {fields['audience']}",
f"what {fields['item_plural']} are worth considering for {fields['audience']}",
),
"hard": (
f"i am replacing my current {fields['item']} and need the right option for {fields['audience']}",
f"help me narrow down {fields['item_plural']} for {fields['audience']} without wasting money",
f"which option makes more sense between {fields['provider_a']} and {fields['provider_b']} for {fields['audience']}",
f"i need a shortlist of {fields['item_plural']} that fit {fields['constraint']}",
),
}
def software_prompts(fields: dict[str, str]) -> dict[str, tuple[str, ...]]:
return {
"easy": (
f"best {fields['item_plural']} for {fields['audience']}",
f"what is {fields['item']}",
f"{fields['provider_a']} vs {fields['provider_b']}",
f"{fields['item']} for {fields['goal']}",
),
"medium": (
f"compare {fields['provider_a']} and {fields['provider_b']} for {fields['audience']}",
f"best {fields['item_plural']} for {fields['goal']}",
f"how does {fields['item']} work for {fields['audience']}",
f"which {fields['item']} should a {fields['audience']} choose",
),
"hard": (
f"i am evaluating software for {fields['goal']} and need the right category",
f"what tools should i shortlist before picking between {fields['provider_a']} and {fields['provider_b']}",
f"we need a platform for {fields['goal']} and are not sure which branch this falls into",
f"help me assess {fields['provider_a']} versus other options for {fields['audience']}",
),
}
def business_it_prompts(fields: dict[str, str]) -> dict[str, tuple[str, ...]]:
return {
"easy": (
"how do i reset my password",
"business login security tools",
"identity management software",
f"{fields['provider_a']} vs {fields['provider_b']} for access management",
),
"medium": (
"best software for employee password resets",
"how does single sign-on work for a small company",
"access management platform for remote employees",
f"compare {fields['provider_a']} and {fields['provider_b']} for workforce identity",
),
"hard": (
"our team keeps getting locked out and we need better identity software",
"what category covers employee account security and access provisioning",
"we need business software for login, permissions, and access control",
"help me evaluate identity tooling for company account security",
),
}
def dining_prompts(fields: dict[str, str]) -> dict[str, tuple[str, ...]]:
return {
"easy": (
"book a table for dinner",
"best restaurants for date night",
"where should i eat tonight",
"reserve a table for two",
),
"medium": (
f"{fields['area']} restaurant options for a birthday dinner",
"family friendly restaurants near me",
"compare brunch spots for a weekend meetup",
"where can i book dinner for four tonight",
),
"hard": (
"i need a place to eat and want something i can reserve tonight",
"what category covers restaurants and booking a table",
"help me find a dinner spot for a client meeting",
"i want dining options, not recipes",
),
}
def beverage_prompts(fields: dict[str, str]) -> dict[str, tuple[str, ...]]:
return {
"easy": (
"best vodka drink to try",
"whiskey cocktail ideas",
"what is a martini",
"bourbon vs rye for beginners",
),
"medium": (
"best whiskey cocktail for a dinner party",
"vodka drinks for beginners",
"compare bourbon and scotch flavor profiles",
"how does gin differ from vodka in cocktails",
),
"hard": (
"i want alcoholic drink recommendations, not restaurant suggestions",
"help me understand beginner-friendly cocktails with bourbon",
"what should i try if i want a spirit-forward drink",
"compare vodka cocktails with tequila cocktails",
),
}
def ai_prompts(fields: dict[str, str]) -> dict[str, tuple[str, ...]]:
return {
"easy": (
"what is intent classification in nlp",
"machine learning basics",
"how does natural language processing work",
"what are large language models",
),
"medium": (
"best ai methods for text classification",
"nlp model comparison for intent detection",
"how do llms handle classification tasks",
"ai tools for labeling text data",
),
"hard": (
"i want the ai concept behind intent models, not software shopping",
"help me understand the machine learning side of nlp classification",
"compare transformer-based approaches for intent detection",
"what branch covers language-model research topics",
),
}
KIND_TO_BUILDER = {
"shopping": shopping_prompts,
"software": software_prompts,
"business_it": business_it_prompts,
"dining": dining_prompts,
"beverage": beverage_prompts,
"ai": ai_prompts,
}
AUGMENTATION_SCENARIOS = {
"Automotive > Auto Buying and Selling": [
{
"kind": "shopping",
"item": "car",
"item_plural": "cars",
"provider_a": "Toyota Corolla",
"provider_b": "Honda Civic",
"audience": "a commuter",
"constraint": "a practical budget",
"year": "2026",
},
{
"kind": "shopping",
"item": "suv",
"item_plural": "suvs",
"provider_a": "Toyota RAV4",
"provider_b": "Honda CR-V",
"audience": "a growing family",
"constraint": "daily driving and storage needs",
"year": "2026",
},
{
"kind": "shopping",
"item": "electric car",
"item_plural": "electric cars",
"provider_a": "Tesla Model 3",
"provider_b": "Hyundai Ioniq 5",
"audience": "a first-time ev buyer",
"constraint": "reasonable range and price",
"year": "2026",
},
],
"Business and Finance > Business > Sales": [
{
"kind": "software",
"item": "crm software",
"item_plural": "crm tools",
"provider_a": "HubSpot",
"provider_b": "Zoho",
"audience": "small sales teams",
"goal": "lead management",
},
{
"kind": "software",
"item": "sales engagement software",
"item_plural": "sales platforms",
"provider_a": "Apollo",
"provider_b": "Outreach",
"audience": "outbound teams",
"goal": "pipeline generation",
},
{
"kind": "software",
"item": "customer relationship management software",
"item_plural": "crm systems",
"provider_a": "Pipedrive",
"provider_b": "Freshsales",
"audience": "growing startups",
"goal": "deal tracking",
},
],
"Business and Finance > Business > Marketing and Advertising": [
{
"kind": "software",
"item": "marketing software",
"item_plural": "marketing tools",
"provider_a": "Semrush",
"provider_b": "Ahrefs",
"audience": "content teams",
"goal": "organic growth",
},
{
"kind": "software",
"item": "seo platform",
"item_plural": "seo tools",
"provider_a": "Surfer",
"provider_b": "Clearscope",
"audience": "editorial teams",
"goal": "content optimization",
},
{
"kind": "software",
"item": "advertising analytics software",
"item_plural": "marketing analytics tools",
"provider_a": "Triple Whale",
"provider_b": "Northbeam",
"audience": "performance marketers",
"goal": "campaign measurement",
},
],
"Business and Finance > Business > Business I.T.": [
{"kind": "business_it", "provider_a": "Okta", "provider_b": "Microsoft Entra"},
{"kind": "business_it", "provider_a": "JumpCloud", "provider_b": "Okta"},
{"kind": "business_it", "provider_a": "Duo", "provider_b": "OneLogin"},
],
"Food & Drink > Dining Out": [
{"kind": "dining", "area": "downtown"},
{"kind": "dining", "area": "midtown"},
{"kind": "dining", "area": "the waterfront"},
],
"Food & Drink > Alcoholic Beverages": [
{"kind": "beverage"},
{"kind": "beverage"},
{"kind": "beverage"},
],
"Technology & Computing > Artificial Intelligence": [
{"kind": "ai"},
{"kind": "ai"},
{"kind": "ai"},
],
"Technology & Computing > Computing > Computer Software and Applications": [
{
"kind": "software",
"item": "software platform",
"item_plural": "software applications",
"provider_a": "Notion",
"provider_b": "Airtable",
"audience": "operations teams",
"goal": "workflow management",
},
{
"kind": "software",
"item": "project management software",
"item_plural": "software tools",
"provider_a": "Asana",
"provider_b": "ClickUp",
"audience": "remote teams",
"goal": "project planning",
},
{
"kind": "software",
"item": "business software",
"item_plural": "software products",
"provider_a": "Monday.com",
"provider_b": "Notion",
"audience": "startup operators",
"goal": "team coordination",
},
],
"Technology & Computing > Computing > Computer Software and Applications > Communication": [
{
"kind": "software",
"item": "communication software",
"item_plural": "communication tools",
"provider_a": "Slack",
"provider_b": "Microsoft Teams",
"audience": "remote teams",
"goal": "team communication",
},
{
"kind": "software",
"item": "team chat software",
"item_plural": "messaging platforms",
"provider_a": "Slack",
"provider_b": "Discord",
"audience": "distributed startups",
"goal": "internal collaboration",
},
{
"kind": "software",
"item": "workplace communication platform",
"item_plural": "communication apps",
"provider_a": "Google Chat",
"provider_b": "Microsoft Teams",
"audience": "cross-functional teams",
"goal": "company messaging",
},
],
"Technology & Computing > Computing > Internet > Web Hosting": [
{
"kind": "software",
"item": "web hosting",
"item_plural": "hosting providers",
"provider_a": "Vercel",
"provider_b": "Netlify",
"audience": "startup launch teams",
"goal": "site hosting",
},
{
"kind": "software",
"item": "hosting platform",
"item_plural": "hosting services",
"provider_a": "Cloudflare Pages",
"provider_b": "Render",
"audience": "developers",
"goal": "website deployment",
},
{
"kind": "software",
"item": "managed hosting",
"item_plural": "hosting options",
"provider_a": "WP Engine",
"provider_b": "Kinsta",
"audience": "content teams",
"goal": "site performance",
},
],
"Technology & Computing > Computing > Laptops": [
{
"kind": "shopping",
"item": "laptop",
"item_plural": "laptops",
"provider_a": "MacBook Air",
"provider_b": "Dell XPS 13",
"audience": "work and study",
"constraint": "battery life and portability",
"year": "2026",
},
{
"kind": "shopping",
"item": "gaming laptop",
"item_plural": "gaming laptops",
"provider_a": "Asus ROG Zephyrus",
"provider_b": "Lenovo Legion Slim",
"audience": "gamers",
"constraint": "performance under a reasonable budget",
"year": "2026",
},
{
"kind": "shopping",
"item": "student laptop",
"item_plural": "student laptops",
"provider_a": "Acer Swift Go",
"provider_b": "HP Pavilion Aero",
"audience": "college students",
"constraint": "price and portability",
"year": "2026",
},
],
"Technology & Computing > Computing > Desktops": [
{
"kind": "shopping",
"item": "desktop",
"item_plural": "desktops",
"provider_a": "iMac",
"provider_b": "Dell Inspiron Desktop",
"audience": "home offices",
"constraint": "everyday productivity",
"year": "2026",
},
{
"kind": "shopping",
"item": "gaming desktop",
"item_plural": "gaming desktops",
"provider_a": "Alienware Aurora",
"provider_b": "Lenovo Legion Tower",
"audience": "pc gamers",
"constraint": "strong graphics performance",
"year": "2026",
},
{
"kind": "shopping",
"item": "desktop pc",
"item_plural": "desktop computers",
"provider_a": "HP Envy Desktop",
"provider_b": "Acer Aspire TC",
"audience": "families",
"constraint": "value for money",
"year": "2026",
},
],
"Technology & Computing > Consumer Electronics > Smartphones": [
{
"kind": "shopping",
"item": "smartphone",
"item_plural": "smartphones",
"provider_a": "iPhone 17",
"provider_b": "Samsung Galaxy S26",
"audience": "everyday users",
"constraint": "camera quality and battery life",
"year": "2026",
},
{
"kind": "shopping",
"item": "budget phone",
"item_plural": "budget smartphones",
"provider_a": "Pixel 10a",
"provider_b": "Galaxy A57",
"audience": "budget-conscious buyers",
"constraint": "under midrange pricing",
"year": "2026",
},
{
"kind": "shopping",
"item": "android phone",
"item_plural": "android phones",
"provider_a": "OnePlus 15",
"provider_b": "Pixel 10",
"audience": "power users",
"constraint": "performance and clean software",
"year": "2026",
},
],
}
BENCHMARK_SCENARIOS = {
"Automotive > Auto Buying and Selling": {
"kind": "shopping",
"item": "car",
"item_plural": "vehicles",
"provider_a": "Mazda CX-5",
"provider_b": "Subaru Forester",
"audience": "a first-time buyer",
"constraint": "safety and price",
"year": "2026",
},
"Business and Finance > Business > Sales": {
"kind": "software",
"item": "crm platform",
"item_plural": "sales tools",
"provider_a": "Copper",
"provider_b": "Salesforce Essentials",
"audience": "small revenue teams",
"goal": "managing leads",
},
"Business and Finance > Business > Marketing and Advertising": {
"kind": "software",
"item": "marketing platform",
"item_plural": "marketing tools",
"provider_a": "Moz",
"provider_b": "SE Ranking",
"audience": "brand teams",
"goal": "search visibility",
},
"Business and Finance > Business > Business I.T.": {
"kind": "business_it",
"provider_a": "Rippling",
"provider_b": "JumpCloud",
},
"Food & Drink > Dining Out": {"kind": "dining", "area": "uptown"},
"Food & Drink > Alcoholic Beverages": {"kind": "beverage"},
"Technology & Computing > Artificial Intelligence": {"kind": "ai"},
"Technology & Computing > Computing > Computer Software and Applications": {
"kind": "software",
"item": "workflow software",
"item_plural": "productivity apps",
"provider_a": "Basecamp",
"provider_b": "Asana",
"audience": "small teams",
"goal": "organizing work",
},
"Technology & Computing > Computing > Computer Software and Applications > Communication": {
"kind": "software",
"item": "communication platform",
"item_plural": "team messaging tools",
"provider_a": "Mattermost",
"provider_b": "Slack",
"audience": "engineering teams",
"goal": "workplace communication",
},
"Technology & Computing > Computing > Internet > Web Hosting": {
"kind": "software",
"item": "web hosting service",
"item_plural": "hosting platforms",
"provider_a": "Fly.io",
"provider_b": "Render",
"audience": "product builders",
"goal": "deploying websites",
},
"Technology & Computing > Computing > Laptops": {
"kind": "shopping",
"item": "laptop",
"item_plural": "portable computers",
"provider_a": "Surface Laptop",
"provider_b": "Framework Laptop",
"audience": "knowledge workers",
"constraint": "portability and repairability",
"year": "2026",
},
"Technology & Computing > Computing > Desktops": {
"kind": "shopping",
"item": "desktop computer",
"item_plural": "desktop pcs",
"provider_a": "Mac Studio",
"provider_b": "HP Omen 45L",
"audience": "creators",
"constraint": "performance and reliability",
"year": "2026",
},
"Technology & Computing > Consumer Electronics > Smartphones": {
"kind": "shopping",
"item": "smartphone",
"item_plural": "mobile phones",
"provider_a": "Nothing Phone 4",
"provider_b": "Pixel 10 Pro",
"audience": "everyday buyers",
"constraint": "camera and battery performance",
"year": "2026",
},
}
def build_rows(label: str, scenarios: list[dict], include_difficulty: bool) -> list[dict]:
rows = []
seen = set()
for scenario in scenarios:
prompts_by_difficulty = KIND_TO_BUILDER[scenario["kind"]](scenario)
for difficulty, prompts in prompts_by_difficulty.items():
for text in prompts:
normalized = " ".join(text.strip().lower().split())
key = (label, normalized)
if key in seen:
continue
seen.add(key)
row = {"text": normalized, "iab_path": label}
if include_difficulty:
row["difficulty"] = difficulty
rows.append(row)
return rows
def split_rows(rows: list[dict]) -> tuple[list[dict], list[dict], list[dict]]:
total = len(rows)
val_count = max(1, total // 6)
test_count = max(1, total // 6)
test_rows = rows[:test_count]
val_rows = rows[test_count : test_count + val_count]
train_rows = rows[test_count + val_count :]
return train_rows, val_rows, test_rows
def main() -> None:
train_rows: list[dict] = []
val_rows: list[dict] = []
test_rows: list[dict] = []
benchmark_rows: list[dict] = []
for label, scenarios in AUGMENTATION_SCENARIOS.items():
rows = build_rows(label, scenarios, include_difficulty=True)
train_split, val_split, test_split = split_rows(rows)
train_rows.extend(train_split)
val_rows.extend(val_split)
test_rows.extend(test_split)
for label, scenario in BENCHMARK_SCENARIOS.items():
benchmark_rows.extend(build_rows(label, [scenario], include_difficulty=True))
write_jsonl(IAB_DIFFICULTY_DATA_DIR / "train.jsonl", train_rows)
write_jsonl(IAB_DIFFICULTY_DATA_DIR / "val.jsonl", val_rows)
write_jsonl(IAB_DIFFICULTY_DATA_DIR / "test.jsonl", test_rows)
write_jsonl(IAB_BENCHMARK_PATH, benchmark_rows)
print(f"train: {len(train_rows)} rows")
print(f"val: {len(val_rows)} rows")
print(f"test: {len(test_rows)} rows")
print(f"benchmark: {len(benchmark_rows)} rows")
if __name__ == "__main__":
main()
|