Flow Matching for Conditional Text Generation in a Few Sampling Steps (2024)

Abstract: Diffusion models are a promising tool for high-quality text generation. However, current models face multiple drawbacks including slow sampling, noise schedule sensitivity, and misalignment between the training and sampling stages. In this paper, we introduce FlowSeq, which bypasses all current drawbacks by leveraging flow matching for conditional text generation. FlowSeq can generate text in a few steps by training with a novel anchor loss, alleviating the need for expensive hyperparameter optimization of the noise schedule prevalent in diffusion models. We extensively evaluate our proposed method and show competitive performance in tasks such as question generation, open-domain dialogue, and paraphrasing tasks.

## introduction diffusion models @xcite @xcite have demonstrated impressive generative performances across many domains and have started to gain traction in the nlp domain as well. diffusion models shine in their ability to generate diverse and high-quality samples but require many sampling steps leading to a long generation time @xcite . furthermore, they require careful tuning of hyperparameters such as the noise schedule @xcite @xcite , time-step interval @xcite , and sampling algorithm @xcite . a suboptimal choice can drastically degrade the performance. a recently proposed generative model, flow matching @xcite @xcite @xcite , represents a superclass of diffusion models and has seen successful adoption to different applications such as image generation @xcite @xcite , video prediction @xcite , 2022), human motion generation @xcite point cloud generation @xcite , and generative modelling on manifolds @xcite . this model directly learns a vector field between the trajectory of instance data and random noise, formulating a nearly straight trajectory between data and noise which can significantly accelerate the sampling speed. in this paper, we propose flowseq, a flow matching model for sample-efficient text generation. we perform generation at the continuous embedding space @xcite @xcite instead of the discrete space @xcite , for improved controllability @xcite and more flexibility @xcite . to this end, a continuous vector field is learned to form a direct trajectory between the text embeddings and gaussian noise. additionally, we formulate an anchor loss to facilitate direct sampling from noisy data at any time step, thus further increasing sampling speed. as a result, our method yields strongly competitive performance on open domain dialogue, question generation, and paraphrasing tasks when compared to various baselines. as demonstrated in fig. 1 , despite relying on as few as a single-step sampling, we manage to secure competitive results ## conclusion and future work in this paper, we propose a flow-based method for sequence-to-sequence generation. we utilize the regression of the vector field and an anchor loss to encourage single-step generation. our approach achieves competitive results compared to several autoregressive and non-autoregressive baselines. importantly, it achieves a remarkable 2,000-fold acceleration in sampling speed relative to the recent diffusion-based baseline. in the future, we may opt to apply flow matching directly in discrete space instead of continuous space. alternatively, we might explore generative models in a token-free manner, such as char-level generation. limitations. our work is constrained by a few limitations. primarily, due to limited computational resources, we could not validate the performance on large-scale datasets. additionally, our method involves random sampling of x 0 and x 1 in an independent manner. an optimized matching approach @xcite could potentially be employed prior to the vector field regression, which is a point of investigation we defer to future work. in the last, furthermore, a rectification @xcite based on flow matching may yield a more direct trajectory and accelerate the sampling speed. from an ethical standpoint, the generated sentences have the potential to contain inappropriate content that may require further review by human inspectors.