Qwen3.5-4B CadQuery SFT (MLX)
Four LoRA checkpoints for generating CadQuery Python programs from text descriptions. Each folder contains MLX adapter weights and their configuration. The base model weights are downloaded separately.
| Folder | Epochs | Optimizer steps |
|---|---|---|
epoch-0.5 |
0.5 | 145 |
epoch-1.0 |
1.0 | 290 |
epoch-1.5 |
1.5 | 435 |
epoch-2.0 |
2.0 | 580 |
The adapters were trained with MLX-LM 0.32.2 on 4,654 examples from CAD-Coder, using rank 32 and LoRA scale 2.0 across all 32 layers. The 2.0-epoch adapter is the last training checkpoint.
Small dev evaluations
The 1.5-epoch checkpoint is the provisional pick for the post-SFT pilot. Each checkpoint had one greedy generation per prompt, with thinking disabled and a 1,536-token limit. A pass required an executable, valid solid and volumetric intersection over union (IoU) of at least 0.70 in the requested coordinate frame. No alignment or retries were applied. The strict threshold was 0.90 IoU.
| Checkpoint | Initial dev sample (8 prompts) | Fresh paired retest (16 prompts) | Retest mean IoU |
|---|---|---|---|
| 0.5 epochs | 5/8 | — | — |
| 1.0 epoch | 7/8 | — | — |
| 1.5 epochs | 8/8 | 16/16 | 0.9960 |
| 2.0 epochs | 8/8 | 15/16 | 0.9329 |
The strict scores matched the reported pass counts on both samples. The fresh sample excluded the original eight prompts. These results cover 24 dev prompts for each finalist, with no base-model comparison or locked-test results.
What differed in the retest
- Prism orientation: The 2.0-epoch program used a different pair of rotation axes, producing a valid solid with zero volume overlap. Replacing only the prism rotations with the reference rotations restored IoU from 0.000 to 1.000.
- Cylinder placement: The 2.0-epoch program added a sketch-center offset before rotating the cylinder. Removing that offset matched the 1.5-epoch program and raised IoU from 0.9313 to 0.9408. Both outputs passed the strict threshold.
Load an adapter on Apple Silicon
from pathlib import Path
from huggingface_hub import snapshot_download
from mlx_lm import generate, load
checkpoint = "epoch-1.5"
repo = snapshot_download(
"adikal-25/qwen3.5-4b-cadquery-sft-mlx",
allow_patterns=f"{checkpoint}/*",
)
model, tokenizer = load(
"Qwen/Qwen3.5-4B",
revision="851bf6e806efd8d0a36b00ddf55e13ccb7b8cd0a",
adapter_path=str(Path(repo) / checkpoint),
)
prompt = tokenizer.apply_chat_template(
[
{"role": "system", "content": 'You write CadQuery (Python) programs that build 3D CAD parts from text descriptions. Reply with exactly one ```python code block and nothing else. The program must `import cadquery as cq` and assign the final solid to a variable named `result`. Use the exact coordinates and dimensions given in the description; do not rescale or recenter the part.'},
{"role": "user", "content": "Build a 20 × 12 × 4 mm block centered at the origin."},
],
tokenize=False,
add_generation_prompt=True,
enable_thinking=False,
)
print(generate(model, tokenizer, prompt=prompt, max_tokens=1536))