A Latent Variable Framework for Scaling Laws in Large Language Models