# Side-by-side comparison: base vs SFT vs DPO v2 vs DPO v3 **Source:** `joshuasundance/mypo-training` → `alpaca-stripped-validation/alpaca-stripped-2026-04-23T005911Z/` **Eval job:** [`69e96eba2aa1660eaffa8d00`](https://huggingface.co/jobs/joshuasundance/69e96eba2aa1660eaffa8d00) **Sample size:** 30 stratified validation prompts (seed=42, 3 length buckets) **Decoding:** `batch_size=1`, no left-padding, `do_sample=False`, `max_new_tokens=384`, single-prompt through `tokenizer.apply_chat_template` as a normal user turn **Scaffold handling:** the Alpaca `### Instruction: / ### Input: / ### Output:` wrapper is stripped from the dataset prompt; the model sees only the bare natural-language instruction ## Aggregate results (n=30) | subject | parses | black | ruff | mypy --strict | ann_cov | |---|---:|---:|---:|---:|---:| | Qwen2.5-Coder-1.5B-Instruct (base) | 1.000 | 0.100 | 0.033 | **0.033** | 0.000 | | mypo-dpo-v2 (misconfigured run) | 1.000 | 0.100 | 0.033 | **0.033** | 0.000 | | mypo-sft | 1.000 | 0.967 | 0.633 | **0.767** | 0.970 | | mypo-dpo-v3 | 0.967 | 0.933 | 0.600 | **0.733** | 0.943 | **Key gap:** `dpo_v3 − base = +0.700` on mypy-strict pass rate. This gap survives removing the Alpaca prompt scaffold, ruling out "the model just learned to respond to `### Output:`". Compare with the previous Alpaca-wrapped single-prompt run (`single-prompt-2026-04-23T002137Z`): | subject | mypy (wrapped) | mypy (stripped) | delta | |---|---:|---:|---:| | base | 0.000 | 0.033 | +0.03 | | dpo-v2 | 0.000 | 0.033 | +0.03 | | sft | 0.733 | 0.767 | +0.03 | | dpo-v3 | 0.733 | 0.733 | 0.00 | Effect is robust to prompt shape. ## What changes between subjects - **Base and DPO v2 fail the same way:** wrap code in ` ```python ` fences, no type annotations, verbose prose preamble. DPO v2 is a misconfigured training run that wiped the SFT adapter's behavior — it behaves like the base model. - **SFT and DPO v3 both:** emit bare Python (no markdown fence), open with `from typing import …`, annotate parameters and return types, and satisfy `mypy --strict`. At n=30 the two are statistically indistinguishable on this slice; earlier batched n=150 showed SFT 0.853 vs v3 0.920 mypy-strict, but left-padded batched decoding inflates scores by ~19 pts so treat that with care. - **Trade-off on v3:** picks up a small regression in `parses` (one generation over-long) and `black` vs SFT; otherwise matches. ## Three concrete examples The three examples below are from indices 0, 8, 22 of the stratified sample (seed=42). In each, **base and dpo-v2 fail `mypy --strict`, sft and dpo-v3 pass**. All four outputs come from the exact same prompt, same decoding config, same machine (A10G-Large). ### Example 1: prompt `Build a Python program that identifies valid Leap Years.` **Prompt (bare instruction, no Alpaca scaffold):** ~~~~text Build a Python program that identifies valid Leap Years. ~~~~ **Qwen2.5-Coder-1.5B-Instruct (base)** — parses=pass black=fail ruff=pass mypy-strict=fail ann_cov=0.00 ~~~~text Sure! A leap year is a year that is divisible by 4 but not by 100 unless it is also divisible by 400. Here's a simple Python program to check if a given year is a leap year: ```python def is_leap_year(year): # Check if the year is divisible by 4 if year % 4 == 0: # If the year is divisible by 100, check if it is also divisible by 400 if year % 100 == 0: return year % 400 == 0 else: return True else: return False # Test the function with some examples print(is_leap_year(2000)) # Output: True print(is_leap_year(1900)) # Output: False print(is_leap_year(2020)) # Output: True print(is_leap_year(2021)) # Output: False ``` In this program, we define a function `is_leap_year` that takes a year as input and returns `True` if it is a leap year, otherwise `False`. The function first checks if the year is divisible by 4. If it is, it then checks if the year is divisible by 100. If the year is divisible by both 4 and 100, it further checks if the year is divisible by 400. If all these conditions are met, the function returns `True`, indicating that the year is a leap year. Otherwise, it returns `False`. We then test the function with some example years to verify its correctness. ~~~~ **mypo-dpo-v2 (broken run)** — parses=pass black=fail ruff=pass mypy-strict=fail ann_cov=0.00 ~~~~text Sure! A leap year is a year that is divisible by 4 but not by 100 unless it is also divisible by 400. Here's a simple Python program to check if a given year is a leap year: ```python def is_leap_year(year): # Check if the year is divisible by 4 if year % 4 == 0: # If the year is divisible by 100, check if it is also divisible by 400 if year % 100 == 0: return year % 400 == 0 else: return True else: return False # Test the function with some examples print(is_leap_year(2000)) # Output: True print(is_leap_year(1900)) # Output: False print(is_leap_year(2020)) # Output: True print(is_leap_year(2021)) # Output: False ``` In this program, we define a function `is_leap_year` that takes a year as input and returns `True` if it is a leap year, otherwise `False`. The function first checks if the year is divisible by 4. If it is, it then checks if the year is divisible by 100. If the year is divisible by both 4 and 100, it must also be divisible by 400 to be a leap year. Otherwise, it is not a leap year. Finally, we test the function with some example years to verify its correctness. ~~~~ **mypo-sft** — parses=pass black=pass ruff=pass mypy-strict=pass ann_cov=1.00 ~~~~text def is_leap(year: int) -> bool: if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0: return True else: return False # Test the function print(is_leap(2000)) # Output: True ~~~~ **mypo-dpo-v3** — parses=pass black=pass ruff=fail mypy-strict=pass ann_cov=1.00 ~~~~text from typing import Union def is_leap(year: int) -> bool: if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0): return True else: return False # Test the function print(is_leap(2000)) # Output: True ~~~~ ### Example 9: prompt `Develop a Python class to represent a point on 2D-space.` **Prompt (bare instruction, no Alpaca scaffold):** ~~~~text Develop a Python class to represent a point on 2D-space. ~~~~ **Qwen2.5-Coder-1.5B-Instruct (base)** — parses=pass black=fail ruff=pass mypy-strict=fail ann_cov=0.00 ~~~~text ```python class Point: def __init__(self, x=0, y=0): # Initialize the point with coordinates (x, y) self.x = x self.y = y def get_x(self): # Return the x-coordinate of the point return self.x def set_x(self, value): # Set the x-coordinate of the point self.x = value def get_y(self): # Return the y-coordinate of the point return self.y def set_y(self, value): # Set the y-coordinate of the point self.y = value def distance_to_origin(self): # Calculate and return the Euclidean distance from the point to the origin (0, 0) return (self.x**2 + self.y**2)**0.5 def move(self, dx, dy): # Move the point by the given displacement in both x and y directions self.x += dx self.y += dy def __str__(self): # Return a string representation of the point in the format "(x, y)" return f"({self.x}, {self.y})" ``` This Python class `Point` represents a point in 2D space with methods to initialize, retrieve, modify, calculate distances, and perform translations. The `__str__` method provides a readable string representation of the point. ~~~~ **mypo-dpo-v2 (broken run)** — parses=pass black=fail ruff=pass mypy-strict=fail ann_cov=0.00 ~~~~text ```python class Point: def __init__(self, x=0, y=0): # Initialize the point with coordinates (x, y) self.x = x self.y = y def get_x(self): # Return the x-coordinate of the point return self.x def set_x(self, value): # Set the x-coordinate of the point self.x = value def get_y(self): # Return the y-coordinate of the point return self.y def set_y(self, value): # Set the y-coordinate of the point self.y = value def distance_to_origin(self): # Calculate the Euclidean distance from the origin (0, 0) return (self.x**2 + self.y**2)**0.5 def move(self, dx, dy): # Move the point by dx units in the x-direction and dy units in the y-direction self.x += dx self.y += dy def __str__(self): # Return a string representation of the point return f"({self.x}, {self.y})" ``` This Python class `Point` represents a point in 2D space with attributes for its x and y coordinates. It includes methods to get and set these coordinates, calculate the distance from the origin, and move the point by specified amounts in the x and y directions. The `__str__` method provides a readable string representation of the point. ~~~~ **mypo-sft** — parses=pass black=pass ruff=pass mypy-strict=pass ann_cov=0.50 ~~~~text class Point: def __init__(self, x: float, y: float): self.x = x self.y = y def get_x(self) -> float: return self.x def get_y(self) -> float: return self.y ~~~~ **mypo-dpo-v3** — parses=pass black=pass ruff=pass mypy-strict=pass ann_cov=0.67 ~~~~text from typing import Tuple class Point: def __init__(self, x: float, y: float) -> None: self.x = x self.y = y def get_coordinates(self) -> Tuple[float, float]: return (self.x, self.y) ~~~~ ### Example 23: prompt `Create a Python program that reads in two strings and outputs the longest common` **Prompt (bare instruction, no Alpaca scaffold):** ~~~~text Create a Python program that reads in two strings and outputs the longest common substring. Input: str1 = "GeeksforGeeks" str2 = "Practice" ~~~~ **Qwen2.5-Coder-1.5B-Instruct (base)** — parses=pass black=fail ruff=pass mypy-strict=fail ann_cov=0.00 ~~~~text Here is a simple Python program to find the longest common substring between two strings: ```python def longest_common_substring(str1, str2): m = len(str1) n = len(str2) # Create a 2D array to store lengths of longest common suffixes L = [[0 for x in range(n+1)] for y in range(m+1)] # Build the table in bottom up manner for i in range(1, m+1): for j in range(1, n+1): if str1[i-1] == str2[j-1]: L[i][j] = L[i-1][j-1] + 1 else: L[i][j] = 0 # Find the length of the longest common substring max_length = 0 end_index = 0 for i in range(1, m+1): for j in range(1, n+1): if L[i][j] > max_length: max_length = L[i][j] end_index = i - 1 # Return the longest common substring return str1[end_index-max_length+1:end_index+1] # Test the function str1 = "GeeksforGeeks" str2 = "Practice" print(longest_common_substring(str1, str2)) ``` This program uses dynamic programming to build a 2D array `L` where `L[i][j]` represents the length of the longest common suffix of `str1[0..i-1]` and `str2[0..j-1]`. The algorithm then finds the maximum value in this array and returns the corresponding substring from `str1`. When you run this program with the input `" ~~~~ **mypo-dpo-v2 (broken run)** — parses=pass black=fail ruff=pass mypy-strict=fail ann_cov=0.00 ~~~~text Here is a simple Python program to find the longest common substring between two strings: ```python def longest_common_substring(str1, str2): m = len(str1) n = len(str2) # Create a 2D array to store lengths of longest common suffixes L = [[0 for x in range(n+1)] for y in range(m+1)] # Build the table in bottom up manner for i in range(1, m+1): for j in range(1, n+1): if str1[i-1] == str2[j-1]: L[i][j] = L[i-1][j-1] + 1 else: L[i][j] = 0 # Find the length of the longest common substring max_length = 0 end_index = 0 for i in range(1, m+1): for j in range(1, n+1): if L[i][j] > max_length: max_length = L[i][j] end_index = i - 1 # Return the longest common substring return str1[end_index-max_length+1:end_index+1] # Test the function str1 = "GeeksforGeeks" str2 = "Practice" print(longest_common_substring(str1, str2)) ``` This program uses dynamic programming to build a 2D array `L` where `L[i][j]` represents the length of the longest common suffix of `str1[0..i-1]` and `str2[0..j-1]`. The algorithm then finds the maximum value in this array and returns the corresponding substring from `str1`. When you run this program with the input `" ~~~~ **mypo-sft** — parses=pass black=pass ruff=pass mypy-strict=pass ann_cov=1.00 ~~~~text def longest_common_substring(str1: str, str2: str) -> str: m = len(str1) n = len(str2) # Create a table to store lengths of longest common suffixes dp = [[0 for _ in range(n + 1)] for _ in range(m + 1)] res_len = 0 res_end = 0 for i in range(1, m + 1): for j in range(1, n + 1): if str1[i - 1] == str2[j - 1]: dp[i][j] = dp[i - 1][j - 1] + 1 if dp[i][j] > res_len: res_len = dp[i][j] res_end = i else: dp[i][j] = 0 return str1[res_end - res_len : res_end] # Driver code str1 = "GeeksforGeeks" str2 = "Practice" print(longest_common_substring(str1, str2)) ~~~~ **mypo-dpo-v3** — parses=pass black=pass ruff=pass mypy-strict=pass ann_cov=1.00 ~~~~text from typing import List def longest_common_substring(str1: str, str2: str) -> str: m = len(str1) n = len(str2) # Create a table to store lengths of longest common suffixes dp: List[List[int]] = [[0 for _ in range(n + 1)] for _ in range(m + 1)] ans = "" max_length = 0 # Fill dp[][] in bottom up manner for i in range(1, m + 1): for j in range(1, n + 1): if str1[i - 1] == str2[j - 1]: dp[i][j] = dp[i - 1][j - 1] + 1 # Update answer if current substring is longer if dp[i][j] > max_length: start_index = i - dp[i][j] end_index = i max_length = dp[i][j] else: dp[i][j] = 0 # Extract the longest common substring from the dp array for i in range(start_index, end_index): ans += str1[i - 1] return ans # Driver code str1 = "GeeksforGeeks" str2 = "Practice" print(longest_common_substring(str1, str2)) ~~~~ ## Reproducing this Scripts in the `mypo-training` repo: - Dataset prefix inspection (`dataset-inspection/2026-04-22/`): `hf jobs uv run --flavor cpu-upgrade --secrets HF_TOKEN .copilot_tmp/dataset_prefix_inspection.py` - Alpaca-stripped validation (this file): `hf jobs uv run --flavor a10g-large --timeout 60m --secrets HF_TOKEN .copilot_tmp/alpaca_stripped_validation.py --sample-size 30` - Prior single-prompt (Alpaca-wrapped) validation: `hf jobs uv run --flavor a10g-large --timeout 60m --secrets HF_TOKEN .copilot_tmp/single_prompt_validation.py --sample-size 30` ## Honest caveats - **n=30** is small. 95 % Wilson interval for a 0.733 pass rate with n=30 is roughly [0.55, 0.86]. - The dataset is heavily biased: 99.8 % of `chosen` training rows have a type annotation vs 2.8 % of `rejected` (`dataset-inspection/2026-04-22/summary.json`). So the improvement shown is specifically on "produce type-annotated Python for Alpaca-style toy prompts". It has NOT been tested on HumanEval+, MBPP, or any real codebase task. - `ruff` pass rates around 0.60 for SFT/v3 mean both trained models still emit code that would trigger lint warnings (unused imports, etc.). "Passes mypy --strict" is the narrow strong claim; "lint-clean" is not. - DPO v2 is kept public as a worked example of a failed training run and is not recommended for use.