ranjanrajib commited on
Commit
ec114db
·
verified ·
1 Parent(s): e2d7367

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +249 -182
README.md CHANGED
@@ -23,60 +23,18 @@ tags:
23
  - parameter-efficient-fine-tuning
24
  ---
25
 
26
- \---
27
 
28
- language:
29
-
30
- \- en
31
-
32
- license: apache-2.0
33
-
34
- library_name: transformers
35
-
36
- pipeline_tag: text-generation
37
-
38
- base_model:
39
-
40
- \- Qwen/Qwen2.5-Coder-7B-Instruct
41
-
42
- datasets:
43
-
44
- \- bigcode/bigcodebench
45
-
46
- \- Muennighoff/mbpp
47
-
48
- \- openai/openai_humaneval
49
-
50
- tags:
51
-
52
- \- qwen2.5
53
-
54
- \- qwen
55
-
56
- \- code-generation
57
-
58
- \- python
59
-
60
- \- python-code-generation
61
 
62
- \- dpo
63
-
64
- \- direct-preference-optimization
65
-
66
- \- preference-learning
67
-
68
- \- lora
69
-
70
- \- parameter-efficient-fine-tuning
71
-
72
- \---
73
- # Qwen2.5-Coder-7B-Instruct — DPO Fine-Tuned for Python## Model at a Glance
74
  This model is a ****Python-focused, DPO fine-tuned version of Qwen2.5-Coder-7B-Instruct****, designed to improve the model's ability to generate ****functionally correct Python code****.
75
 
76
  The model was trained using ****Direct Preference Optimization (DPO)**** with automatically constructed preference pairs. Candidate Python solutions were generated for programming problems and evaluated by executing them against unit tests. Solutions that passed the required tests were used as preferred examples, while solutions that failed tests were used as rejected examples.
77
 
78
  The resulting model was evaluated against the original Qwen2.5-Coder-7B-Instruct model on held-out programming problems.
79
- ### What changed?
 
 
80
  The base model:
81
 
82
  ****Qwen2.5-Coder-7B-Instruct****
@@ -87,28 +45,32 @@ was fine-tuned using:
87
 
88
  The resulting model demonstrates improved coding performance on the evaluated held-out benchmark:
89
 
90
- | Metric | Qwen2.5-Coder-7B-Instruct | DPO Model | Improvement |
91
 
92
- | ----------------------- | ------------------------: | ---------: | -----------: |
93
 
94
- | Pass@1 | 41.87% | ****45.22%**** | ****+3.35 pp**** |
95
 
96
- | Pass@5 | 48.87% | ****51.10%**** | ****+2.23 pp**** |
97
 
98
- | Pass@10 | 50.99% | ****53.16%**** | ****+2.17 pp**** |
99
 
100
- | Tests passed per answer | 66.20% | ****69.41%**** | ****+3.21 pp**** |
101
 
102
  The primary result is the improvement in ****Pass@1****, meaning that a single generated solution was more likely to produce a correct solution on the evaluated programming problems.
103
 
104
  The model also showed improved Pass@5, Pass@10, and partial test coverage.
105
 
106
- ---
107
 
108
  ****Base model:**** \`Qwen/Qwen2.5-Coder-7B-Instruct\` at snapshot
109
 
110
- \`c03e6d358207e414f1eca0bb1891e29f1db0e242\`. The merge was performed against exactly these weights.
111
- ## Downloading and using### The merged model (what most people want)
 
 
 
 
112
  \`\`\`python
113
 
114
  from transformers import AutoModelForCausalLM, AutoTokenizer
@@ -136,7 +98,9 @@ Or fetch the files without loading them (~14 GB, four shards):
136
  hf download ranjanrajib/DPO-trained-Qwen2.5-Coder-7B --exclude "adapter/*" --local-dir ./d4
137
 
138
  \`\`\`
139
- ### The LoRA adapter only (308 MB)
 
 
140
  The adapter lives in \`adapter/\`. Applying it to the base model gives the same result as the
141
 
142
  merged weights, at a fraction of the download.
@@ -169,24 +133,11 @@ model = PeftModel.from_pretrained(
169
 
170
  \`\`\`
171
 
172
- ---
173
-
174
- **# ## VRAM Requirements
175
-
176
- The base model and the merged trained model use the same VRAM. The merge changes weight values, not tensor shapes: both models have the same 7.6B parameters and architecture, so the model weights occupy the same amount of bf16 memory.
177
 
178
- | Component | bf16 VRAM |
179
- | --- | ---: |
180
- | Weights (base or merged D4) | 14.19 GiB |
181
- | KV cache, per token | 56 KiB |
182
- | Activations / workspace | ~0.5–1 GiB |
183
- | **Practical single-stream total** | **~15–16 GiB** |
184
 
185
- ---
186
-
187
- Why Use This Model?**
188
-
189
- If your primary use case is ****Python code generation****, this model is intended to be a stronger alternative to the original Qwen2.5-Coder-7B-Instruct model based on the evaluation performed in this project.
190
 
191
  It is particularly relevant for users who want to:
192
 
@@ -210,8 +161,10 @@ It was to encourage the model toward ****solutions that work****.
210
 
211
  The preference data therefore used actual program execution and unit-test results rather than subjective judgments about whether generated code **looked** correct.
212
 
213
- ---
214
- # How Is It Different From Qwen2.5-Coder-7B-Instruct?
 
 
215
  The underlying model architecture and capabilities come from ****Qwen2.5-Coder-7B-Instruct****.
216
 
217
  This model adds a preference-optimization stage on top of that model.
@@ -275,85 +228,121 @@ Qwen2.5-Coder-7B-Instruct
275
  \`\`\`
276
 
277
  The goal is to shift the model toward coding behaviors associated with solutions that successfully execute against the available tests.
278
- ### Important distinction
 
 
279
  This is ****not a new foundation model****.
280
 
281
  It is a parameter-efficient fine-tuned adapter for Qwen2.5-Coder-7B-Instruct.
282
 
283
  The base model remains unchanged.
284
 
285
- ---
286
- # What Kind of Model Is This?### Primary task
 
 
 
 
287
  ****Python code generation****
288
- ### Model family
 
 
289
  Qwen2.5-Coder
290
- ### Base model
 
 
291
  \`Qwen/Qwen2.5-Coder-7B-Instruct\`
292
- ### Fine-tuning
 
 
293
  Direct Preference Optimization (DPO)
294
- ### Parameter-efficient method
 
 
295
  LoRA
296
- ### Precision
 
 
297
  bfloat16
298
- ### Quantization
 
 
299
  None
300
- ### Model size
 
 
301
  7.7B-parameter base model
302
- ### Adapter
 
 
303
  Approximately 80.7M trainable parameters
304
 
305
- ---
306
- # Performance
 
 
307
  The model was evaluated against the original Qwen2.5-Coder-7B-Instruct using a controlled benchmark consisting of 508 held-out BigCodeBench programming problems.
308
 
309
  The same prompts, generation settings, random seeds, number of samples, and grading procedure were used for both models.
310
- ## Pass@k
311
- | Metric | Base Model | DPO Model |
312
 
313
- | ------- | ---------: | ---------: |
314
 
315
- | Pass@1 | 41.87% | ****45.22%**** |
316
 
317
- | Pass@5 | 48.87% | ****51.10%**** |
318
 
319
- | Pass@10 | 50.99% | ****53.16%**** |
 
 
 
 
320
 
321
  The improvement in Pass@1 is approximately ****3.35 percentage points****.
322
- ## Partial Correctness
 
 
323
  The average proportion of tests passed by each generated answer increased from:
324
 
325
  ****66.20% → 69.41%****
326
 
327
  This is a secondary metric intended to provide additional information about functional correctness beyond binary problem-level pass/fail.
328
 
329
- ---
330
- # Paired Problem-Level Analysis
 
 
331
  The evaluation used the same 508 problems for both models, allowing direct comparison of model behavior on individual problems.
332
 
333
  For the first generated answer:
334
 
335
- | Base → DPO | Problems |
336
 
337
- | --------------------- | -------: |
338
 
339
- | Correct → Correct | 186 |
340
 
341
- | Correct → Incorrect | 17 |
342
 
343
- | Incorrect → Correct | 41 |
344
 
345
- | Incorrect → Incorrect | 264 |
346
 
347
  The DPO model converted 41 problems from incorrect to correct while 17 previously correct problems became incorrect.
348
 
349
  This provides additional evidence that the aggregate improvement is associated with meaningful changes in problem-level behavior rather than simply differences in the evaluated problem sets.
350
 
351
- ---
352
- # Who Should Use This Model?
 
 
353
  This model is most appropriate for:
354
- ### Python Developers
 
 
355
  Developers interested in experimenting with a locally hosted code-generation model that has been specifically fine-tuned toward execution-validated solutions.
356
- ### AI/ML Researchers
 
 
357
  Researchers studying:
358
 
359
  * DPO
@@ -369,7 +358,9 @@ Researchers studying:
369
  * execution-based evaluation
370
 
371
  * parameter-efficient fine-tuning
372
- ### LLM Evaluation Researchers
 
 
373
  The model can also be useful as an experimental model for comparing:
374
 
375
  * base versus preference-tuned models
@@ -382,8 +373,10 @@ The model can also be useful as an experimental model for comparing:
382
 
383
  * preference-learning behavior
384
 
385
- ---
386
- # When Should You Prefer the Original Qwen Model?
 
 
387
  This model should not automatically be considered better for every possible task.
388
 
389
  The experiment specifically focused on ****Python code generation****.
@@ -394,7 +387,7 @@ The reported improvement should therefore be interpreted as:
394
 
395
  \> ****Improved performance on the evaluated Python coding benchmark, not a guarantee of improvement across every coding or general-purpose task.****
396
 
397
- ---
398
 
399
  The base model and the trained model use the same VRAM.
400
 
@@ -424,8 +417,10 @@ architecture — so they are byte-for-byte the same size.
424
 
425
  └───────────────────────────────┴────────────┘
426
 
427
- ---
428
- # Model Architecture and Training
 
 
429
  The model starts from:
430
 
431
  \`Qwen/Qwen2.5-Coder-7B-Instruct\`
@@ -438,8 +433,12 @@ The resulting adapter contains approximately 80.7 million trainable parameters.
438
 
439
  The adapter is approximately 308 MB.
440
 
441
- ---
442
- # DPO Training## Why DPO?
 
 
 
 
443
  Direct Preference Optimization provides a method for optimizing a language model directly from preference pairs without requiring a separate reward-model training stage.
444
 
445
  For this experiment, a preference pair has the form:
@@ -460,8 +459,10 @@ Problem
460
 
461
  DPO then learns to increase the relative likelihood of the chosen response compared with the rejected response.
462
 
463
- ---
464
- # Preference Data Construction
 
 
465
  The preference dataset was generated specifically for this experiment.
466
 
467
  It was constructed from programming problems drawn from:
@@ -473,16 +474,18 @@ It was constructed from programming problems drawn from:
473
  * HumanEval
474
 
475
  * handwritten programming problems
476
- ### Training Data
477
- | Dataset | License |
478
 
479
- | ------------ | ---------- |
 
 
480
 
481
- | BigCodeBench | Apache 2.0 |
482
 
483
- | MBPP | CC BY 4.0 |
484
 
485
- | HumanEval | MIT |
 
 
486
 
487
  Candidate solutions were generated automatically.
488
 
@@ -504,8 +507,10 @@ Every candidate was then executed in a Docker sandbox against the associated uni
504
 
505
  The resulting execution outcome was used to construct chosen/rejected preference pairs.
506
 
507
- ---
508
- # Preference Dataset
 
 
509
  After filtering and deduplication:
510
 
511
  * 1,326 preference pairs
@@ -526,34 +531,58 @@ No external LLM was used as a preference judge.
526
 
527
  The preference signal was generated from objective unit-test execution.
528
 
529
- ---
530
- # DPO Configuration
 
 
531
  The primary DPO configuration was:
532
 
533
- | Parameter | Value |
534
- | --- | --- |
535
- | Rank | 32 |
536
- | Alpha | 64 |
537
- | Dropout | 0.05 |
538
- | Target modules | Attention and MLP projections |
539
- | Epochs | 2 |
540
- | Maximum sequence length | 1,024 |
541
- | Batch size | 4 |
542
- | Gradient accumulation | 4 |
543
- | Effective batch size | 16 |
544
- | Optimizer | AdamW |
545
- | Gradient clipping | 1.0 |
546
- | Gradient checkpointing | Enabled |
547
- ## LoRA Configuration
548
- | Parameter | Value |
549
- | --- | --- |
550
- | Rank | 32 |
551
- | Alpha | 64 |
552
- | Dropout | 0.05 |
553
- | Target modules | Attention and MLP projections |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
554
 
555
- ---
556
- # Training Hardware
557
  DPO training was performed on:
558
 
559
  ****NVIDIA RTX A6000 — 48 GB VRAM****
@@ -570,8 +599,10 @@ Training environment:
570
 
571
  Peak GPU memory consumption was approximately 33.4 GiB.
572
 
573
- ---
574
- # Evaluation Methodology
 
 
575
  The primary evaluation benchmark consisted of:
576
 
577
  ****508 BigCodeBench programming problems****
@@ -579,7 +610,9 @@ The primary evaluation benchmark consisted of:
579
  The evaluation problems were reserved separately from the preference-training pool.
580
 
581
  The same generation and grading procedure was applied to both models.
582
- ### Generation
 
 
583
  * 10 answers per problem
584
 
585
  * temperature: 0.2
@@ -593,22 +626,26 @@ The same generation and grading procedure was applied to both models.
593
  * sampling enabled
594
 
595
  * identical random seeds for base and DPO models
596
- ### Pass@k
 
 
597
  Pass@k was calculated using the standard unbiased estimator based on the number of correct samples among the generated candidates.
598
 
599
- ---
600
- # Preference-Learning Diagnostics
 
 
601
  The DPO training objective produced a strong preference signal on the training examples.
602
 
603
  However, the validation results were substantially weaker.
604
 
605
- | Metric | Training | Validation |
606
 
607
- | ------------------- | -------: | --------------------: |
608
 
609
- | Preference accuracy | ~84.4% | ~45.8% |
610
 
611
- | Reward margin | Positive | Approximately neutral |
612
 
613
  This indicates that the explicit preference signal learned during training did not generalize strongly to the validation preference examples.
614
 
@@ -616,8 +653,10 @@ At the same time, downstream coding performance improved on the held-out benchma
616
 
617
  This is an important observation from the experiment.
618
 
619
- ---
620
- # What Does This Mean?
 
 
621
  The results should not be interpreted as proof that the model learned a broadly generalized notion of code quality.
622
 
623
  Instead, they suggest that ****optimizing an automatically constructed preference objective can improve downstream coding performance even when explicit preference metrics show weak validation generalization.****
@@ -634,34 +673,48 @@ Several explanations are possible, including:
634
 
635
  These are hypotheses for further investigation rather than established conclusions.
636
 
637
- ---
638
- # Important Limitations## No Human Preference Evaluation
 
 
 
 
639
  No human preference study was performed.
640
 
641
  The preference signal was derived from automated unit-test execution.
642
 
643
  Therefore, this model should not be described as being aligned to human preferences based on this experiment.
644
- ## Unit Tests Are Imperfect
 
 
645
  Passing the available tests does not guarantee that a solution is universally correct.
646
 
647
  A test suite may fail to cover some edge cases or undesirable implementation behavior.
648
- ## Benchmark Source Overlap
 
 
649
  The evaluation problems were held out at the problem level.
650
 
651
  However, the preference-training data includes other BigCodeBench problems.
652
 
653
  Therefore, the evaluation is ****problem-held-out****, but not completely source-family-disjoint.
654
- ## Python Focus
 
 
655
  The primary objective and evaluation were focused on Python programming.
656
 
657
  Performance should not be assumed to generalize to other programming languages without additional evaluation.
658
- ## Experimental Model
 
 
659
  This is an experimental research model.
660
 
661
  Users should evaluate it against their own workloads before using it in production.
662
 
663
- ---
664
- # Reproducibility
 
 
665
  The experiment documents:
666
 
667
  * base model
@@ -690,8 +743,10 @@ The experiment documents:
690
 
691
  The objective is to make the experiment sufficiently transparent for others to reproduce, extend, or critique.
692
 
693
- ---
694
- # Independent Research Project
 
 
695
  This model was developed as an ****independent, out-of-office AI/ML research project****.
696
 
697
  The project was conceived, designed, implemented, trained, evaluated, analyzed, and released independently.
@@ -732,18 +787,22 @@ Model Release
732
 
733
  \`\`\`
734
 
735
- ---
736
- # Model Release
 
 
737
  The trained LoRA adapter and technical documentation are available here:
738
 
739
  ****Hugging Face:****
740
 
741
  https://huggingface.co/ranjanrajib/DPO-trained-Qwen2.5-Coder-7B
742
 
743
- The repository contains the model adapter and documentation required to understand the training methodology, evaluation, results, intended use, and limitations.
 
 
 
 
744
 
745
- ---
746
- # Licensing and Attribution
747
  The model is derived from:
748
 
749
  \`Qwen/Qwen2.5-Coder-7B-Instruct\`
@@ -754,12 +813,16 @@ The preference-generation pipeline used programming problems from BigCodeBench,
754
 
755
  The respective dataset licenses and attribution requirements should be observed when using or redistributing material derived from those datasets.
756
 
757
- ---
758
- # Citation
 
 
759
  If you use this model or the experimental methodology in your work, please cite the original Qwen2.5-Coder model and the relevant datasets used in the experiment.
760
 
761
- ---
762
- # Summary
 
 
763
  ****What is this?****
764
 
765
  A Python-focused DPO fine-tuned version of Qwen2.5-Coder-7B-Instruct.
@@ -787,7 +850,11 @@ A LoRA adapter that can be loaded on top of \`Qwen/Qwen2.5-Coder-7B-Instruct\`.
787
  ****Why is the experiment interesting?****
788
 
789
  The model improved downstream coding performance even though explicit preference metrics showed weak validation generalization, highlighting the distinction between optimizing a preference objective and improving downstream model capability.
790
- ## Licence and attribution
 
 
 
 
791
  Apache-2.0, inherited from \`Qwen/Qwen2.5-Coder-7B-Instruct\`. This is a modified derivative of that
792
 
793
  model; the original is by the Qwen team at Alibaba Cloud. The preference data was generated from the
 
23
  - parameter-efficient-fine-tuning
24
  ---
25
 
26
+ # Qwen2.5-Coder-7B-Instruct — DPO Fine-Tuned for Python**
27
 
28
+ **## Model at a Glance**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  This model is a ****Python-focused, DPO fine-tuned version of Qwen2.5-Coder-7B-Instruct****, designed to improve the model's ability to generate ****functionally correct Python code****.
31
 
32
  The model was trained using ****Direct Preference Optimization (DPO)**** with automatically constructed preference pairs. Candidate Python solutions were generated for programming problems and evaluated by executing them against unit tests. Solutions that passed the required tests were used as preferred examples, while solutions that failed tests were used as rejected examples.
33
 
34
  The resulting model was evaluated against the original Qwen2.5-Coder-7B-Instruct model on held-out programming problems.
35
+
36
+ **### What changed?**
37
+
38
  The base model:
39
 
40
  ****Qwen2.5-Coder-7B-Instruct****
 
45
 
46
  The resulting model demonstrates improved coding performance on the evaluated held-out benchmark:
47
 
48
+ \| Metric | Qwen2.5-Coder-7B-Instruct | DPO Model | Improvement |
49
 
50
+ \| ----------------------- | ------------------------: | ---------: | -----------: |
51
 
52
+ \| Pass@1 | 41.87% | ****45.22%**** | ****+3.35 pp**** |
53
 
54
+ \| Pass@5 | 48.87% | ****51.10%**** | ****+2.23 pp**** |
55
 
56
+ \| Pass@10 | 50.99% | ****53.16%**** | ****+2.17 pp**** |
57
 
58
+ \| Tests passed per answer | 66.20% | ****69.41%**** | ****+3.21 pp**** |
59
 
60
  The primary result is the improvement in ****Pass@1****, meaning that a single generated solution was more likely to produce a correct solution on the evaluated programming problems.
61
 
62
  The model also showed improved Pass@5, Pass@10, and partial test coverage.
63
 
64
+ **---**
65
 
66
  ****Base model:**** \`Qwen/Qwen2.5-Coder-7B-Instruct\` at snapshot
67
 
68
+ \`c03e6d358207e414f1eca0bb1891e29f1db0e242\`. The adapter was trained against exactly these weights.
69
+
70
+ **## Downloading and using**
71
+
72
+ **### The LoRA adapter (recommended release)**
73
+
74
  \`\`\`python
75
 
76
  from transformers import AutoModelForCausalLM, AutoTokenizer
 
98
  hf download ranjanrajib/DPO-trained-Qwen2.5-Coder-7B --exclude "adapter/*" --local-dir ./d4
99
 
100
  \`\`\`
101
+
102
+ **### The LoRA adapter only (308 MB)**
103
+
104
  The adapter lives in \`adapter/\`. Applying it to the base model gives the same result as the
105
 
106
  merged weights, at a fraction of the download.
 
133
 
134
  \`\`\`
135
 
136
+ **---**
 
 
 
 
137
 
138
+ **# Why Use This Model?**
 
 
 
 
 
139
 
140
+ If your primary use case is ****Python code generation****, this model is intended as an experimental alternative to the original Qwen2.5-Coder-7B-Instruct model, with higher measured performance on the held-out benchmark used in this project.
 
 
 
 
141
 
142
  It is particularly relevant for users who want to:
143
 
 
161
 
162
  The preference data therefore used actual program execution and unit-test results rather than subjective judgments about whether generated code **looked** correct.
163
 
164
+ **---**
165
+
166
+ **# How Is It Different From Qwen2.5-Coder-7B-Instruct?**
167
+
168
  The underlying model architecture and capabilities come from ****Qwen2.5-Coder-7B-Instruct****.
169
 
170
  This model adds a preference-optimization stage on top of that model.
 
228
  \`\`\`
229
 
230
  The goal is to shift the model toward coding behaviors associated with solutions that successfully execute against the available tests.
231
+
232
+ **### Important distinction**
233
+
234
  This is ****not a new foundation model****.
235
 
236
  It is a parameter-efficient fine-tuned adapter for Qwen2.5-Coder-7B-Instruct.
237
 
238
  The base model remains unchanged.
239
 
240
+ **---**
241
+
242
+ **# What Kind of Model Is This?**
243
+
244
+ **### Primary task**
245
+
246
  ****Python code generation****
247
+
248
+ **### Model family**
249
+
250
  Qwen2.5-Coder
251
+
252
+ **### Base model**
253
+
254
  \`Qwen/Qwen2.5-Coder-7B-Instruct\`
255
+
256
+ **### Fine-tuning**
257
+
258
  Direct Preference Optimization (DPO)
259
+
260
+ **### Parameter-efficient method**
261
+
262
  LoRA
263
+
264
+ **### Precision**
265
+
266
  bfloat16
267
+
268
+ **### Quantization**
269
+
270
  None
271
+
272
+ **### Model size**
273
+
274
  7.7B-parameter base model
275
+
276
+ **### Adapter**
277
+
278
  Approximately 80.7M trainable parameters
279
 
280
+ **---**
281
+
282
+ **# Performance**
283
+
284
  The model was evaluated against the original Qwen2.5-Coder-7B-Instruct using a controlled benchmark consisting of 508 held-out BigCodeBench programming problems.
285
 
286
  The same prompts, generation settings, random seeds, number of samples, and grading procedure were used for both models.
 
 
287
 
288
+ **## Pass@k**
289
 
290
+ \| Metric | Base Model | DPO Model |
291
 
292
+ \| ------- | ---------: | ---------: |
293
 
294
+ \| Pass@1 | 41.87% | ****45.22%**** |
295
+
296
+ \| Pass@5 | 48.87% | ****51.10%**** |
297
+
298
+ \| Pass@10 | 50.99% | ****53.16%**** |
299
 
300
  The improvement in Pass@1 is approximately ****3.35 percentage points****.
301
+
302
+ **## Partial Correctness**
303
+
304
  The average proportion of tests passed by each generated answer increased from:
305
 
306
  ****66.20% → 69.41%****
307
 
308
  This is a secondary metric intended to provide additional information about functional correctness beyond binary problem-level pass/fail.
309
 
310
+ **---**
311
+
312
+ **# Paired Problem-Level Analysis**
313
+
314
  The evaluation used the same 508 problems for both models, allowing direct comparison of model behavior on individual problems.
315
 
316
  For the first generated answer:
317
 
318
+ \| Base → DPO | Problems |
319
 
320
+ \| --------------------- | -------: |
321
 
322
+ \| Correct → Correct | 186 |
323
 
324
+ \| Correct → Incorrect | 17 |
325
 
326
+ \| Incorrect → Correct | 41 |
327
 
328
+ \| Incorrect → Incorrect | 264 |
329
 
330
  The DPO model converted 41 problems from incorrect to correct while 17 previously correct problems became incorrect.
331
 
332
  This provides additional evidence that the aggregate improvement is associated with meaningful changes in problem-level behavior rather than simply differences in the evaluated problem sets.
333
 
334
+ **---**
335
+
336
+ **# Who Should Use This Model?**
337
+
338
  This model is most appropriate for:
339
+
340
+ **### Python Developers**
341
+
342
  Developers interested in experimenting with a locally hosted code-generation model that has been specifically fine-tuned toward execution-validated solutions.
343
+
344
+ **### AI/ML Researchers**
345
+
346
  Researchers studying:
347
 
348
  * DPO
 
358
  * execution-based evaluation
359
 
360
  * parameter-efficient fine-tuning
361
+
362
+ **### LLM Evaluation Researchers**
363
+
364
  The model can also be useful as an experimental model for comparing:
365
 
366
  * base versus preference-tuned models
 
373
 
374
  * preference-learning behavior
375
 
376
+ **---**
377
+
378
+ **# When Should You Prefer the Original Qwen Model?**
379
+
380
  This model should not automatically be considered better for every possible task.
381
 
382
  The experiment specifically focused on ****Python code generation****.
 
387
 
388
  \> ****Improved performance on the evaluated Python coding benchmark, not a guarantee of improvement across every coding or general-purpose task.****
389
 
390
+ **---**
391
 
392
  The base model and the trained model use the same VRAM.
393
 
 
417
 
418
  └───────────────────────────────┴────────────┘
419
 
420
+ **---**
421
+
422
+ **# Model Architecture and Training**
423
+
424
  The model starts from:
425
 
426
  \`Qwen/Qwen2.5-Coder-7B-Instruct\`
 
433
 
434
  The adapter is approximately 308 MB.
435
 
436
+ **---**
437
+
438
+ **# DPO Training**
439
+
440
+ **## Why DPO?**
441
+
442
  Direct Preference Optimization provides a method for optimizing a language model directly from preference pairs without requiring a separate reward-model training stage.
443
 
444
  For this experiment, a preference pair has the form:
 
459
 
460
  DPO then learns to increase the relative likelihood of the chosen response compared with the rejected response.
461
 
462
+ **---**
463
+
464
+ **# Preference Data Construction**
465
+
466
  The preference dataset was generated specifically for this experiment.
467
 
468
  It was constructed from programming problems drawn from:
 
474
  * HumanEval
475
 
476
  * handwritten programming problems
 
 
477
 
478
+ **### Training Data**
479
+
480
+ \| Dataset | License |
481
 
482
+ \| ------------ | ---------- |
483
 
484
+ \| BigCodeBench | Apache 2.0 |
485
 
486
+ \| MBPP | CC BY 4.0 |
487
+
488
+ \| HumanEval | MIT |
489
 
490
  Candidate solutions were generated automatically.
491
 
 
507
 
508
  The resulting execution outcome was used to construct chosen/rejected preference pairs.
509
 
510
+ **---**
511
+
512
+ **# Preference Dataset**
513
+
514
  After filtering and deduplication:
515
 
516
  * 1,326 preference pairs
 
531
 
532
  The preference signal was generated from objective unit-test execution.
533
 
534
+ **---**
535
+
536
+ **# DPO Configuration**
537
+
538
  The primary DPO configuration was:
539
 
540
+ \| Parameter | Value |
541
+
542
+ \| ----------------------- | ------- |
543
+
544
+ \| DPO beta | 0.1 |
545
+
546
+ \| Learning rate | 1e-5 |
547
+
548
+ \| Scheduler | Cosine |
549
+
550
+ \| Warmup | 5% |
551
+
552
+ \| Epochs | 2 |
553
+
554
+ \| Maximum sequence length | 1,024 |
555
+
556
+ \| Batch size | 4 |
557
+
558
+ \| Gradient accumulation | 4 |
559
+
560
+ \| Effective batch size | 16 |
561
+
562
+ \| Optimizer | AdamW |
563
+
564
+ \| Gradient clipping | 1.0 |
565
+
566
+ \| Gradient checkpointing | Enabled |
567
+
568
+ **## LoRA Configuration**
569
+
570
+ \| Parameter | Value |
571
+
572
+ \| -------------- | ----------------------------- |
573
+
574
+ \| Rank | 32 |
575
+
576
+ \| Alpha | 64 |
577
+
578
+ \| Dropout | 0.05 |
579
+
580
+ \| Target modules | Attention and MLP projections |
581
+
582
+ **---**
583
+
584
+ **# Training Hardware**
585
 
 
 
586
  DPO training was performed on:
587
 
588
  ****NVIDIA RTX A6000 — 48 GB VRAM****
 
599
 
600
  Peak GPU memory consumption was approximately 33.4 GiB.
601
 
602
+ **---**
603
+
604
+ **# Evaluation Methodology**
605
+
606
  The primary evaluation benchmark consisted of:
607
 
608
  ****508 BigCodeBench programming problems****
 
610
  The evaluation problems were reserved separately from the preference-training pool.
611
 
612
  The same generation and grading procedure was applied to both models.
613
+
614
+ **### Generation**
615
+
616
  * 10 answers per problem
617
 
618
  * temperature: 0.2
 
626
  * sampling enabled
627
 
628
  * identical random seeds for base and DPO models
629
+
630
+ **### Pass@k**
631
+
632
  Pass@k was calculated using the standard unbiased estimator based on the number of correct samples among the generated candidates.
633
 
634
+ **---**
635
+
636
+ **# Preference-Learning Diagnostics**
637
+
638
  The DPO training objective produced a strong preference signal on the training examples.
639
 
640
  However, the validation results were substantially weaker.
641
 
642
+ \| Metric | Training | Validation |
643
 
644
+ \| ------------------- | -------: | --------------------: |
645
 
646
+ \| Preference accuracy | ~84.4% | ~45.8% |
647
 
648
+ \| Reward margin | Positive | Approximately neutral |
649
 
650
  This indicates that the explicit preference signal learned during training did not generalize strongly to the validation preference examples.
651
 
 
653
 
654
  This is an important observation from the experiment.
655
 
656
+ **---**
657
+
658
+ **# What Does This Mean?**
659
+
660
  The results should not be interpreted as proof that the model learned a broadly generalized notion of code quality.
661
 
662
  Instead, they suggest that ****optimizing an automatically constructed preference objective can improve downstream coding performance even when explicit preference metrics show weak validation generalization.****
 
673
 
674
  These are hypotheses for further investigation rather than established conclusions.
675
 
676
+ **---**
677
+
678
+ **# Important Limitations**
679
+
680
+ **## No Human Preference Evaluation**
681
+
682
  No human preference study was performed.
683
 
684
  The preference signal was derived from automated unit-test execution.
685
 
686
  Therefore, this model should not be described as being aligned to human preferences based on this experiment.
687
+
688
+ **## Unit Tests Are Imperfect**
689
+
690
  Passing the available tests does not guarantee that a solution is universally correct.
691
 
692
  A test suite may fail to cover some edge cases or undesirable implementation behavior.
693
+
694
+ **## Benchmark Source Overlap**
695
+
696
  The evaluation problems were held out at the problem level.
697
 
698
  However, the preference-training data includes other BigCodeBench problems.
699
 
700
  Therefore, the evaluation is ****problem-held-out****, but not completely source-family-disjoint.
701
+
702
+ **## Python Focus**
703
+
704
  The primary objective and evaluation were focused on Python programming.
705
 
706
  Performance should not be assumed to generalize to other programming languages without additional evaluation.
707
+
708
+ **## Experimental Model**
709
+
710
  This is an experimental research model.
711
 
712
  Users should evaluate it against their own workloads before using it in production.
713
 
714
+ **---**
715
+
716
+ **# Reproducibility**
717
+
718
  The experiment documents:
719
 
720
  * base model
 
743
 
744
  The objective is to make the experiment sufficiently transparent for others to reproduce, extend, or critique.
745
 
746
+ **---**
747
+
748
+ **# Independent Research Project**
749
+
750
  This model was developed as an ****independent, out-of-office AI/ML research project****.
751
 
752
  The project was conceived, designed, implemented, trained, evaluated, analyzed, and released independently.
 
787
 
788
  \`\`\`
789
 
790
+ **---**
791
+
792
+ **# Model Release**
793
+
794
  The trained LoRA adapter and technical documentation are available here:
795
 
796
  ****Hugging Face:****
797
 
798
  https://huggingface.co/ranjanrajib/DPO-trained-Qwen2.5-Coder-7B
799
 
800
+ The repository contains the LoRA adapter and documentation required to understand the training methodology, evaluation, results, intended use, and limitations. The base Qwen weights are not redistributed in this repository.
801
+
802
+ **---**
803
+
804
+ **# Licensing and Attribution**
805
 
 
 
806
  The model is derived from:
807
 
808
  \`Qwen/Qwen2.5-Coder-7B-Instruct\`
 
813
 
814
  The respective dataset licenses and attribution requirements should be observed when using or redistributing material derived from those datasets.
815
 
816
+ **---**
817
+
818
+ **# Citation**
819
+
820
  If you use this model or the experimental methodology in your work, please cite the original Qwen2.5-Coder model and the relevant datasets used in the experiment.
821
 
822
+ **---**
823
+
824
+ **# Summary**
825
+
826
  ****What is this?****
827
 
828
  A Python-focused DPO fine-tuned version of Qwen2.5-Coder-7B-Instruct.
 
850
  ****Why is the experiment interesting?****
851
 
852
  The model improved downstream coding performance even though explicit preference metrics showed weak validation generalization, highlighting the distinction between optimizing a preference objective and improving downstream model capability.
853
+
854
+
855
+
856
+ **## Licence and attribution**
857
+
858
  Apache-2.0, inherited from \`Qwen/Qwen2.5-Coder-7B-Instruct\`. This is a modified derivative of that
859
 
860
  model; the original is by the Qwen team at Alibaba Cloud. The preference data was generated from the