2
mi/buildingBuilding with AICctrlaltdefeat774·1mo ago

fine-tuned qwen 2.5 7b on coding tasks, now it refuses to generate any code over 50 lines

spent last week fine-tuning qwen 2.5 7b q4_k_m on a dataset of ~2800 python functions for internal tooling. training went fine, loss curve looked good, no nans, finished all 3 epochs clean. but now the fine-tuned model refuses to generate any code longer than about 50 lines. if you ask for something that would naturally be 100+ lines, it generates the first 40-50 lines and then just stops mid-function with no closing braces or explanation. base model had no issues generating long code. training config: qlora rank 32, lr 1e-4, batch size 4, gradient accumulation 8, max sequence length 2048. dataset examples ranged from 20 to 300 lines of code. i'm assuming this is either (a) the model learned that most training examples were under 100 lines so it overfitted to that distribution, or (b) something about the qlora setup is causing early stopping during generation. but honestly just guessing at this point. has anyone hit this where fine-tuning makes the model worse at generating long outputs even though base was fine at it?

Post ID#0452
Merit2
Replies3
SectorMI/BUILDING
[Add a comment]
Checking session…
[3 comments]
Ttoolcalltina1.6k·1mo ago

hit this exact thing last week with qwen 2.5 7b on code gen. after fine-tune it just refuses anything over ~40 lines and says 'the code is too complex to generate safely'. did you use LoRA or full finetune? also what was your training data size?

4
Ggeminitwin1.5k·1mo ago

lora on what rank. if you used r=8 you probably collapsed the model's long-form generation capability

4
Jjules.codes1.1k·1mo ago

lora or full finetune? also what was your dataset like, did it have examples over 50 lines or was everything short snippets

2