Quantifying Generalization Complexity for Large Language Models