QLoRA Fine-Tuning for Offline Structured Generation
Constrained Transformer Adaptation
Fine-tuned a 4-bit Qwen2.5-1.5B model with MLX QLoRA on synthetic structured-task examples. The base weights remained frozen while low-rank adapters updated 0.171% of parameters. A fixed benchmark, unchanged external smoke set, resource profiler, deterministic validator, and request-level trace made both gains and failure modes visible.
Challenge
A structured-generation workflow needed to run locally without depending on a network connection or a large inference service. The model had to fit a constrained compute budget, emit machine-readable output, and remain subordinate to deterministic safety and schema validation.
Solution
Fine-tuned a 4-bit Qwen2.5-1.5B model with MLX QLoRA on synthetic structured-task examples. The base weights remained frozen while low-rank adapters updated 0.171% of parameters. A fixed benchmark, unchanged external smoke set, resource profiler, deterministic validator, and request-level trace made both gains and failure modes visible.
Impact Metrics
Results
- • Improved the fixed held-out benchmark from 0/8 to 7/8 passing scenarios
- • Maintained 100% valid JSON on the held-out benchmark
- • Measured 1.18-second mean local inference and 1.78 GB peak memory
- • Preserved the weaker 1/6 unchanged external-template result as a documented generalization limitation
- • Added 12 smoke scenarios, 25 automated tests, and terminal plus JSONL request tracing
Business Impact
Demonstrates the full constrained-model loop: choose a small base model, adapt it with parameter-efficient training, measure latency and memory, evaluate task behavior, expose failure modes, and keep deterministic controls outside the model.
Architecture
Portfolio research project using synthetic scenarios and local compute. It is not a production edge deployment, and the unchanged external-template result is included to make the remaining generalization gap explicit.
Adapt, Measure, and Constrain
A proven approach combining statistical rigor, automation, and AWS best practices.
Define the Contract
Fix the structured output schema, scenario set, validator rules, and resource measurements before judging the tuned model.
Adapt Efficiently
Use 4-bit QLoRA so the frozen base model remains compact while a small set of low-rank adapter weights learns the task format.
Benchmark Behavior
Compare the base and tuned checkpoints on held-out scenarios, JSON validity, unchanged external templates, latency, memory, and artifact size.
Keep Rules Authoritative
Treat generated output as a proposal. Deterministic parsing and policy validation decide whether the system may accept it.
Scale & Scope
Technology Stack
- Qwen2.5-1.5B
- MLX and MLX-LM
- 4-bit QLoRA / LoRA adapters
- Python evaluation harness
- Deterministic JSON and policy validation
- JSONL observability
- Local browser workbench
Need a similar solution?
Let's replicate this success within your organization with a tailored engagement plan.