Download command_data.py from ElderRyan/lispm-llm: direct link, hf CLI and curl.
- Browser
- Download file 31.8 kB
-
https://huggingface.co/ElderRyan/lispm-llm/resolve/main/command_data.py
- Command line
-
hf download hf://ElderRyan/lispm-llm/command_data.py
-
curl -L -o command_data.py https://huggingface.co/ElderRyan/lispm-llm/resolve/main/command_data.py
31.8 kB
| """Deterministic synthetic intent examples with separate calibration phrasing. | |
| The dataset teaches intent labels, not Lisp syntax. NAME is a placeholder for | |
| one separately parsed buffer name, file path, or search string. Original benchmark paraphrases are excluded | |
| even when embedded in a polite wrapper. Calibration templates are written | |
| separately from training templates and are not generated by a random row split. | |
| """ | |
| import re | |
| from actions import ActionKind | |
| from expanded_data import ( | |
| CALIBRATION_FAMILIES as EXPANDED_CALIBRATION_FAMILIES, | |
| CALIBRATION_REJECT_MIGRATIONS, | |
| CALIBRATION_REJECT_REWRITES, | |
| CALIBRATION_REJECTS as EXPANDED_CALIBRATION_REJECTS, | |
| TRAINING_FAMILIES as EXPANDED_TRAINING_FAMILIES, | |
| TRAINING_REJECT_MIGRATIONS, | |
| TRAINING_REJECTS as EXPANDED_TRAINING_REJECTS, | |
| ) | |
| import lispm_data | |
| import contrastive_data | |
| REJECT = "reject" | |
| ORIGINAL_PARAPHRASES = [ | |
| "put a new window on the right", | |
| "put a new window below", | |
| "switch focus to the next window", | |
| "close every other window", | |
| "give the windows equal sizes", | |
| "take me to the top of the buffer", | |
| "take me to the bottom of the buffer", | |
| "display the buffer named NAME", | |
| ] | |
| _TRAINING_FAMILIES = { | |
| ActionKind.SPLIT_RIGHT.value: ( | |
| "split right", | |
| "split the window to the right", | |
| "make a pane on the right", | |
| "split this window to the right", | |
| "split the current window on the right", | |
| "split the active pane to its right", | |
| "split this pane on the right side", | |
| "create a window to the right", | |
| "create another pane on the right", | |
| "create a new right hand pane", | |
| "add a window on the right", | |
| "add another window to the right of this one", | |
| "add a pane to the right of the current pane", | |
| "make another window to my right", | |
| "make a new pane to the right of this window", | |
| "open a window on the right", | |
| "open another pane to the right", | |
| "open a new right side window", | |
| "divide the window with a new pane on the right", | |
| "divide this pane into side by side windows", | |
| "split this window into two adjacent panes", | |
| "make two windows side by side", | |
| "make a rightward window split", | |
| "split the selected window rightwards", | |
| "on the right create another window", | |
| "to the right add a new pane", | |
| "on this window right side make a pane", | |
| "give me a pane to the right", | |
| "give me another window on the right side", | |
| "put an additional pane on the right", | |
| "put a second window to the right of this one", | |
| "create a side by side split with the new window on the right", | |
| ), | |
| ActionKind.SPLIT_BELOW.value: ( | |
| "split below", | |
| "split the window below", | |
| "make a pane below", | |
| "split this window below", | |
| "split the current window underneath", | |
| "split the active pane below it", | |
| "split this pane on the bottom side", | |
| "create a window below", | |
| "create another pane underneath", | |
| "create a new lower pane", | |
| "add a window below this one", | |
| "add another window underneath this window", | |
| "add a pane below the current pane", | |
| "make another window underneath me", | |
| "make a new pane below this window", | |
| "open a window below", | |
| "open another pane underneath", | |
| "open a new bottom window", | |
| "divide the window with a new pane below", | |
| "divide this pane into stacked windows", | |
| "split this window into two stacked panes", | |
| "make two windows one above the other", | |
| "make a downward window split", | |
| "split the selected window downwards", | |
| "below this window create another window", | |
| "underneath add a new pane", | |
| "at the bottom of this window make a pane", | |
| "give me a pane below this one", | |
| "give me another window underneath", | |
| "put an additional pane below", | |
| "put a second window underneath this one", | |
| "create a stacked split with the new window below", | |
| ), | |
| ActionKind.NEXT_WINDOW.value: ( | |
| "select the next window", | |
| "focus the next pane", | |
| "move to the next window", | |
| "switch to the next window", | |
| "switch to the next pane", | |
| "go to the next window", | |
| "go to the next pane", | |
| "select the following window", | |
| "select the following pane", | |
| "focus the following window", | |
| "focus the next window", | |
| "activate the next pane", | |
| "activate the next window", | |
| "move focus to the next pane", | |
| "move focus to the following window", | |
| "move the cursor to the next window", | |
| "cycle to the next window", | |
| "cycle forward through the windows", | |
| "cycle forward to another pane", | |
| "advance to the next window", | |
| "advance to the following pane", | |
| "advance window focus by one", | |
| "change focus to the next window", | |
| "change the active window to the next one", | |
| "choose the next pane", | |
| "choose the next window", | |
| "make the next pane active", | |
| "bring the next window into focus", | |
| "give the next pane focus", | |
| "put focus in the next window", | |
| "next window", | |
| "next pane", | |
| ), | |
| ActionKind.KEEP_WINDOW.value: ( | |
| "keep only this window", | |
| "close the other panes", | |
| "maximize this window", | |
| "keep only the current window", | |
| "keep only the active pane", | |
| "keep this pane by closing the others", | |
| "keep the selected window only", | |
| "leave only this window", | |
| "leave only the current pane", | |
| "leave the active window open by closing the others", | |
| "close all other windows", | |
| "close all other panes", | |
| "close the windows other than this one", | |
| "close all panes other than the current pane", | |
| "delete the other windows", | |
| "delete all other panes", | |
| "remove all other windows", | |
| "remove the other panes", | |
| "remove every pane other than this one", | |
| "maximize the current window", | |
| "maximize the active pane", | |
| "expand this window to fill the frame", | |
| "expand the selected pane to the whole frame", | |
| "make this the only window", | |
| "make the current pane the only pane", | |
| "make this window fill the frame", | |
| "show only the active window", | |
| "show just this pane", | |
| "use a single window keeping this one", | |
| "reduce the layout to the current pane", | |
| "keep this window by removing all its siblings", | |
| "give all the frame space to the current window", | |
| ), | |
| ActionKind.BALANCE_WINDOWS.value: ( | |
| "balance the windows", | |
| "equalize pane sizes", | |
| "make all panes equal", | |
| "balance all windows", | |
| "balance all panes", | |
| "balance the pane layout", | |
| "equalize the windows", | |
| "equalize all window sizes", | |
| "equalize the dimensions of the panes", | |
| "make the windows the same size", | |
| "make all windows equally sized", | |
| "make every pane the same size", | |
| "make pane sizes equal", | |
| "make window sizes match", | |
| "resize all panes equally", | |
| "resize the windows to equal sizes", | |
| "resize every window to the same size", | |
| "distribute space equally between windows", | |
| "distribute space evenly across panes", | |
| "share the frame evenly among the windows", | |
| "even out the window sizes", | |
| "even out the pane sizes", | |
| "evenly size all the windows", | |
| "arrange the panes with equal sizes", | |
| "arrange the windows evenly", | |
| "set all pane sizes equal", | |
| "set equal sizes for all windows", | |
| "give each pane the same amount of space", | |
| "give all windows an equal share of the frame", | |
| "adjust the panes to equal sizes", | |
| "restore equal window sizes", | |
| "balance windows", | |
| ), | |
| ActionKind.BUFFER_START.value: ( | |
| "go to buffer start", | |
| "jump to the beginning", | |
| "move to the top", | |
| "go to the start of the buffer", | |
| "go to the beginning of this buffer", | |
| "go to the top of the current buffer", | |
| "jump to buffer start", | |
| "jump to the beginning of the buffer", | |
| "jump to the top of this buffer", | |
| "move to the start of the current buffer", | |
| "move to the beginning of this buffer", | |
| "move to the top of the buffer", | |
| "move point to buffer start", | |
| "move point to the beginning of the buffer", | |
| "move the cursor to the start of this buffer", | |
| "move the cursor to the very beginning", | |
| "put the cursor at the beginning of the buffer", | |
| "put point at the start of the buffer", | |
| "position the cursor at buffer start", | |
| "position point at the beginning", | |
| "navigate to the start of the buffer", | |
| "navigate to the top of the buffer", | |
| "take me to buffer start", | |
| "take the cursor to the beginning", | |
| "return to the beginning of the buffer", | |
| "return to buffer start", | |
| "beginning of buffer", | |
| "top of the buffer", | |
| "start of this buffer", | |
| "go to the first character of the buffer", | |
| "move to the very first position in the buffer", | |
| "jump all the way to the top", | |
| ), | |
| ActionKind.BUFFER_END.value: ( | |
| "go to buffer end", | |
| "jump to the end", | |
| "move to the bottom", | |
| "go to the end of the buffer", | |
| "go to the end of this buffer", | |
| "go to the bottom of the current buffer", | |
| "jump to buffer end", | |
| "jump to the end of the buffer", | |
| "jump to the bottom of this buffer", | |
| "move to the end of the current buffer", | |
| "move to the end of this buffer", | |
| "move to the bottom of the buffer", | |
| "move point to buffer end", | |
| "move point to the end of the buffer", | |
| "move the cursor to the end of this buffer", | |
| "move the cursor to the very end", | |
| "put the cursor at the end of the buffer", | |
| "put point at the end of the buffer", | |
| "position the cursor at buffer end", | |
| "position point at the end", | |
| "navigate to the end of the buffer", | |
| "navigate to the bottom of the buffer", | |
| "take me to buffer end", | |
| "take the cursor to the end", | |
| "return to the end of the buffer", | |
| "return to buffer end", | |
| "end of buffer", | |
| "bottom of the buffer", | |
| "end of this buffer", | |
| "go past the last character of the buffer", | |
| "move to the final position in the buffer", | |
| "jump all the way to the bottom", | |
| ), | |
| ActionKind.SWITCH_BUFFER.value: ( | |
| "switch to buffer NAME", | |
| "show buffer NAME", | |
| "visit the buffer NAME", | |
| "switch to the buffer NAME", | |
| "switch to NAME", | |
| "switch the current buffer to NAME", | |
| "show the buffer NAME", | |
| "show NAME", | |
| "show the buffer called NAME", | |
| "show the buffer with the name NAME", | |
| "display buffer NAME", | |
| "display the buffer NAME", | |
| "display NAME", | |
| "display the buffer called NAME", | |
| "visit buffer NAME", | |
| "visit NAME", | |
| "open buffer NAME", | |
| "open the buffer NAME", | |
| "open the buffer called NAME", | |
| "select buffer NAME", | |
| "select the buffer NAME", | |
| "select the buffer named NAME", | |
| "activate buffer NAME", | |
| "activate the buffer called NAME", | |
| "change to buffer NAME", | |
| "change the current buffer to NAME", | |
| "bring up buffer NAME", | |
| "bring NAME into view", | |
| "bring the buffer NAME to the front", | |
| "make buffer NAME current", | |
| "make NAME the selected buffer", | |
| "in this window show buffer NAME", | |
| ), | |
| } | |
| _REJECT_FAMILIES = ( | |
| # Selecting or moving a directional window does not create a new window. | |
| "focus right", "focus left", "focus above", "focus below", | |
| "select the right window", "select the left window", | |
| "select the upper pane", "select the lower pane", | |
| "switch to the window on the right", "switch to the window below", | |
| "go to the right pane", "go to the pane above", | |
| "move focus to the left", "move focus down", "move focus up", | |
| "move the window to the right", "move this pane below the other one", | |
| "swap the left and right windows", "swap the top and bottom panes", | |
| "rotate the windows", "reorder the panes", | |
| # Unsupported direction, unspecified split, or repeated/simultaneous intent. | |
| "split left", "split above", "split the window to the left", | |
| "create a window above", "make a pane on the left", | |
| "add another pane above this one", "open a window on the left", | |
| "split window", "split the window", "split this pane", "split", | |
| "make a window", "create another pane", "add a new window", | |
| "split right twice", "split below three times", "make three panes", | |
| "create four windows on the right", "split right below", | |
| "split the right window", "split the bottom pane", | |
| # Next-window intent is distinct from previous or specific targets. | |
| "select the previous window", "focus the previous pane", | |
| "move to the previous window", "cycle backward through the windows", | |
| "go back to the last pane", "activate the first window", | |
| "select the second pane", "select the last window", | |
| "skip the next window", "advance two windows", "focus another window", | |
| "next buffer", "show the next buffer", "switch to the previous buffer", | |
| "select the next tab", "switch to the next frame", | |
| # Deleting the current/target buffer or window is not keeping the current one. | |
| "close this window", "close the current pane", "delete the active window", | |
| "remove this pane", "close all windows", "close every pane", | |
| "close the next window", "delete the previous pane", | |
| "keep the next window", "keep the left pane", "keep both windows", | |
| "maximize other window", "maximize the next pane", "maximize all windows", | |
| "minimize this window", "hide the current pane", "close the buffer", | |
| "delete the buffer", "kill the current buffer", "close buffer NAME", | |
| "delete buffer NAME", "kill buffer NAME", "close the buffer called NAME", | |
| # Fixed-size resizing or an unequal layout is not balancing. | |
| "make this window wider", "make the current pane narrower", | |
| "make this pane taller", "make the active window shorter", | |
| "enlarge this window", "shrink the current pane", | |
| "resize the window", "resize this pane to half the frame", | |
| "set the window width to eighty columns", "set the pane height to ten lines", | |
| "increase the width by one column", "decrease the height by two lines", | |
| "give the right window more space", "give the top pane less space", | |
| "balance only the current buffer", "make all buffers equal", | |
| "give the windows different sizes", "make the panes unequal", | |
| # Motion target distinctions: line, word, visible area, middle, search. | |
| "go to the start of the line", "go to the end of the line", | |
| "move to line beginning", "move to line end", | |
| "jump to the first word", "jump to the last word", | |
| "go to buffer middle", "move to the middle of the buffer", | |
| "move the cursor one line down", "move the cursor one character right", | |
| "go to the top of the visible window", "go to the bottom of the screen", | |
| "scroll to the top", "scroll to the bottom", "scroll down one page", | |
| "go to line fifty", "jump to line ten", "go to the next paragraph", | |
| "select the buffer contents", "delete everything in the buffer", | |
| "insert text at buffer start", "append text to the end of the buffer", | |
| "search for NAME", "find NAME in this buffer", | |
| # File/metadata operations must not turn into switch-to-buffer. | |
| "open file NAME", "open the file NAME", "visit file NAME", | |
| "read the file NAME", "find file NAME", "load file NAME", | |
| "save the buffer", "save buffer NAME", "save file NAME", | |
| "write the buffer to NAME", "rename the buffer NAME", | |
| "rename buffer NAME", "delete file NAME", "create file NAME", | |
| "create directory NAME", "open directory NAME", "show folder NAME", | |
| "show the contents of file NAME", "show all buffers", "list the buffers", | |
| "list open windows", "show the buffer list", "show window NAME", | |
| "open terminal NAME", "run command NAME", "execute NAME", | |
| "change the buffer name to NAME", "copy buffer NAME", | |
| # Incomplete arguments, conflicting targets, and out-of-domain requests. | |
| "show buffer", "switch to buffer", "visit the buffer", "display the buffer", | |
| "select the buffer named", "switch to", "show", "move to", "go to", | |
| "right", "below", "start", "end", "top", "bottom", "window", "buffer", | |
| "NAME", "NAME buffer", "NAME window", "name the buffer", | |
| "go to the top bottom of the buffer", "select the next previous window", | |
| "make panes equal unequal", "split right or below", | |
| "hello", "hello world", "good morning", "thank you", "help me", | |
| "what time is it", "tell me a joke", "calculate the total", | |
| "explain the code", "install a package", "undo the last change", | |
| "redo the edit", "quit emacs", "restart the editor", | |
| "unicorns frobnicate", "purple banana windows", "wibble wobble", | |
| "flarble the snorg", "zqxv blorp", "pane banana buffer", | |
| "do not split right", "never close the other panes", "do nothing", | |
| ) | |
| _CALIBRATION_FAMILIES = { | |
| ActionKind.SPLIT_RIGHT.value: ( | |
| "divide this window so the added pane is on its right", | |
| "create a companion pane to the right of this one", | |
| "make room for another window on the right side", | |
| "put an extra pane to the right of the active window", | |
| "give this window a new neighbour on the right", | |
| "open an additional window beside this one on its right", | |
| ), | |
| ActionKind.SPLIT_BELOW.value: ( | |
| "divide this window so the added pane is underneath it", | |
| "create a companion pane below this one", | |
| "make room for another window under the active pane", | |
| "put an extra pane underneath the selected window", | |
| "give this window a new neighbour below it", | |
| "open an additional window beneath this one", | |
| ), | |
| ActionKind.NEXT_WINDOW.value: ( | |
| "activate the window following this one", | |
| "give focus to the succeeding pane", | |
| "make the next window active", | |
| "continue to the next pane in window order", | |
| "move window selection ahead by one", | |
| "hand focus to the next window", | |
| ), | |
| ActionKind.KEEP_WINDOW.value: ( | |
| "leave the selected window as the sole pane", | |
| "remove all panes apart from the selected one", | |
| "give the entire frame to this window", | |
| "retain the active pane alone", | |
| "close its siblings so this pane stays", | |
| "let this window occupy the whole frame", | |
| ), | |
| ActionKind.BALANCE_WINDOWS.value: ( | |
| "allocate equal space to all existing panes", | |
| "adjust every window to have matching sizes", | |
| "distribute frame space evenly among its windows", | |
| "make the panes occupy equal portions of the frame", | |
| "normalize the dimensions of the windows", | |
| "use an even layout for the existing panes", | |
| ), | |
| ActionKind.BUFFER_START.value: ( | |
| "place point at the earliest position in this buffer", | |
| "navigate to where the current buffer begins", | |
| "set point to the first position of the active buffer", | |
| "head to the very top of the current buffer", | |
| "start at the beginning of the active buffer", | |
| "reposition the cursor at the buffer beginning", | |
| ), | |
| ActionKind.BUFFER_END.value: ( | |
| "place point at the final position in this buffer", | |
| "navigate to where the current buffer ends", | |
| "set point past the last character of the active buffer", | |
| "head to the very bottom of the current buffer", | |
| "finish at the end of the active buffer", | |
| "reposition the cursor at the buffer end", | |
| ), | |
| ActionKind.SWITCH_BUFFER.value: ( | |
| "make NAME the active buffer", | |
| "use NAME as the current buffer", | |
| "bring the buffer called NAME into view", | |
| "put buffer NAME into the selected window", | |
| "turn attention to the buffer with name NAME", | |
| "change the displayed buffer to NAME", | |
| ), | |
| } | |
| _CALIBRATION_REJECTS = ( | |
| "move the selected pane to the right", | |
| "give focus to the window immediately to the right", | |
| "rearrange this window beside the other one", | |
| "activate the rightmost pane", | |
| "put the current window on the left side", | |
| "create an additional pane above this window", | |
| "send the current window downward", | |
| "select the pane underneath the active one", | |
| "focus the bottommost window", | |
| "move the lower window upward", | |
| "create an extra pane without choosing a direction", | |
| "divide this window into three equal panes", | |
| "hand focus to the preceding window", | |
| "move window selection back by one", | |
| "advance to the next open buffer", | |
| "continue to the next application", | |
| "activate the third pane in window order", | |
| "move forward by two panes", | |
| "remove the selected window and keep the rest", | |
| "leave the rightmost window as the sole pane", | |
| "close the active pane alone", | |
| "remove every window in the frame", | |
| "hide all windows temporarily", | |
| "discard the buffer called NAME", | |
| "allocate more space to the current pane", | |
| "make the right pane twice as wide", | |
| "reduce this window to five lines high", | |
| "set unequal proportions for the windows", | |
| "normalize indentation in this buffer", | |
| "balance the parentheses in the buffer", | |
| "place point at the earliest position in this line", | |
| "navigate to the beginning of the next paragraph", | |
| "set point to the first position of the selected word", | |
| "head to the topmost visible text", | |
| "reposition the cursor in the middle of the buffer", | |
| "highlight everything from the beginning of the buffer", | |
| "place point at the final position in this line", | |
| "navigate to the end of the current sentence", | |
| "set point past the last character of the selected word", | |
| "head to the bottom of the visible screen", | |
| "delete text until the end of the buffer", | |
| "insert a new line at the buffer end", | |
| "use NAME as the new name for this buffer", | |
| "bring the file called NAME into the editor", | |
| "put buffer contents into the file NAME", | |
| "change the directory to NAME", | |
| "make NAME the active color theme", | |
| "display documentation for NAME", | |
| ) | |
| _TRAINING_WRAPPERS = ( | |
| "{}", "please {}", "could you {}", "can you {}", | |
| "i would like you to {}", "{} please", | |
| ) | |
| _CALIBRATION_WRAPPERS = ("{}", "would you please {}") | |
| _WINDOW_WORDS = re.compile(r"\b(?:window|windows|pane|panes)\b") | |
| _CURRENT_WORDS = re.compile(r"\b(?:current|active|selected)\b") | |
| def _normalized(phrase): | |
| return " ".join(phrase.casefold().split()) | |
| def _synonym_variants(phrase): | |
| """Apply the same small label-preserving vocabulary substitutions to all labels.""" | |
| nouns = [phrase] | |
| for singular, plural in (("window", "windows"), ("pane", "panes")): | |
| nouns.append(_WINDOW_WORDS.sub( | |
| lambda match: plural if match.group().endswith("s") else singular, | |
| phrase, | |
| )) | |
| variants = [] | |
| for text in dict.fromkeys(nouns): | |
| variants.append(text) | |
| variants.extend(_CURRENT_WORDS.sub(word, text) | |
| for word in ("current", "active", "selected")) | |
| return tuple(dict.fromkeys(variants)) | |
| def _augment_training(authored, calibration_keys, forbidden): | |
| """Add systematic variants while preserving the separately authored holdouts.""" | |
| rows = list(authored) | |
| seen = {_normalized(phrase): label for phrase, label in authored} | |
| for phrase, label in authored: | |
| for variant in _synonym_variants(phrase): | |
| key = _normalized(variant) | |
| previous = seen.get(key) | |
| if previous is not None and previous != label: | |
| raise ValueError(f"Synonym expansion produced contradictory labels: {variant!r}.") | |
| if previous is not None: | |
| continue | |
| if key in calibration_keys or any(original in key for original in forbidden): | |
| continue | |
| if previous is None: | |
| rows.append((variant, label)) | |
| seen[key] = label | |
| return rows | |
| def _expand(families, rejects, positive_wrappers, reject_wrappers): | |
| rows = [] | |
| seen = {} | |
| sources = [ | |
| (label, phrases, positive_wrappers) | |
| for label, phrases in families.items() | |
| ] + [(REJECT, rejects, reject_wrappers)] | |
| for label, phrases, wrappers in sources: | |
| for phrase in phrases: | |
| for wrapper in wrappers: | |
| text = wrapper.format(phrase) | |
| key = _normalized(text) | |
| previous = seen.get(key) | |
| if previous is not None and previous != label: | |
| raise ValueError(f"Contradictory labels for {text!r}.") | |
| if previous is None: | |
| rows.append((text, label)) | |
| seen[key] = label | |
| return rows | |
| def _expanded_families(core, additions, rejects, migrations, rewrites=None): | |
| """Migrate newly supported old negatives before adding new action families.""" | |
| rewrites = rewrites or {} | |
| if set(migrations) - set(rejects): | |
| raise ValueError("A reject migration refers to a nonexistent source phrase.") | |
| if set(rewrites) - set(migrations): | |
| raise ValueError("Only explicitly migrated reject phrases can be rewritten.") | |
| families = {label: tuple(phrases) for label, phrases in core.items()} | |
| for label, phrases in additions.items(): | |
| if label in families: | |
| raise ValueError(f"An expanded action duplicates a core label: {label!r}.") | |
| families[label] = tuple(phrases) | |
| for phrase, label in migrations.items(): | |
| if label not in families: | |
| raise ValueError(f"A reject migration names an unsupported label: {label!r}.") | |
| families[label] += (rewrites.get(phrase, phrase),) | |
| remaining = tuple(phrase for phrase in rejects if phrase not in migrations) | |
| return families, remaining | |
| def _build_splits(): | |
| training_families, training_rejects = _expanded_families( | |
| _TRAINING_FAMILIES, EXPANDED_TRAINING_FAMILIES, _REJECT_FAMILIES, | |
| TRAINING_REJECT_MIGRATIONS, | |
| ) | |
| calibration_families, calibration_rejects = _expanded_families( | |
| _CALIBRATION_FAMILIES, EXPANDED_CALIBRATION_FAMILIES, _CALIBRATION_REJECTS, | |
| CALIBRATION_REJECT_MIGRATIONS, CALIBRATION_REJECT_REWRITES, | |
| ) | |
| training_rejects += EXPANDED_TRAINING_REJECTS | |
| calibration_rejects += EXPANDED_CALIBRATION_REJECTS | |
| training_families, training_rejects = _expanded_families( | |
| training_families, lispm_data.TRAINING_FAMILIES, training_rejects, | |
| lispm_data.TRAINING_REJECT_MIGRATIONS, | |
| ) | |
| calibration_families, calibration_rejects = _expanded_families( | |
| calibration_families, lispm_data.CALIBRATION_FAMILIES, calibration_rejects, | |
| lispm_data.CALIBRATION_REJECT_MIGRATIONS, | |
| ) | |
| training_rejects += lispm_data.TRAINING_REJECTS | |
| calibration_rejects += lispm_data.CALIBRATION_REJECTS | |
| train = _expand(training_families, training_rejects, | |
| _TRAINING_WRAPPERS, _TRAINING_WRAPPERS) | |
| calibration = _expand(calibration_families, calibration_rejects, | |
| _CALIBRATION_WRAPPERS, _CALIBRATION_WRAPPERS) | |
| train_keys = {_normalized(phrase) for phrase, _ in train} | |
| calibration_keys = {_normalized(phrase) for phrase, _ in calibration} | |
| if train_keys & calibration_keys: | |
| raise ValueError("Training and calibration phrases overlap.") | |
| forbidden = tuple(_normalized(phrase) for phrase in ORIGINAL_PARAPHRASES) | |
| for phrase, _ in train + calibration: | |
| normalized = _normalized(phrase) | |
| if any(original in normalized for original in forbidden): | |
| raise ValueError(f"Original benchmark phrase leaked into data: {phrase!r}.") | |
| calibration_bases = tuple( | |
| _normalized(phrase) | |
| for phrases in list(calibration_families.values()) + [calibration_rejects] | |
| for phrase in phrases | |
| ) | |
| # A wrapped copy of a calibration base would still reveal its entire phrasing. | |
| return _augment_training(train, calibration_keys, forbidden + calibration_bases), calibration | |
| def _merge_consistent(rows): | |
| """Deduplicate normalized phrases without silently overwriting their labels.""" | |
| result, seen = [], {} | |
| for phrase, label in rows: | |
| key = _normalized(phrase) | |
| if key in seen and seen[key] != label: | |
| raise ValueError(f'Conflicting contrastive label for {phrase!r}.') | |
| if key not in seen: | |
| result.append((phrase, label)) | |
| seen[key] = label | |
| return result | |
| def _extend_splits(base_train, base_calibration): | |
| """Append disjoint contrastive examples and retain the original calibration prefix. | |
| Every new calibration base and polite wrapper is excluded from training. | |
| Keeping the original subset intact gives model selection a common coverage | |
| reference, rather than changing the denominator when adding hard cases. | |
| """ | |
| added_train = _expand(contrastive_data.TRAINING_FAMILIES, contrastive_data.TRAINING_REJECTS, | |
| _TRAINING_WRAPPERS, _TRAINING_WRAPPERS) | |
| added_calibration = _expand(contrastive_data.CALIBRATION_FAMILIES, | |
| contrastive_data.CALIBRATION_REJECTS, | |
| _CALIBRATION_WRAPPERS, _CALIBRATION_WRAPPERS) | |
| calibration = _merge_consistent(base_calibration + added_calibration) | |
| calibration_keys = {_normalized(phrase) for phrase, _ in calibration} | |
| new_bases = tuple(_normalized(phrase) for phrases in | |
| list(contrastive_data.CALIBRATION_FAMILIES.values()) | |
| + [contrastive_data.CALIBRATION_REJECTS] for phrase in phrases) | |
| originals = tuple(_normalized(phrase) for phrase in ORIGINAL_PARAPHRASES) | |
| forbidden = tuple(_normalized(phrase) for phrase, _ in base_calibration) + new_bases + originals | |
| train = _merge_consistent(base_train + added_train) | |
| train = [(phrase, label) for phrase, label in train | |
| if _normalized(phrase) not in calibration_keys | |
| and not any(base in _normalized(phrase) for base in new_bases + originals)] | |
| train = _augment_training(train, calibration_keys, forbidden) | |
| return train, calibration | |
| # Immutable historical splits anchor fair before/after coverage comparisons. | |
| _BASE_TRAINING_ROWS, _BASE_CALIBRATION_ROWS = _build_splits() | |
| # Current training/model-selection data; independent test files are never read. | |
| _TRAINING_ROWS, _CALIBRATION_ROWS = _extend_splits(_BASE_TRAINING_ROWS, _BASE_CALIBRATION_ROWS) | |
| def training_rows(include_contrastive=True) -> list[tuple[str, str]]: | |
| """Return a fresh list of reproducible training phrases and intent labels.""" | |
| return list(_TRAINING_ROWS if include_contrastive else _BASE_TRAINING_ROWS) | |
| def calibration_rows(include_contrastive=True) -> list[tuple[str, str]]: | |
| """Return disjoint phrasing families reserved for threshold calibration.""" | |
| return list(_CALIBRATION_ROWS if include_contrastive else _BASE_CALIBRATION_ROWS) | |
| def hard_training_rows() -> list[tuple[str, str]]: | |
| """Return authored operation contrasts that survived all holdout exclusions.""" | |
| admitted = set(_TRAINING_ROWS) | |
| return [row for row in contrastive_data.HARD_TRAINING_ROWS if row in admitted] | |