"""Synthetic corpus for the loop taxonomy — template x slot generation, labels by construction, plus hand-written boundary items and continuation forms. Built against docs/components/loop-taxonomy.md's entry criteria. Template bias is the known limitation (recorded in the corpus README); slot pools span the personal-assistant life domains: finances, home, devices, travel, health, wardrobe, work/software, family/social, admin, learning, food. """ import json import random rng = random.Random(7) SLOTS = { "thing": ["dishwasher", "washing machine", "dryer", "car", "bike", "gateway", "home server", "laptop", "phone", "wifi", "router", "coffee machine", "water heater", "printer", "door lock", "thermostat", "robot vacuum", "car charger", "monitor", "keyboard"], "bad": ["making a grinding noise", "running really slow", "restarting every few hours", "draining battery fast", "overheating", "randomly disconnecting", "freezing up", "not charging", "leaking", "showing wrong numbers", "flapping on and off", "categorizing things wrong", "running way hotter than usual"], "metric": ["food spend", "electricity bill", "internet bill", "health score", "sleep score", "screen time", "subscription spend", "grocery spend"], "skill": ["Spanish", "guitar", "chess", "cooking", "Python", "drawing", "swimming", "Portuguese", "piano", "photography", "French", "rock climbing"], "standing": ["food budget", "monthly budget", "sleep", "workouts", "investments", "wardrobe", "home maintenance", "savings rate", "screen time"], "person": ["mom", "Priya", "dad", "Anita", "my brother", "Sam", "grandma", "Ravi"], "event": ["dinner", "anniversary dinner", "team offsite", "birthday party", "family lunch", "climbing session", "coffee catch-up", "housewarming", "weekend trip", "date night"], "procedure": ["passport", "driver's license", "car registration", "gym membership", "insurance claim", "expense report", "utility account", "travel visa", "health insurance", "apartment lease", "professional license", "tax filing", "student loan deferment", "parking ticket", "airline refund", "electricity connection"], "artifact": ["cover letter for the Stripe job", "wedding speech", "resignation letter", "meal plan for next week", "training plan for a 10k", "packing list for Japan", "gift ideas for mom's 60th", "budget spreadsheet", "spending dashboard", "script that renames my photo files", "announcement post for the move", "toast for my sister's wedding", "README for my side project"], "topic": ["EV leasing vs buying", "creatine", "standing desks", "moving to Lisbon", "index funds vs robo-advisors", "sleep trackers", "heat pumps", "prenatal vitamins", "noise-cancelling headphones", "heat pump vs solar for our house"], "consumable": ["laundry detergent", "coffee beans", "printer paper", "dog food", "olive oil", "dishwasher tablets", "protein powder", "AA batteries"], "purchase": ["USB-C dock", "replacement filter for the water purifier", "running shoes", "a blender", "a monitor arm", "an air purifier", "a winter jacket", "a standing desk"], "domain": ["budget", "wardrobe", "home setup", "health stats", "reading list", "kitchen"], "situation": ["the move", "this job", "my friendship with Sam", "how the year is going", "my parents getting older", "being so busy lately", "the promotion I didn't get"], "emergency": ["my flight was just cancelled and I fly tomorrow morning", "the hotel just called and cancelled our booking for tonight", "my meeting got moved to right now and I'm not ready", "the washing machine is spilling water on the floor", "I locked myself out and the stove is on", "my phone just broke and it's my only alarm for the early flight", "the bathroom is flooding", "I think I lost my wallet in Lisbon", "the power just went out and the freezer is full", "I'm about to miss the visa filing deadline", "my laptop just died and the presentation is in two hours", "the car won't start and I have a hospital appointment in an hour", "I burned my hand and I'm home alone"], "price": ["don't spend more than $80", "keep it under $30", "whatever's cheapest", "quality over price", "mid-range is fine"], "when": ["tomorrow", "this weekend", "Sunday", "next Tuesday", "tonight", "Saturday morning"], } T = { "diagnose": [ "why is my {thing} {bad}?", "my {thing} keeps {bad} — any idea what's going on?", "any idea why the {thing} is {bad}?", "my {thing} started {bad} after the update — why?", "something's off with my {thing}, it {bad}", "why did my {metric} jump this month?", "my {thing} has been {bad} since yesterday, figure out why", "what's wrong with my {thing}? it's {bad}", "why is the {thing} {bad} again?", "help me figure out why my {thing} is {bad}", "my {thing} is {bad}, what's causing that?", "my {metric} doesn't make sense this month — why?", "why does my {thing} get {bad} only in the evening?", "the {thing} {bad} whenever I run the dishwasher — what is that?", "diagnose my {thing} — it's {bad}", "any clue why {thing} keeps {bad}?", "why is my {thing} {bad} all of a sudden?", "trace down why the {thing} is {bad}", ], "execute": [ "renew my {procedure}", "file the {procedure} claim", "submit my {procedure}", "cancel my {procedure}", "update my address on the {procedure}", "apply for the {procedure}", "get the {procedure} sorted", "handle the {procedure} for me", "i need to renew my {procedure} before it expires", "start the {procedure} process", "complete the {procedure} paperwork", "file a dispute on that charge on my card", "do my taxes this year", "submit the warranty claim for the {thing}", "get my {procedure} reissued", "transfer the {procedure} to my name", "appeal the parking ticket", "get the rebate claim submitted", ], "make": [ "write my {artifact}", "draft a {artifact}", "can you make a {artifact} for me", "put together a {artifact}", "i need a {artifact}", "build me a {artifact}", "write the {artifact}", "help me write my {artifact}", "create a {artifact}", "can you draft the {artifact}?", "make me a {artifact}", "i want a {artifact} — make it good", "write up a {artifact}", "produce the {artifact} from my notes", "turn my notes into a {artifact}", ], "research": [ "look into {topic} for me", "i want to understand {topic} properly", "compare {topic}", "what should i know before deciding on {topic}?", "is the stuff about {topic} actually true?", "dig into {topic} and tell me what matters", "what does the research say about {topic}?", "help me decide — {topic}", "research {topic}", "give me a proper analysis of {topic}", "what are the tradeoffs with {topic}?", "find out what the options are for {topic}", "i keep hearing about {topic} — sort out what's real", "work out whether {topic} makes sense for us", ], "learn": [ "teach me {skill}", "help me learn {skill}", "i want to get better at {skill}", "give me a practice routine for {skill}", "start teaching me {skill}", "quiz me on {skill} every day this week", "work with me on my {skill} a few times a week", "i want to learn {skill}", "help me practice {skill}", "get me from zero to conversational in {skill}", "be my {skill} tutor", "walk me through {skill} day by day", "set up a study plan so i actually learn {skill}", ], "tend": [ "how are we doing on the {standing}?", "review my {standing} this month", "check on the {standing}", "anything i should adjust in my {standing}?", "how's the {standing} tracking?", "go over my {standing} trend with me", "what needs attention in my {domain}?", "keep an eye on my {standing}", "quarterly check on my {standing}", "review the {domain} and tell me what's drifting", "is everything on track with the {standing}?", "do a walkthrough of my {domain} and flag anything off", "how am i doing against my {standing} goals?", "time for the {standing} check-in", ], "companion": [ "i've been feeling {emotion} about {situation}", "i don't know what to do about {situation}", "help me think through how i feel about {situation}", "i'm stressed about {situation}", "can we talk about {situation}? it's been weighing on me", "i keep going back and forth on {situation} and it's exhausting", "i need to vent about {situation}", "i'm anxious about {situation} — talk me through it", "i feel stuck with {situation}", "i can't stop overthinking {situation}", "i've been down about {situation} lately", "can i talk through {situation} with you?", ], "react": [ "{emergency}", "{emergency} — what do i do?", "{emergency}. help.", "quick — {emergency}", "sos: {emergency}", "{emergency}, and i need to act fast", ], "arrange": [ "book me a table for {n} at a good {cuisine} place {when}", "schedule {event} with {person} {when}", "set up a {provider} appointment", "plan {event} for {person}", "arrange a {provider} visit", "find me a {provider} and get me in this week", "coordinate {event} — {price}", "get {event} on the calendar", "book the {event}", "sort out {event} for {when}", "make a reservation for {event} {when}", ], "acquire": [ "order more {consumable}", "we're out of {consumable} — order some", "buy me {purchase}", "get me a replacement {thing}", "restock the {consumable}", "order a new {thing}, the old one broke", "find and order {purchase}", "buy {purchase} — {price}", "pick up {consumable} this week", "reorder my usual {consumable}", "order {consumable} — {price}", ], "conversation": [ "how much did i spend on {category} last month?", "what's on my calendar {when}?", "remind me to {micro} {when}", "what did we decide about {decision}?", "what was {person}'s number again?", "when did i last {did}?", "what's the weather looking like {when}?", "how many {unit} did i log this week?", "did i already {did}?", "what's my {category} total so far?", "where did i save the {doc}?", ], } EXTRA = { "n": ["2", "3", "4", "6"], "cuisine": ["Italian", "Peruvian", "Thai", "Japanese", "Indian"], "provider": ["dentist", "GP", "haircut", "physio", "cleaner", "electrician", "vet"], "category": ["food", "transport", "subscriptions", "health", "shopping"], "micro": ["take my vitamins", "call the bank", "water the plants", "check the mail", "stretch"], "decision": ["the kitchen reno", "the Lisbon trip", "the car", "the apartment"], "did": ["backed up the photos", "refilled the water filter", "renewed the domain", "cleaned the coffee machine"], "unit": ["steps", "workouts", "pages", "kilometers"], "doc": ["lease", "insurance policy", "tax folder", "car manual"], "emotion": ["anxious", "sad", "frustrated", "lonely", "overwhelmed", "burnt out", "uneasy"], } FOLLOWUPS = { "diagnose": ["why?", "dig deeper", "so what's actually causing it?", "keep going", "check the logs then", "what else could it be?"], "research": ["go deeper on that", "what about the costs?", "find more sources", "which one wins in the end?", "keep going"], "make": ["make it shorter", "do it", "add a section on pricing", "version 2 please", "tweak the tone — warmer"], "arrange": ["yes, book it", "make it cheaper", "for 6 instead", "do it", "book the second one"], "acquire": ["order it", "the cheaper one", "yes go ahead", "do it"], "execute": ["do it", "continue", "what's next?", "yes, go ahead"], "tend": ["what should i change?", "keep going", "flag anything else?"], "learn": ["continue", "quiz me", "next lesson", "again from the top"], "companion": ["keep going", "i think you're right — go on", "that helps, continue"], "react": ["ok what do i do first?", "it's getting worse", "go", "help me now"], "conversation": ["continue", "and?", "why?", "what else?"], } # Hand-written boundary items — near-misses against adjacent shapes. HARD = [ ("diagnose", "why is my food spend double what it usually is?"), ("diagnose", "the categorization in my finance app has been wrong since Tuesday — why?"), ("diagnose", "why does my budget keep going negative in week three?"), ("diagnose", "my sleep score dropped off a cliff this month, what changed?"), ("diagnose", "why do my weekend runs feel so much harder than the weekday ones?"), ("diagnose", "why is the answer I get from the finance engine wrong for March?"), ("execute", "what do I need for renewing my passport?"), ("execute", "i've got the appointment — take me through the visa application"), ("execute", "walk me through filing the insurance claim step by step"), ("execute", "start the expense report, I'll send receipts as I find them"), ("execute", "the council form is open on my laptop, let's fill it out"), ("make", "make me a summary of what the literature says about creatine"), ("make", "write down what the options are for moving to Lisbon"), ("make", "draft the analysis of our spending for the month"), ("make", "put my findings about the heat pumps into a document"), ("tend", "how much did I spend on food last month?"), ("tend", "what's left on the renovation budget?"), ("tend", "what are my biggest spending categories?"), ("learn", "explain how compound interest works, in depth"), ("learn", "teach me about Portuguese history — a proper course, over the next weeks"), ("companion", "i hate my job"), ("companion", "work was rough today"), ("companion", "i don't know what to do about my job"), ("react", "urgent: we fly Saturday and the hotel says they lost the booking"), ("react", "renew my passport — I fly in three weeks"), ("arrange", "is Bali worth visiting in December?"), ("arrange", "where should I stay in Lisbon?"), ("acquire", "lease me an EV — find the best deal and sign me up"), ("acquire", "compare the top three EV lease deals and pick one, then get it"), ("conversation", "explain how TLS works"), ("conversation", "what's the capital of Peru?"), ("conversation", "remind me to renew my passport in June"), ("conversation", "set an alarm for 6:40 tomorrow"), ("conversation", "can you book me time to think about this? — no really, just reminding myself"), ("research", "should I switch to a MacBook?"), ("research", "what's the best mattress for back pain? actually compare a few for me properly"), ] def fill(tpl): out = tpl for k, v in SLOTS.items(): if "{" + k + "}" in out: out = out.replace("{" + k + "}", rng.choice(v)) for k, v in EXTRA.items(): if "{" + k + "}" in out: out = out.replace("{" + k + "}", rng.choice(v)) return out def main(): counts = {"diagnose": 320, "execute": 320, "make": 320, "research": 300, "learn": 260, "tend": 320, "companion": 260, "react": 220, "arrange": 200, "acquire": 280, "conversation": 340} items, seen = [], set() def add(state, label, src="synth"): key = state.lower()[:200] if key in seen: return False seen.add(key) items.append({"state": state, "label": label, "src": src, "id": f"syn-{label}-{len(items)}"}) return True for shape, n in counts.items(): made, guard = 0, 0 while made < n and guard < n * 80: guard += 1 if add(fill(rng.choice(T[shape])), shape): made += 1 # bounded continuation budget per shape: ~18%, capped at 55 cmade, cguard = 0, 0 ctarget = min(int(n * 0.18), 55) while cmade < ctarget and cguard < ctarget * 60: cguard += 1 priors = [i["state"] for i in items if i["label"] == shape and "\n" not in i["state"]] if not priors: break prior = rng.choice(priors) fu = rng.choice(FOLLOWUPS[shape]) if add(f"Earlier request: {prior}\nNew request: {fu}", shape, "synth-cont"): cmade += 1 print(f"{shape:<13} {made} + {cmade} cont") hard_added = 0 for shape, text in HARD: if add(text, shape, "hard"): hard_added += 1 print(f"hard items: {hard_added}") with open("corpus/synthetic.jsonl", "w") as fh: for it in items: fh.write(json.dumps(it) + "\n") print(f"total synthetic: {len(items)}") main()