Module Specialization in Transformer Factual Recall under Correlated Fact Distributions
Abstract
Recent studies have investigated how attention and MLP modules in Transformers store and recall individual facts. Real-world facts, however, exhibit shared attributes across subjects, overlap between relations, and uneven answer frequencies. To investigate how these structures affect factual recall, we conduct controlled experiments in two-layer Transformers, separately varying shared answer patterns across subjects, shared answers across relations, and concentration of answer frequencies on a small set. We measure how accurately linear classifiers predict answers from intermediate representations and how interventions on module outputs change the model's predictions. Under strong subject sharing, answers can be decoded almost as accurately before the final MLP as after it. In contrast, concentrating answer frequencies on a small set leaves a larger improvement in decoding accuracy after the final MLP. In separate intervention evaluations, altering the first attention module substantially changes answer predictions across independent, subject-sharing, and answer-concentration conditions. Additional interventions and a conditional cost analysis suggest a possible attention-MLP pathway for exploiting shared answer patterns across subjects. A comparison of three natural factual relations in pretrained language models also reveals relation-dependent differences in an intervention-based localization measure. These findings show that factual structure shapes patterns of answer decodability, while module interventions provide a complementary view of the computations underlying recall.