# Interlevel Betti Token Transformer

- ID: 1526
- Canonical URL: https://synthcore.org/idea/1526/interlevel-betti-token-transformer
- API JSON: https://synthcore.org/api/idea/1526.json
- API Markdown: https://synthcore.org/api/idea/1526.md
- Verification status: beats_baseline
- Source: [arXiv:2607.28259](https://arxiv.org/abs/2607.28259)
- Category: architecture
- Solves: accuracy, stability, scalability
- ML areas: graph-nn, attention, transformer, embedding
- Math tags: topology, algebraic-topology, combinatorics, linear-algebra
- Ratings: usefulness 7/10; difficulty 6/10; novelty 6/10

## Idea description

Represent each input graph by a short ordered sequence of topological tokens rather than a persistence diagram. For each overlapping interval on a shared filtration grid, compute the number of connected components and independent one-dimensional cycles, concatenate these counts with inexpensive graph summary statistics, and process the resulting sequence with a small Transformer. The representation should retain multiscale structural information while avoiding pairwise persistence-diagram matching.

## Mathematical statement

Let G=(V,E) be a graph, let \widehat{G} be its simplicial complex completion containing vertices and edges, and let h:V    o\mathbb{R} be a filtration function. Extend h to every simplex \sigma by the upper-star rule \widehat{h}(\sigma)=\max_{v\in\sigma}h(v). Choose a shared grid \alpha_0<\cdots<\alpha_N, window width m, and stride s. Define I_t=[\alpha_{ts},\alpha_{ts+m}] for t=0,\ldots,T-1, with T=\lfloor(N-m)/s\rfloor+1. For k\in\{0,1\}, the topological token is \widehat{\beta}_k^h(t)=\dim H_k((\widehat{G})^h_{I_t}), where H_k is homology over a chosen field such as GF(2), and (\widehat{G})^h_{I_t} is the interlevel subcomplex associated with the filtration values in interval I_t. The paper's stability theorem states that for two filtration functions f,g on the same complex, \|\widehat{\beta}_k(G,f)-\widehat{\beta}_k(G,g)\|_1\le C\,d_B(M_k^f,M_k^g), where \widehat{\beta}_k(G,h) is the vector over all windows, M_k^h is the k-dimensional interlevel persistence module, d_B is bottleneck distance, and C depends only on the fixed complex, grid, window width, and stride. Compute each Betti number from boundary matrices: if B_k is the k-boundary matrix and B_{k+1} the next boundary matrix for the interval complex, then \beta_k=\dim\ker(B_k)-\operatorname{rank}(B_{k+1})=n_k-\operatorname{rank}(B_k)-\operatorname{rank}(B_{k+1}), where n_k is the number of k-simplices. The same formula can be used as a practical GF(2) implementation.

## Key formulas

- $$\widehat{h}(\sigma)=\max_{v\in\sigma}h(v),\qquad I_t=[\alpha_{ts},\alpha_{ts+m}],\qquad T=\left\lfloor\frac{N-m}{s}\right\rfloor+1.$$
- $$\widehat{\beta}_{k}^{h}(t)=\dim H_k\!\big((\widehat{G})^{h}_{I_t}\big),\qquad k\in\{0,1\}.$$
- $$\big\|\widehat{\beta}_{k}(G,f)-\widehat{\beta}_{k}(G,g)\big\|_{1}\le C\,d_{B}\!\big(M_{k}^{f},M_{k}^{g}\big).$$
- $$\beta_k(K_I)=\dim\ker B_k-\operatorname{rank}B_{k+1}=n_k-\operatorname{rank}(B_k)-\operatorname{rank}(B_{k+1}).$$

## Implementation notes

1. Integration point: add a TopoScanEncoder beside a standard GNN in a graph-classification model. The encoder receives an input graph G and a scalar filtration h(v) for each node. Start with fixed choices such as node degree, normalized degree, atom type, or a random projection of node attributes; optionally add a learned scalar h(v)=MLP(x_v) but detach it initially so the homology computation is stable. Build a shared grid of N+1 quantiles of all node filtration values, choose m and s, and produce T windows. For each window I_t, construct the interlevel complex exactly according to the paper's filtration convention. In a graph-only MVP, include vertices and edges whose upper-star value lies in the interval, then enforce boundary closure; if the exact interlevel convention is unavailable, use the corresponding interval subcomplex as an explicit ablation. 2. Pseudocode: `h = filtration(G, X); alpha = shared_quantile_grid(h, N+1); tokens=[]; for t in range(T): I=(alpha[t*s], alpha[t*s+m]); K=make_interlevel_complex(G,h,I); B0,B1=boundary_matrices(K, field=GF2); beta0=n0-rank_GF2(B0)-rank_GF2(B1); beta1=n1-rank_GF2(B1)-rank_GF2(B2); tokens.append([beta0,beta1,log1p(n0),log1p(n1)])`; then project each token with a linear layer, add positional embeddings, apply a 2-4 layer Transformer, mean-pool, and concatenate with the baseline GNN embedding before classification. Use batched sparse GF(2) elimination or precompute incidence structure for fixed molecular graphs. 3. Computed from the mathematics: the grid/window definitions, upper-star values, boundary matrices, GF(2) ranks, and Betti counts. Estimated empirically: the best filtration function, grid density N, window width m, stride s, Transformer width, and whether learned filtrations improve over degree/attribute filtrations. Report the theorem's stability proxy directly by perturbing h to h+epsilon and measuring the empirical ratio `||beta(h+epsilon)-beta(h)||_1 / max(epsilon)`; bottleneck distances need not be computed for the first experiment. 4. First cheap experiment: use a 2-3 layer GIN baseline on MUTAG or PROTEINS, with graphs capped at a manageable size. Compare GIN, GIN plus raw degree histograms, and GIN plus the TopoScanEncoder at matched parameter count. Sweep N in {16,32}, m in {4,8}, and s=m/2. Evaluate validation accuracy, wall-clock preprocessing time, and robustness after randomly perturbing node attributes or filtration scores by 1%, 5%, and 10%. Success means a statistically significant accuracy gain over degree histograms at less than 2x preprocessing cost, plus a smaller increase in prediction error under filtration perturbations. A second ablation should compare exact Betti tokens against persistence-diagram features and against tokens containing only beta0 or only beta1.

## Verification

- Status: beats_baseline
- Mechanism evidence: yes
- Mechanism confirmed: yes
- Practical verdict: helps
- Verdict: Built a GF(2) interlevel Betti scanner with beta0/beta1 tokens and a small Transformer encoder. The rank identity passed 60/60 cases; cycle scaling and the filtration transition matched predictions exactly, and the toy topology classification showed a real signal, though it was deliberately favorable.

### Mechanism check

- Verdict: Built a GF(2) interlevel Betti scanner with beta0/beta1 tokens and a small Transformer encoder. The rank identity passed 60/60 cases; cycle scaling and the filtration transition matched predictions exactly, and the toy topology classification showed a real signal, though it was deliberately favorable.
- Confidence: 9/10
- Limitations: No MUTAG/PROTEINS benchmark or multi-seed confidence interval was tested. The implementation uses an explicit interval-subcomplex ablation with boundary closure, not a full interlevel persistence-module construction, and bottleneck-distance stability was not evaluated.

### Practical benchmark

- Paired seeds: 8
- Baseline mean: 0
- Idea mean: 0
- p-value: 0.0081
- Paired wins: 8/8
- Benchmark verdict: idea better (significant)

## Artifacts

- [bench_graph.py](https://synthcore.org/code/594/bench_graph.py)
- [bench_output.json](https://synthcore.org/code/594/bench_output.json)
- [graph_topology_track.py](https://synthcore.org/code/594/graph_topology_track.py)
- [mini_compare.py](https://synthcore.org/code/594/mini_compare.py)
- [report.md](https://synthcore.org/code/594/report.md)
- [report_bench_2026-08-31T192742.md](https://synthcore.org/code/594/report_bench_2026-08-31T192742.md)
- [toposcan.py](https://synthcore.org/code/594/toposcan.py)
- [toy_verify.py](https://synthcore.org/code/594/toy_verify.py)
- [Download all files as ZIP](https://synthcore.org/download/594)

## Disclaimer

AI-generated research hypothesis, automatically tested. Not peer-reviewed.
