LLM-Enhanced Stochastic Generation of Class Diagram Datasets
Large language models (LLMs) excel at code-centric and algorithmic tasks, but their software design and modeling capabilities remain limited. Unlike abundant code that enables strong generation performance, the scarcity of high-quality design corpora in the training data restricts their software modeling comprehension. A practical solution is to automatically build large-scale, task-specific datasets for training and evaluating software modeling neural networks. This paper introduces CDGen, a neuro-symbolic pipeline for synthesizing large-scale Text-Class Diagram (TXT-CD) datasets. The pipeline consists of five core phases plus one optional augmentation step: first, a stochastic generator produces CD skeletons with random structures and identifiers; second, an LLM grounds skeletons to business domains by replacing random identifiers with domain concepts; third, CDs are refined via a hybrid LLM and rule-based fixing approach to improve quality; fourth, an LLM generates CD-aligned textual descriptions via few-shot prompting; fifth, alignment validation filters valid description-CD pairs for dataset storage. The optional augmentation step injects controlled noise into texts to mimic real-world description-model inconsistencies. Using this pipeline, we constructed CDSyn10K—a large-scale TXT-CD dataset with 10,000 description-model pairs across 2,000 business domains. Evaluations show CDSyn10K diagrams are highly diverse and comparable to expert-made artifacts. To demonstrate the effectiveness, we fine-tuned Qwen3-0.6B and Qwen3-8B on CDSyn10K to build Qw-OOD-0.6B and Qw-OOD-8B, which surpass the same-size generic LLMs on class diagram modeling tasks.