D iff LM : Controllable Synthetic Data Generation via Diffusion Language Models (2025)

Abstract: Recent advancements in large language models (LLMs) have significantly enhanced their knowledge and generative capabilities, leading to a surge of interest in leveraging LLMs for high-quality data synthesis. However, synthetic data generation via prompting LLMs remains challenging due to LLMs’ limited understanding of target data distributions and the complexity of prompt engineering, especially for structured formatted data. To address these issues, we introduce DiffLM, a controllable data synthesis framework based on variational autoencoder (VAE), which further (1) leverages diffusion models to reserve more information of original distribution and format structure in the learned latent distribution and (2) decouples the learning of target distribution knowledge from the LLM’s generative objectives via a plug-and-play latent feature injection module. As we observed significant discrepancies between the VAE’s latent representations and the real data distribution, the latent diffusion module is introduced into our framework to learn a fully expressive latent distribution. Evaluations on seven real-world datasets with structured formatted data (i.e., Tabular, Code, and Tool data) demonstrate that DiffLM generates high-quality data, with performance on downstream tasks surpassing that of real data by 2%–7% in certain cases. Data and code are available at https://github.com/bytedance/DiffLM.

## introduction data synthesis has become an indispensable technique in current machine learning research, enabling rapid generation and modification of datasets @xcite , allowing researchers to experiment with various scenarios and model architectures without the extensive processes associated with real-world data collection. meanwhile, with the rapid advancements in large language models (llms), recent research in natural language processing (nlp) has increasingly focused on leveraging llms for synthetic data generation. early efforts attempted to fine-tune llms to align with real data distributions @xcite @xcite . as the in-context learning capabilities of llms have improved, some studies have explored zero-shot or few-shot prompting of llms to generate synthetic data @xcite . despite the progress achieved, generating highquality synthetic textual data using llms remains challenging, particularly for structured data @xcite . first, llms often lack a global understanding of the target data distribution when generating synthetic data. even after fine-tuning, it is difficult to inject information about complex and varied distributions into current llm architectures, often resulting in outputs with low diversity and instances of data copying @xcite . moreover, existing llm-based synthetic data generation methods typically involve complex pipelines and post-processing mechanisms, such as prompt engineering, multi-agent frameworks, and iterative sampling @xcite . these complexities hinder the rapid adaptation of llms to new tasks, limiting their utility in dynamic research and industrial scenario. concurrently, the remarkable performance of variational autoencoders (vaes) and diffusion models in image synthesis tasks @xcite has spurred interest in adapting these techniques to other modalities @xcite @xcite . although some works have introduced latent spaces into language models for simple tasks like style transfer or topic generation @xcite , our preliminary experiments indicate that directly applying the latent distributions learned by vaes often results in outputs that are unrelated to the real data. similar issues also have been addressed in prior works @xcite @xcite . this challenges the direct application of these methods in more complex scenarios for synthetic data generation. to address these challenges, we propose dif-flm, a novel framework that leverages a plug-andplay latent space to provide data distribution information for llms during data generation. first, to decouple the learning of real data distributions from the llm's training objectives, we develop a latent space using a vae model to capture external information, mapping samples from the real dataset to latent vectors. however, we observed that sampling points from a gaussian distribution obtained from naive vae that cannot generate realistic results. to overcome the poor quality of data generated by sampling from vae, we employ a latent diffusion method that linearly adds noise to the latent space over time. a denoising network is then trained to learn these noises in the reverse process, reducing efficiency loss in data synthesis due to sampling failures. finally, we design a soft prompting method to inject latent features into the llm decoding process, resulting in controllable, high-quality synthetic data. we evaluate our method on seven real-world structured formatted datasets, ranging from relatively simple table synthesis to more complex code and tool synthesis tasks. experiments demonstrate that difflm can generate high-quality results, and ablation studies confirm the effectiveness of each component in our proposed method. the contributions of this paper are threefold: the recent advancement in the generative capabilities of llms has motivated numerous exploratory works aiming to leverage these models for data augmentation in areas such as text classification @xcite , information extraction @xcite , and tabular data generation @xcite . a comprehensive survey conducted by @xcite proposes a prompt-based generic workflow for synthetic data generation, curation, and evaluation. and multiple advanced works have attempted to fine-tune language models for data synthesis in recent years @xcite @xcite @xcite . specifically, these methods involve fine-tuning llms on a small amount of gold data for language modeling, followed by the use of various sampling methods to generate data. however, a major challenge remains in ensuring that synthetic data accurately reflects real-world distributions. @xcite has shown that llm-generated data can sometimes diverge from actual data distributions, leading to unfaithful representations that may hinder model training. some studies have explored data selection @xcite or data augmentation @xcite to address this distribution gap, but there remains significant room for improvement. ## methodology figure 1 illustrates the main pipeline of our proposed difflm. first, we define an encoder to map discrete text into a continuous latent space (section 3.2). second, although the features of the data are extracted and compressed, conventional latent embeddings in text vaes often lead to decoding failures due to underutilized or empty regions in the latent space. to address this issue, we train a diffusion model on the latent space (section 3.3). finally, to incorporate encoded prior knowledge into the decoding stage of large language models, we propose a novel soft prompt injection method to steer the decoding process (section 3.4). ## experiments in this section, we evaluate the generation quality of the difflm method on multiple public benchmarks across three tasks: 1) tabular data generation: we compare difflm with sota ## analysis the effect of adaptive β adjustment. as described in section 3.2, we use a decreasing β adjustment strategy to train the vae latent space. here, we compare this with another method that uses a cyclical schedule to anneal β @xcite , evaluating both the loss decline curves and downstream task performance to demonstrate the effectiveness of our decreasing strategy. firstly, as shown in figure 3 , the kl-divergence loss trends under decreasing β exhibit a pattern where the loss first increases, then decreases, and then increases again. this indicates that during the early stages of vae training, difflm uses a larger β to focus on the divergence between the embedding distribution and the standard gaussian. this helps quickly learn a standard latent space to stabilize the training of the llm module. subsequently, when the reconstruction loss reaches a bottleneck, it gradually reduces the weight of the kl-divergence loss. at this point, the training objective shifts towards obtaining a decoder with stronger generative capabilities. as a result, the kl loss gradually increases and eventually stabilizes at a fairly low value. from the results, our decreasing β method achieves the lowest reconstruction loss. additionally, by introducing the latent diffusion process, we address the issue of distribution discrepancy. therefore, as shown in the effect of latent feature injection. we also compare our proposed soft prompt latent feature injection method with previously explored methods such as kv memory injection and input embedding injection @xcite ; implementation details are illustrated in figure 4 . specifically, the loss convergence on the validation dataset for different injection methods are shown in figure 3 . the input embedding method leads to suboptimal training results, where the reconstruction loss ceases to decrease after reaching around 3.6. this indicates that such a simple injection method struggles to effectively convey complex real distribution information to the llm decoder. meanwhile, the soft prompt method slightly outperforms kv memory in terms of reconstruction loss. however, as shown in ## conclusion in this paper, we propose difflm, a novel framework that enhances llms' ability to generate highquality synthetic data by integrating real-world data distributions. difflm maps real data into a latent space via vae, which is then injected into llm decoding through a causal language modeling objective. a diffusion process further refines the latent distribution, reducing sampling discrepancies. to ensure flexible and non-intrusive control over data quality and structure, difflm freezes llm parameters and employs latent features as plug-in modules. experiments show that difflm generates consistent data, enabling downstream models to match or even exceed the performance of those trained on real data. for future research, our work could help build data flywheels for llm applications and facilitate dataset curation for low-resource domains. limitations our work, while offering valuable contributions to synthetic data generation, has several limitations. first, our approach focuses primarily on structured data synthesis, such as tabular data generation, code generation, and tool generation. it does not address the generation of more subjective or nuanced data, such as sentiment-specific data or tasks requiring varied levels of complexity or capability. additionally, our decoupling of data distribution learning may need further refinement to accommodate such subjective text synthesis tasks. second, due to time and hardware constraints, we limited our study to a relatively simple vae and diffusion network, and used llms up to 7b parameters for decoding. future research could explore the potential of scaling these models further, using even larger architectures to better evaluate and validate the effectiveness of the difflm framework in data synthesis tasks.