The discovery of the optical counterpart, along with the gravitational waves (GWs) from GW170817, of the first binary neutron star merger has opened up a new era for multimessenger astrophysics. Combining the GW data with the optical counterpart, also known as AT 2017gfo and classified as a kilonova, has revealed the nature of compact binary merging systems by extracting enriched information about the total binary mass, the mass ratio, the system geometry, and the equation of state. Even though the detection of kilonovae has brought about a revolution in the domain of multimessenger astronomy, there has been only one kilonova from a GW-detected binary neutron star merger event confirmed so far, and this limits the exact understanding of the origin and propagation of the kilonova. Here, we use a conditional variational autoencoder (CVAE) trained on light-curve data from two kilonova models having different temporal lengths, and consequently, generate kilonova light curves rapidly based on physical parameters of our choice with good accuracy. Once the CVAE is trained, the timescale for light-curve generation is of the order of a few milliseconds, which is a speedup of the generation of light curves by 1000 times as compared to the simulation. The mean squared error between the generated and original light curves is typically 0.015 with a maximum of 0.08 for each set of considered physical parameters, while having a maximum of ≈0.6 error across the whole parameter space. Hence, implementing this technique provides fast and reliably accurate results.