Nowadays, solar spectra are routinely analyzed to understand the physical mechanisms that trigger different physical phenomena. These spectral lines are modeled using approaches of increasing complexity, ranging from a simple Gaussian model to complex non-LTE radiative transfer calculations. In practice, these data are also affected by telescope degradation, may include some instrumental artifacts, and some signals may be buried under noise. During these years, different approaches have been developed to solve specific problems, proving solutions under various assumptions. Since many of these models are differentiable (and those that are not differentiable can be emulated with neural networks), we could use deep learning frameworks as a general infrastructure to implement these models and infer the parameters of interest in a flexible way. We can combine and incorporate different models, nonlinear transformations, spatial degradation (telescope PSF), spatial coherence (spatial smoothing), artifacts (e.g., fringes, blends with other lines), and physical constraints (e.g., magnetic field vector divergence). By construction, we can run these codes on GPUs with no extra modification, speeding up all computations. In this talk, I will present different examples with IRIS and SST data with an eye toward future missions such as MUSE and EUVST, highlighting the strengths and limitations of this novel approach.