generative model code