# Transformers Provably Learn Algorithmic Solutions for Graph Connectivity, But Only with the Right Data

트랜스포머는 그래프 연결성을 위한 알고리즘적 해법을 증명 가능하게 학습하지만, 올바른 데이터가 있을 때만 가능하다

Qilin Ye, Deqing Fu, Robin Jia, Vatsal Sharan · arXiv · 2025년 10월 22일

- **연구 문제** Transformer가 그래프 연결성에서 알고리즘 대신 차수 기반 휴리스틱에 의존하는지를 분석합니다.
- **연구 방법** Disentangled Transformer의 용량을 3L 직경으로 정의하고, 가중치를 알고리즘 채널과 휴리스틱 채널로 분해해 학습 동역학을 분석합니다.
- **주요 결과** L층 모델은 직경 3L 이하 그래프를 처리할 수 있으며, 용량 내 데이터로 학습하면 알고리즘 채널이 선택되는 경향이 보고됩니다.

## Transformer는 연결성 문제에서 알고리즘을 배우는가

이 논문은 Transformer가 그래프 연결성 문제를 풀 때 검증 가능한 알고리즘을 배우는지, 아니면 노드 차수 같은 단순한 지름길에 의존하는지를 다룹니다. 연결성은 두 노드가 경로로 이어지는지를 판별하는 문제이며, 인접행렬의 거듭제곱으로 해결할 수 있어 알고리즘 학습을 검증하기에 명확한 테스트베드입니다. 저자들은 표준 Transformer가 무작위 그래프에서는 거의 완벽한 분포 내 정확도를 보이지만, 두 개의 분리된 사슬 같은 단순한 분포 외 그래프에서는 크게 실패한다고 보고합니다. 따라서 질문은 표현력이 충분한 구조에서도 경사하강법이 실제로 알고리즘 해를 찾는지입니다.

## Disentangled Transformer와 용량 개념

분석은 각 어텐션 블록의 출력을 잔차 스트림에 더하지 않고 새 좌표 조각으로 덧붙이는 Disentangled Transformer를 중심으로 합니다. 이 구조에서 L층 모델은 직경 3L 이하의 그래프에서 인접행렬 거듭제곱 알고리즘을 구현할 수 있으며, 직경 3L+1 그래프가 존재하면 실패한다는 상한이 함께 제시됩니다. 이때 용량은 모델이 모든 그래프를 완벽히 처리할 수 있는 최대 직경으로 정의되고, 노드 쌍은 최단 경로 거리가 3L 이하이면 within-capacity, 그보다 길면 beyond-capacity로 나뉩니다.

## 가중치 분해와 두 채널의 경쟁

층별 순열 동변성 조건이 성립하면 각 층의 가중치는 A⊗I\_n + B⊗J\_n 형태로 분해됩니다. 여기서 A⊗I\_n 항인 알고리즘 채널은 지역적 결합을 보존하며 인접행렬의 거듭제곱을 계산하고, B⊗J\_n 항인 휴리스틱 채널은 그래프 구조를 무시하고 노드 차수 기반의 전역 통계를 계산합니다. 학습 동역학은 용량 내 쌍이 지배하면 휴리스틱 채널이 억제되고, 용량 밖의 연결된 쌍이 많으면 휴리스틱 채널이 강화되는 방향으로 분석됩니다. 다만 이 결론은 교차 성분 페널티가 within-component 보상보다 큰 Population-Level Dominance Condition 같은 가정 아래에서 얻어집니다.

![Figure 8: We plot the model behavior of a 3-Layer Disentangled Transformer model trained onER(n= 64) graphs. They also quickly pick up almostlayer-wise equivar…](https://refivu.com/papers/b23c33ef-4b87-4e29-a0da-332c5c52f7a4/figures/figure-d5da441d8759c3be7b2f861461879ddf.png?thumb=512)

**Figure 8** .We plot the model behavior of a 3-Layer Disentangled Transformer model trained onER(n= 64) graphs. They also quickly pick up almostlayer-wise equivariantproperties (measured by Eqn. 3). All layers show very small projection error onto the A⊗I n +B⊗J n decomposition, resonating our theoretical claims in Theorem 4.7.

[원문](https://arxiv.org/abs/2510.19753v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Qilin Ye, Deqing Fu, Robin Jia, Vatsal Sharan · Transformers Provably Learn Algorithmic Solutions for Graph Connectivity, But Only with the Right Data · 원문 그림 인용 · 원본 PDF 30쪽에서 그림 영역을 추출했습니다.

![Figure 9: Here we visualize the weights Wℓ learned by a 2-Layer and 3-Layer Disentangled Transformer respectively. All models are randomly initializedwithoutan…](https://refivu.com/papers/b23c33ef-4b87-4e29-a0da-332c5c52f7a4/figures/figure-893fd934729296a81a1069a0960f6fc0.png?thumb=512)

**Figure 9** .Here we visualize the weights Wℓ learned by a 2-Layer and 3-Layer Disentangled Transformer respectively. All models are randomly initializedwithoutany restriction on parameterization. Resonating Theorem 4.7, they all converge to a form of Wℓ = Aℓ ⊗I n +B ℓ ⊗J n.

[원문](https://arxiv.org/abs/2510.19753v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Qilin Ye, Deqing Fu, Robin Jia, Vatsal Sharan · Transformers Provably Learn Algorithmic Solutions for Graph Connectivity, But Only with the Right Data · 원문 그림 인용 · 원본 PDF 31쪽에서 그림 영역을 추출했습니다.

## 용량 경계와 데이터 조절의 효과

2층과 3층 Disentangled Transformer를 각각 ER(n=24) 및 ER(n=64) 그래프에서 학습하면, 노드 쌍의 최단 거리가 3^L 이하일 때만 99% 이상의 정확도로 예측합니다. 표준 Transformer도 비슷한 경계를 보입니다. 데이터 조절은 학습 그래프를 직경 3L 이하로 제한하거나 용량 내 그래프를 강조하는 방식이며, 표준 Transformer를 직경 9 이하 분포에서 학습하면 최대 사슬 길이 10인 2Chain에서 일반화하는 것으로 보고됩니다. 저자들은 학습 중 비음수성을 강제하지 않았음에도 이론적 용량 분석이 여전히 유효하다고 해석합니다.

![Figure 2: Capacity of Disentangled Transformers. We train 2-layer (top) and 3-layer (bottom) Disentangled Transformers on ER(n = 24) and ER(n = 64) graphs re…](https://refivu.com/papers/b23c33ef-4b87-4e29-a0da-332c5c52f7a4/figures/figure-05bb0f96ab18cfe1118ca9ac6d9c2636.png?thumb=512)

**Figure 2** . Capacity of Disentangled Transformers. We train 2-layer (top) and 3-layer (bottom) Disentangled Transformers on ER(n = 24) and ER(n = 64) graphs respectively. When evaluated on hold-out sets, both models can only make reliable predictions (≥ 99% accuracy) on node pairs u, v if and only if dG(u, v) ≤ 3 L . These findings resonate with our theoretical observations in Theorem 4.5.

[원문](https://arxiv.org/abs/2510.19753v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Qilin Ye, Deqing Fu, Robin Jia, Vatsal Sharan · Transformers Provably Learn Algorithmic Solutions for Graph Connectivity, But Only with the Right Data · 원문 그림 인용 · 원본 PDF 4쪽에서 그림 영역을 추출했습니다.

![Figure 7: Standard Transformer models learn generalizable solutions from within capacity data.We train a 2-layer standard Transformer model on ER(n= 20) graphs…](https://refivu.com/papers/b23c33ef-4b87-4e29-a0da-332c5c52f7a4/figures/figure-0190d0e490ef42ae48d884aa11119ac6.png?thumb=512)

**Figure 7** .Standard Transformer models learn generalizable solutions from within capacity data.We train a 2-layer standard Transformer model on ER(n= 20) graphs, with and without restricting graph diameters. When tested on OOD 2Chain graphs, the one trained withthe right datais able to generalize.

[원문](https://arxiv.org/abs/2510.19753v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Qilin Ye, Deqing Fu, Robin Jia, Vatsal Sharan · Transformers Provably Learn Algorithmic Solutions for Graph Connectivity, But Only with the Right Data · 원문 그림 인용 · 원본 PDF 9쪽에서 그림 영역을 추출했습니다.

![Figure 10: (left) Standard Transformers models studied in §3.3 also hit its capacity wall at 3L, showing that our theoretical results transfer beyond the theor…](https://refivu.com/papers/b23c33ef-4b87-4e29-a0da-332c5c52f7a4/figures/figure-bc9ba7e8a97db1d231c07ca8a4e9b9a0.png?thumb=512)

**Figure 10** .(left) Standard Transformers models studied in §3.3 also hit its capacity wall at 3L, showing that our theoretical results transfer beyond the theoretical simplification of Disentangled Transformers. (right) Standard Transformer models also learn an almost layer-wise equivariant solution measured by Eqn. 3.

[원문](https://arxiv.org/abs/2510.19753v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Qilin Ye, Deqing Fu, Robin Jia, Vatsal Sharan · Transformers Provably Learn Algorithmic Solutions for Graph Connectivity, But Only with the Right Data · 원문 그림 인용 · 원본 PDF 31쪽에서 그림 영역을 추출했습니다.

## 논문 정보

- **저자**: Qilin Ye, Deqing Fu, Robin Jia, Vatsal Sharan
- **학회·저널**: arXiv · 프리프린트
- **최초 공개일**: 2025년 10월 22일
- **등록일**: 2026년 10월 29일
- **수정일**: 2026년 2월 17일
- **버전**: v2
- **arXiv**: 2510.19753
- **분류**: cs.LG
- **원문 이용 조건**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **제공 범위**: 논문 정보, 해설, 허용된 원문 그림

[논문 원문 ↗](https://arxiv.org/abs/2510.19753v2) · [원문 PDF ↗](https://arxiv.org/pdf/2510.19753v2)

AI 해설은 논문 원문과 별개의 설명이며 오류가 있을 수 있습니다. 원문과 그림은 각 출처의 이용 조건과 따로 표시된 권리를 따릅니다.

## 초록

Transformers often fail to learn generalizable algorithms, instead relying on brittle heuristics. Using graph connectivity as a testbed, we explain this phenomenon both theoretically and empirically. We consider a simplified Transformer architecture, the Disentangled Transformer, and prove that an $L$-layer model can compute connectivity in graphs with diameters up to $3^L$, implementing an algorithm equivalent to computing powers of the adjacency matrix. By analyzing training dynamics, we prove that whether the model learns this strategy hinges on whether most training instances are within this model capacity. Within-capacity graphs (diameter $\\leq 3^L$) drive the learning of the algorithmic solution while beyond-capacity graphs drive the learning of a simple heuristic based on node degrees. Finally, we empirically show that restricting training data to stay within a model's capacity makes both standard and Disentangled Transformers learn the exact algorithm.

## 원문 인용

Qilin Ye, Deqing Fu, Robin Jia, Vatsal Sharan (2025). Transformers Provably Learn Algorithmic Solutions for Graph Connectivity, But Only with the Right Data. arXiv:2510.19753v2. https://arxiv.org/abs/2510.19753v2

**BibTeX**

```
@misc{ye2025transformers,
  title = {{Transformers Provably Learn Algorithmic Solutions for Graph Connectivity, But Only with the Right Data}},
  author = {Qilin Ye and Deqing Fu and Robin Jia and Vatsal Sharan},
  year = {2025},
  eprint = {2510.19753},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.19753v2}
}
```

## 이 논문의 용어

- [트랜스포머](https://refivu.com/terms/515e8433c447-transformer)
- [KKT conditions](https://refivu.com/terms/4cd4d84125a5-kkt-conditions)
- [Kronecker product](https://refivu.com/terms/cc940568c4ad-kronecker-product)
- [Exact Match Accuracy](https://refivu.com/terms/cc285d6c7080-exact-match-accuracy)
- [connectivity matrix](https://refivu.com/terms/3c04796ccae3-connectivity-matrix)
- [Standard Transformer](https://refivu.com/terms/a89335417afb-standard-transformer)

## 다른 논문 해설

- [Why ReLU? A Bit-Model Dichotomy for Deep Network Training](https://refivu.com/papers/ef9838e0-146e-4cab-acca-5a924451690d-why-relu-a-bit-model-dichotomy-for-deep.md)
- [WaveSSM: Multiscale State-Space Models for Non-stationary Signal Attention](https://refivu.com/papers/b10a30ea-d84b-4eed-9929-b946bcc1a697-wavessm-multiscale-state-space-models-for-non-stationary.md)
- [Memory Caching: RNNs with Growing Memory](https://refivu.com/papers/87ba67cb-e3d7-4a89-927f-f795be747cb8-memory-caching-rnns-with-growing-memory.md)
- [Tucker Attention: A generalization of approximate attention mechanisms](https://refivu.com/papers/372047e0-cd32-4ae3-8113-17871388745b-tucker-attention-a-generalization-of-approximate-attention.md)
- [AdaSplash-2: Faster Differentiable Sparse Attention](https://refivu.com/papers/c0088d29-0ad2-4489-9b71-b3ce2a62b4a6-adasplash-2-faster-differentiable-sparse-attention.md)
- [Benign Overfitting in Adversarial Training for Vision Transformers](https://refivu.com/papers/a90339d2-e025-49a0-97df-3e6493ad2bd1-benign-overfitting-in-adversarial-training-for-vision.md)
- [Random Scaling of Emergent Capabilities](https://refivu.com/papers/2ffeaac2-4d9c-4489-a7df-893d2dede9e8-random-scaling-of-emergent-capabilities.md)
- [Two Calm Ends and the Wild Middle: A Geometric Picture of Memorization in Diffusion Models](https://refivu.com/papers/b17e2b67-a040-4a28-94af-c10277207bf4-two-calm-ends-and-the-wild-middle-a.md)
- [Avoid What You Know: Divergent Trajectory Balance for GFlowNets](https://refivu.com/papers/87b88085-7a9a-40b1-ab76-20695d82f16d-avoid-what-you-know-divergent-trajectory-balance-for.md)
- [When to Trust the Cheap Check: Weak and Strong Verification for Reasoning](https://refivu.com/papers/a7bb9015-ecfe-4c16-a5f8-d2f25285d6ea-when-to-trust-the-cheap-check-weak-and.md)
- [When More Experts Hurt: Underfitting in Multi-Expert Learning to Defer](https://refivu.com/papers/92083314-dda5-4f9a-be1b-69e210ee6378-when-more-experts-hurt-underfitting-in-multi-expert.md)
- [Neural-HSS: Hierarchical Semi-Separable Neural PDE Solver](https://refivu.com/papers/f865eaf4-e20f-43e6-b5a8-80e1cee83ca3-neural-hss-hierarchical-semi-separable-neural-pde-solver.md)

---

AI 해설에는 오류가 있을 수 있습니다. [Refivu](https://refivu.com/papers/b23c33ef-4b87-4e29-a0da-332c5c52f7a4-transformers-provably-learn-algorithmic-solutions-for-graph)
