File size: 16,738 Bytes
40d31f1 | 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 | # 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.
|