acceptodds
Under review as a conference paper at ICLR 2027

ChainGram: Discovering A Structural Grammar for Knowledge Graph Foundation Models

Abstract

Knowledge graph foundation models (KGFMs) are emerging as a promising paradigm for transferable reasoning over knowledge graphs. By learning invariant patterns, they enable zero-shot inference on new KGs with unseen entities and relations. Existing KGFMs capture these patterns through relational interactions. However, these patterns are often implicitly encoded in learned representations, making them difficult to identify, organize, and reuse explicitly. Inspired by natural language grammar, we ask whether invariant patterns across KGs can be explicitly abstracted and organized into a transferable structural grammar. To this end, we propose ChainGram, a chain-based KGFM that learns such a grammar from relational chains across KGs for query-specific reasoning. Specifically, we propose a hierarchical codebook encoder to learn word-level structural codes and chain-level prototypes from relational chains. These prototypes are further aggregated into a relation-specific structural grammar. A grammar-guided reasoner then selects relevant patterns based on query-specific chains and aggregates pattern-consistent evidence for entity prediction. Experimental results across 54 KGs demonstrate that ChainGram achieves the best performance across all six evaluation settings, improving overall MRR over the strongest baseline by 2.82% under zero-shot inference and 5.84% with full fine-tuning. Our code is available at https://anonymous.4open.science/r/ChainGram-2857/.

Primary area:
learning on graphs and other geometries & topologies
Keywords:
knowledge graph, KG foundation model

Reviews

Among:
Shape:
1234this paper, Top 30%
Figure 1. Mean review rating of the reviewed papers at ICLR 2027. This paper averages 2.67 over 3 reviews, above 70% of the others.
Reviewer_766COpenReview ↗
Rating
3(+1)
Confidence
3
Informativeness
2
Presentation
2
Soundness
2
Read review
Paper summary

This paper studies cross-graph link prediction with knowledge graph foundation models (KGFMs) and proposes ChainGram. The method converts relational chains sampled around support facts into identity-independent structural tokens and constructs shared structural codebooks through word-level and chain-level vector quantization. These representations are aggregated into relation-specific structural patterns, which guide the matching and weighting of chains rooted at the query entity. The resulting chain evidence refines the entity predictions of a query-conditioned GNN.

The main contribution is the integration of relational-chain representations, hierarchical discrete structural abstraction, and query-specific evidence selection into a reasoning architecture with parameters shared across knowledge graphs.

The authors pretrain the model on three source KGs and evaluate it on 54 target benchmark configurations spanning three transfer settings under zero-shot and full fine-tuning protocols. The main results report relative improvements in overall MRR of 2.82% and 5.84%, respectively, over the strongest baseline. Ablation studies, codebook perturbation experiments, and controlled structural probes provide additional evidence that the hierarchical codebooks and chain-matching mechanism contribute to predictive performance.

Critical strengths
  1. A well-motivated mechanism for structural transfer

The hierarchical codebooks organize local relational roles and whole-chain patterns into shared structural units, which are subsequently used for relation initialization and query-specific evidence matching. This design directly addresses a central challenge in cross-KG transfer: entity and relation identities need not be shared, whereas structural patterns may be transferable.

The performance degradation observed when the structure–code assignments are perturbed provides stronger evidence of the codebooks’ predictive utility than clustering visualizations alone.

This is an important methodological strength because the approach offers a concrete mechanism for organizing transferable structural knowledge, rather than merely improving prediction through a less structured representation.

  1. Broad evaluation with consistent aggregate improvements

The main evaluation covers 54 target benchmark configurations, including unseen-entity, unseen-entity-and-relation, and transductive settings, under both zero-shot and fine-tuning protocols. The aggregate results in the main table consistently favor the complete model over the compared methods.

This breadth is particularly relevant to the overall assessment because transferability is the central objective of KGFMs. Evaluation across multiple target settings provides substantially stronger support for that objective than improvements on a small number of individual datasets.

Critical weaknesses
  1. The method specification does not yet adequately support the central claims of ordered relational composition and grammar matching

There are two related technical concerns.

First, the preservation of relational information is unclear. According to Eq. (4), two chains with the same sequence of entity distance labels and the same query-relation indicators could receive identical token sequences even if the types or repetition patterns of their non-query relations differ. Subsequent Transformer encoding and quantization cannot recover information that is absent from the input.

This does not imply that the AAAB/AABA/ABAA probe is necessarily indistinguishable under the proposed tokenization: the patterns could still be distinguished if A or B is marked as the query relation. However, the authors need to specify the query relation and the resulting tokens used in this probe. Without this information, it is difficult to determine whether the experiment tests general relational-composition capabilities or primarily the ability to identify the position of a query-relation marker.

Second, the attention-based matching mechanism requires clarification. If hrqpath^{\mathrm{pat}}_{r_q} is a single vector, the attention weight over the single key in Eq. (16) is necessarily one. In that case, the attention operation itself cannot select among different patterns based on the query chain. The subsequent matching network can still depend on the query chain, so this concern does not imply that the entire reasoner is ineffective. Nevertheless, the explanation of pattern matching through attention needs to be revised or made more precise.

These concerns are important because they affect whether the specified model implements the paper’s central mechanism, rather than merely reflecting minor presentation issues. If unresolved, they would weaken both the technical justification of the contribution and its reproducibility.

  1. The contribution of the structural grammar mechanism is not sufficiently disentangled from conventional chain modeling and additional computation

The model includes multiple Transformers, two levels of codebooks, and an additional chain-based prediction branch. Although the ablations provide useful evidence, they do not yet clearly establish whether the gains primarily arise from hierarchical discrete abstraction or from stronger continuous chain encoding and additional computation.

In particular:

  • M1 and M4 are both described as removing chain reasoning or matching and relying on the base GNN; their actual architectural differences are unclear.
  • Parameter-matched or compute-matched continuous chain baselines are not sufficiently reported.
  • The main results do not include variability estimates or confidence intervals. While some appendix analyses use three random seeds, the statistical treatment of the main table remains unclear.
  • Some reported advantages are very small. For example, under fine-tuning in the Inductive-E setting, Hits@10 is 0.5679 compared with 0.5678 for the strongest baseline. Statistical evidence is needed to assess the robustness of such differences.

Chain modeling and vector quantization are not themselves new techniques. Unless the paper establishes that their proposed combination provides distinctive benefits beyond conventional model enhancement, the contribution may be better characterized as an effective architectural integration than as evidence of structural grammar discovery.

Questions for authors

A. Clarification of the Current Method

Question 1: What relational information is preserved by Eq. (4)?

Please provide the complete token sequence for a concrete example chain and clarify:

  • Whether the tokenization encodes equality or differences among non-query relations;
  • How forward and inverse relations are represented;
  • How rqr_q is specified in the AAAB/AABA/ABAA probe.

Question 2: What are the actual tensor shapes in Eqs. (12) and (16)?

Is hrqpath^{\mathrm{pat}}_{r_q} a single vector or a collection of pattern representations? If it is a single vector, please explain the role of attention over a single key. If it is a collection, please specify how the individual patterns are constructed and aggregated.

B. Evidence Supporting the Current Conclusions

Question 3: Does the hierarchical discrete mechanism provide statistically robust improvements over continuous chain models under comparable resource budgets?

Please clarify the distinction between M1 and M4 and provide a directly comparable continuous chain control model, together with parameter counts, inference costs, and results across multiple random seeds.

Question 4: What are the exact evaluation sets and the rules governing access to graph information?

Please clarify:

  • Why the target-set composition changes from 23/16/15 to 23/18/13 in the alternative pretraining experiment;
  • Which target datasets are excluded or replaced when FB15k-237 and CoDEx-M are used for pretraining;
  • Whether the prediction target triple and its inverse edge are removed from the reasoning context during training;
  • Whether support sampling strictly uses only facts permitted by the evaluation protocol.
5 comments

We sincerely thank the reviewer for the thorough comments and for recognizing our well-motivated transfer mechanism and broad evaluation. The two central questions are whether the input representation preserves relational composition, and whether the gains come from discrete abstraction rather than additional computation. We address each comment point by point below.

W1. Method specification of relational composition and grammar matching

Thank you for raising these concerns. We clarify the method specification in two parts: (1) how relational information is preserved in Eq. (4) and (2) how attention-based matching is implemented in Eq. (16).

Part 1: Preservation of relational information in Eq. (4). The tokenization in Eq. (4) is designed to be identity-independent: since relation identities are not shared across KGs, the tokens encode only transferable structural roles, and relation identity is re-attached during the aggregation in Eq. (12).

  • Token sequence. For a support fact (u,rq,v)(u, r_q, v), and the chain u→r1e1→rqe2→r1e3→r2e4u \xrightarrow{r_1} e_1 \xrightarrow{r_q} e_2 \xrightarrow{r_1} e_3 \xrightarrow{r_2} e_4. Eq. (4) maps it to

[ x(δ0), y10, x(δ1), y21, x(δ2), y30, x(δ3), y40, x(δ4) ],[\ x(\delta_0),\ y_1^{0},\ x(\delta_1),\ y_2^{1},\ x(\delta_2),\ y_3^{0},\ x(\delta_3),\ y_4^{0},\ x(\delta_4)\ ],

where x(δk)=Eent[δk]+tentx(\delta_k)=E_{ent}[\delta_k]+t_{ent} with δk=(min⁡(d(ek,u),3), min⁡(d(ek,v),3))\delta_k=(\min(d(e_k,u),3),\ \min(d(e_k,v),3)), and ykm=trel+pk+m⋅eqryy_k^{m}=t_{rel}+p_k+m\cdot e_{qry} with m=1[rk=rq]m=\mathbb 1[r_k=r_q]. Each relation rr has an inverse r−1r^{-1} as a separate relation, so direction is represented by relation identity. The tokens mark only whether a relation equals rqr_q.

  • Where relational identity enters. In Eq. (12), token states are aggregated by relation identity, so positions occupied by the same relation are pooled into the same slot, and forward and inverse relations fall into separate slots. In the example, positions 1 and 3 are pooled into the slot of r1r_1 and position 4 into that of r2r_2.
  • Query relation in the probe. AA, BB, and rqr_q are assigned three distinct relation IDs. The AAAB, AABA, and ABAA chains therefore carry no query marker and have identical token sequences, so they can only be distinguished through the slot aggregation in Eq. (12). The probe thus tests relational composition rather than the position of a query marker.

Part 2: Attention-based matching in Eq. (16). We apologize for the confusion caused by the oversimplified notation in Eq. (16). In fact, in our code, the grammar pattern is not a single key but is expanded into four pattern tokens, so the reported results are unaffected. Specifically, the patterns hrpat∈Rdh_r^{pat}\in\mathbb R^{d} from Eq. (12) are averaged into uq∈Rdu_q\in\mathbb R^{d} and expanded into Pq∈R4×dP_q\in\mathbb R^{4\times d}:

uq=1∣R∣∑r∈Rhrpat,Pq=Reshape(Wpuq)+O,an=MHA(gn,Pq,Pq),u_q=\frac{1}{|\mathcal R|}\sum_{r\in\mathcal R}h_r^{pat},\qquad P_q=\mathrm{Reshape}(W_p u_q)+O,\qquad a_n=\mathrm{MHA}(g_n,P_q,P_q),

where Wp∈R4d×dW_p\in\mathbb R^{4d\times d} and O∈R4×dO\in\mathbb R^{4\times d} are learnable. The attention weights depend on both the query chain gng_n and PqP_q, so each chain obtains its own readout ana_n of the support grammar, which is then scored by fmatch([gn∥an∥gn⊙an])f_{match}([g_n\Vert a_n\Vert g_n\odot a_n]). Removing this matching while keeping the chain branch (M4-C in W2 Part 2) reduces overall MRR from 0.3973 to 0.3947.

We have revised Eq. (16) in Sec. 3.3 to match the implementation.

W2. Disentangling the grammar mechanism from chain modeling and additional computation

Thank you for this valuable feedback. We (1) clarify the definitions of M1 and M4, (2) add controls for grammar guidance and discrete abstraction, (3) report parameter and inference costs, and (4) report multi-seed results.

Part 1: Definitions of M1 and M4.

  • M1 (w/o chain reasoning) measures the overall contribution of chain-based reasoning. It removes both the grammar encoder (Eqs. 2–12) and the chain reasoner (Eqs. 15–18), so predictions are made solely by the base query-conditioned GNN.
  • M4 (w/o grammar-guided reasoner) measures the contribution of query-side chain grammar. It keeps the grammar encoder for relation initialization and removes only the query-chain reasoner and its score correction (Eqs. 15–18).

Part 2: Contribution of grammar guidance and discrete abstraction. We add three controls that change only one component at a time:

  • M4-U and M4-C keep the query-chain reasoner and its score correction but remove grammar matching, using uniform weights or weights learned from the chain representation alone.
  • M5 removes both word-level and chain-level vector quantization and uses continuous representations instead, serving as a directly comparable continuous chain model.

M4-U and M4-C bring only marginal gains over M4 despite keeping the chain branch, and M5 underperforms the full model, showing that the gains come from grammar guidance and discrete abstraction rather than continuous chain encoding.

VariantInd-E,R MRRInd-E,R H@10Ind-E MRRInd-E H@10Trans MRRTrans H@10Overall MRROverall H@10
M1: w/o chain reasoning0.41070.58970.41120.54370.32280.46700.38640.5420
M4: w/o grammar-guided reasoner0.41940.60580.41650.55570.32510.46340.39230.5514
M4-U: uniform chain weights0.41980.60270.42010.55530.32380.46870.39320.5514
M4-C: chain-only weights0.42270.60460.42040.55540.32430.46800.39470.5521
M5: continuous (w/o both VQ levels)0.41770.59150.41730.55000.31360.46830.38870.5450
ChainGram (full)0.42470.60690.42270.55620.32800.47250.39730.5546

Part 3: Parameter and computational cost. ChainGram is computationally efficient. On 10 inductive KGs with an A100 GPU, the chain components add about 0.24M parameters over M1 but increase inference time by only 4.0%. M5 has nearly the same cost as the full model, so discrete abstraction brings its gains at negligible extra cost.

Variant#ParamsTotal time (10 KGs)Time per query group
M1: w/o chain reasoning142,392140.87 s4.108 ms
M4: w/o grammar-guided reasoner294,604143.50 s4.185 ms
M5: continuous (w/o both VQ levels)374,974146.30 s4.266 ms
ChainGram (full)381,886146.44 s4.270 ms

Part 4: Statistical robustness. We run ChainGram with three random seeds and report the zero-shot results below. The overall MRR of ChainGram (0.3980 ± 0.0013) exceeds that of the strongest baseline KG-ICL (0.3864) by a margin far larger than its standard deviation.

MetricInd-E,RInd-ETransOverall
MRR0.4260 ± 0.00140.4228 ± 0.00100.3289 ± 0.00130.3980 ± 0.0013
H@100.6068 ± 0.00120.5556 ± 0.00080.4734 ± 0.00280.5546 ± 0.0015

We have clarified the definitions of M1 and M4 in Sec. 4.4 and added these variants to Appendix D.4 of the revised manuscript.

Q1. Relational information preserved by Eq. (4)

Thank you for this question. As it is closely related to W1 Part 1, we briefly answer each of its three sub-questions below.

  • (1) Equality or differences among non-query relations. The tokens do not encode equality among non-query relations; instead, relational identity is recovered through the slot aggregation in Eq. (12), where positions occupied by the same relation are pooled into the same slot.
  • (2) Forward and inverse relations. Each relation is augmented with an inverse relation as a separate relation, so direction is represented by relation identity and preserved in separate slots.
  • (3) Query relation in the probe. rqr_q is randomly assigned a relation ID distinct from both AA and BB, so the three patterns can only be distinguished through relational composition rather than a query marker.

For the complete token sequence of a concrete example and further details, please kindly refer to W1 Part 1.

Q2. Tensor shapes in Eqs. (12) and (16)

Thank you for this question. As it is closely related to W1 Part 2, we briefly clarify the tensor shapes and the construction of the pattern tokens below.

  • (1) Single vector or collection. Eq. (12) produces a pattern hrpat∈Rdh^{pat}_r\in\mathbb R^{d} for every relation, and the attention in Eq. (16) operates over a collection of four pattern tokens Pq∈R4×dP_q\in\mathbb R^{4\times d} rather than a single vector.
  • (2) Construction and aggregation. The patterns of all relations are averaged into a summary uq∈Rdu_q\in\mathbb R^{d}, which is then expanded into the four tokens through a learnable projection with token offsets.

For the full formulation, please kindly refer to W1 Part 2.

Q3. Robustness of the hierarchical discrete mechanism

Thank you for this question. We have conducted additional ablations, cost measurements, and multi-seed experiments, which are detailed in W2. We summarize the answers to each requested item below.

  • (1) Distinction between M1 and M4. M1 removes all chain components, whereas M4 keeps the grammar encoder and removes only the query-chain reasoner.
  • (2) Comparable continuous chain control. M5 replaces both levels of vector quantization with continuous representations and underperforms the full model.
  • (3) Parameter counts and inference costs. M5 has nearly the same cost as the full model, and ChainGram increases inference time by only 4.0% over M1.
  • (4) Multiple random seeds. Over three seeds, ChainGram achieves an overall MRR of 0.3980 ± 0.0013, well above the strongest baseline.

For the detailed results, please kindly refer to W2 Parts 1–4.

Q4. Evaluation sets and access to graph information

Thank you for these questions. We clarify the target-set composition under the alternative pretraining setting, the removal of target triples during training, and the graph information used for support sampling below.

(1)–(2) Target-set composition and replaced datasets. Under the alternative setting, FB15k-237, WN18RR, and CoDEx-M replace FB-v1, NELL-v1, and CoDEx-S as pretraining KGs, so these six KGs swap their pretraining and target roles:

Target groupMain → AlternativeAdded datasetsRemoved datasets
Inductive-E,R23 → 23––
Inductive-E16 → 18FB-v1, NELL-v1–
Transductive15 → 13CoDEx-SFB15k-237, WN18RR, CoDEx-M
Overall54 → 543 KGs3 KGs

(3) Removal of target triples. During training, the target triple and its inverse edge are removed from the graph used for GNN message passing, and query-rooted chains that traverse either edge are discarded.

(4) Support sampling. Following KG-ICL [1], support facts and their chains are sampled only from the observed graph of each KG under the evaluation protocol, i.e., the training graph for transductive KGs and the inference graph for inductive KGs. Validation and test triples are never used as support facts.

We thank the reviewer again for the valuable comments, which have helped us improve the clarity and rigor of the paper.

[1] Yuanning Cui, Zequn Sun, and Wei Hu. A Prompt-Based Knowledge Graph Foundation Model for Universal In-Context Reasoning. Advances in Neural Information Processing Systems, 37:7095–7124, 2024.

Reviewer_fkMAOpenReview ↗
Rating
2
Confidence
4
Informativeness
2
Presentation
2
Soundness
2
Read review
Paper summary

ChainGram learns a transferable structural grammar from relational chains for knowledge graph foundation models. It uses query-relative structural tokens, word-level and chain-level codebooks, and grammar-guided chain matching for entity prediction. Experiments on 54 target KGs show improvements over existing methods under both zero-shot and full fine-tuning protocols.

Critical strengths

1.Insightful hierarchical design. The Hierarchical Grammar Encoder organizes structural information into local structural roles, chain-level prototypes, and relation-specific grammar patterns. This design explicitly organizes structural patterns into a shared vocabulary and relation-specific grammar patterns for cross-KG reasoning.

2.Notable performance improvements. ChainGram achieves the best aggregate results across all six evaluation settings on 54 target KGs, with relative overall MRR gains over the strongest baseline of 2.82% under zero-shot inference and 5.84% after full fine-tuning.

3.Analysis of learned patterns. The paper examines prototype separability, chain-weight relevance, codebook utilization, and cross-KG pattern consistency. The controlled synthetic experiment provides evidence that the model preserves the tested four-hop patterns across different relation identities.

Critical weaknesses

1.The ablations do not clearly establish the contribution of the proposed components. The distinction between M1 and M4 is unclear. The paper should specify which modules are removed in M1 and how it differs from M4. In M4, removing grammar-guided chain matching also removes the query-chain score correction, so this comparison does not isolate the benefit of grammar guidance over simpler chain aggregation. Moreover, the chain-level perturbation in Fig. D.3(b) causes little MRR change, which does not clearly support the stated claim.

2.Lack of hyperparameter sensitivity analysis. The model uses four-hop support chains and query-rooted chains, but no results for other chain lengths are reported. The paper also does not examine sensitivity to the number of sampled chains or the word-level and chain-level codebook sizes. It is therefore unclear whether the reported gains are robust to these choices, especially across KGs with different structural properties.

3.Incomplete comparison under the standard pretraining configuration. The main experiments use FB-v1, NELL-v1, and CoDEx-S, rather than the commonly used FB15k-237, WN18RR, and CoDEx-M configuration. Although all methods share the same pretraining data in the main experiments, Table D.7 evaluates the alternative configuration only for five structure-based baselines under zero-shot inference. Comparisons with ProLink, SEMMA, and KRLM, as well as full fine-tuning results for all models under this configuration, are missing. It therefore remains unclear whether ChainGram’s reported advantages hold across baseline families and evaluation protocols when this pretraining configuration is used.

4.Missing discussion of closely related in-context learning work. ChainGram constructs relation-specific support contexts from observed triples sharing the query relation. The use of observed triples sharing the query relation as support contextis closely related to KGPFN, which also uses instances of the query relation and their local neighborhoods for in-context learning. Although the paper discusses KG-ICL, it does not address KGPFN. The authors should cite KGPFN and clarify the methodological differences between KGPFN and ChainGram, particularly in how they construct and use relation-specific context.

Questions for authors

Please see the Weaknesses.

3 comments

We sincerely thank the reviewer for the detailed and constructive comments, and for recognizing the insightful hierarchical design, the notable performance improvements, and the analysis of learned patterns in ChainGram. We address each concern point by point below.

W1. Clarity of the ablation study

To address the concerns about the ablation study, we have made two improvements: (1) clarified the definitions of M1 and M4, (2) added fine-grained ablations on grammar guidance and discrete abstraction. We have also revised the claim about the chain-level perturbation.

(1) Definitions of M1 and M4.

  • M1 (w/o chain reasoning) measures the overall contribution of chain-based reasoning. It removes all chain components, including both the grammar encoder (Eqs. 2–12) and the chain reasoner (Eqs. 15–18). Consequently, relation representations are no longer initialized from grammar patterns, and predictions are made solely by the base query-conditioned GNN.

  • M4 (w/o grammar-guided reasoner) measures the contribution of query-side chain grammar. It retains the grammar encoder and removes only the query-chain reasoner together with its score correction (Eqs. 15-18).

(2) Fine-grained ablations of grammar guidance and discrete abstraction. To address the concern that M4 removes the score correction together with grammar guidance, we add three variants that change only one component at a time:

  • M4-U (uniform weights) retains the query-chain reasoner and its score correction but removes grammar matching, assigning equal weights to all valid query chains.
  • M4-C (chain-only weights) retains the query-chain reasoner and its score correction but removes grammar matching and learns chain weights from the query-chain representation alone, ωn=softmax(MLP(gn))\omega_n=\mathrm{softmax}(\mathrm{MLP}(g_n)).
  • M5 (continuous) removes both word-level and chain-level vector quantization and uses continuous representations instead.

As shown below, all three variants underperform the full model. M4-U and M4-C bring only marginal gains over M4, indicating that grammar guidance provides additional benefits beyond simple chain aggregation. M5 performs worse than removing either quantization level alone (M2: 0.3904, M3: 0.3936), demonstrating that discrete abstraction contributes beyond continuous chain encoding.

VariantInd-E,R MRRInd-E,R H@10Ind-E MRRInd-E H@10Trans MRRTrans H@10Overall MRROverall H@10
M1: w/o chain reasoning0.41070.58970.41120.54370.32280.46700.38640.5420
M4: w/o grammar-guided reasoner0.41940.60580.41650.55570.32510.46340.39230.5514
M4-U: uniform chain weights0.41980.60270.42010.55530.32380.46870.39320.5514
M4-C: chain-only weights0.42270.60460.42040.55540.32430.46800.39470.5521
M5: continuous (w/o both VQ levels)0.41770.59150.41730.55000.31360.46830.38870.5450
ChainGram (full)0.42470.60690.42270.55620.32800.47250.39730.5546

We have clarified the definitions of M1 and M4 in Sec. 4.4 and added variants to Table D.8 of the revised manuscript.

Chain-level perturbation in Fig. D.3(b). We have revised the corresponding statement in Appendix D.3.4. The contribution of chain-level prototypes is better reflected by retraining without them (M3), which reduces overall MRR from 0.3973 to 0.3936.

W2. Hyperparameter sensitivity

Thank you for this insightful suggestion. We have added a sensitivity analysis on the chain length, the numbers of sampled support and query chains, and the sizes of the word-level and chain-level codebooks, varying one hyperparameter at a time while keeping the others at their default values.

ChainGram is robust to all four hyperparameters: across the 13 configurations, overall MRR varies by less than 0.005 and always remains above the strongest baseline KG-ICL (0.3864). Chain length has the most visible effect across transfer settings, where Inductive-E,R performs best with L=5L=5 and Transductive with L=3L=3. The overall zero-shot results are summarized below.

HyperparameterValueOverall MRROverall H@10
Chain length LL20.39670.5539
30.39870.5525
40.39730.5546
50.39950.5553
Sampled chains NsN_s / NqN_q16 / 320.40090.5561
32 / 640.39730.5546
64 / 1280.39660.5557
128 / 2560.39960.5578
Word codebook size320.39830.5532
640.39730.5546
1280.39980.5552
2560.40020.5583
Chain codebook size40.39880.5563
80.40120.5564
160.39730.5546
320.39910.5576

We have added this analysis to Sec. 4.6 of the revised manuscript, with the per-setting results provided in Appendix D.6.

W3. Comparison under the standard pretraining configuration

Thank you for this valuable suggestion. We have extended the comparison under the FB15k-237, WN18RR, and CoDEx-M pretraining datasets with the LLM-enhanced baselines (ProLINK, SEMMA, and KRLM) and full fine-tuning results for all models.

ChainGram achieves the best overall MRR and Hits@10 under both zero-shot inference and fine-tuning, outperforming both structure-based and LLM-enhanced baselines. This indicates that its advantage holds across baseline families under the standard pretraining configuration. The overall results are summarized below.

ModelZS MRRZS H@10FT MRRFT H@10
ULTRA0.35510.50960.40780.5617
KG-ICL0.40990.56680.44010.5906
TRIX0.39010.54800.41770.5691
MOTIF0.36590.52080.41670.5685
FLOCK0.39000.55310.42750.5826
ProLINK0.35470.50940.39590.5487
SEMMA0.37410.52600.44470.5980
KRLM0.38030.54000.42310.5825
ChainGram0.41650.57480.45310.6033

We have added the detailed zero-shot results under this configuration to Table 2 in the main text, and updated both the zero-shot and full fine-tuning results in Appendix Table D.9 (Appendix D.5.1) of the revised manuscript.

W4. Discussion of KGPFN

Thank you for bringing this meaningful work [1] to our attention. We have cited KGPFN in the Introduction section and added a discussion of it to the Related Work (Appendix A) of the revised manuscript.

Both methods use observed instances of the query relation as context, but KGPFN captures structural patterns in continuous neighborhood features, whereas ChainGram represents them explicitly as relational chains abstracted into discrete units shared across KGs. Specifically:

  • Context construction. KGPFN encodes labeled positive and negative triples with head-centric NBFNet features, whereas ChainGram abstracts chains around positive support facts via two-level codebooks.
  • Context usage. KGPFN uses the context to score candidates in a prior-fitted transformer, whereas ChainGram uses it to initialize relations and select query-specific chain evidence.

We thank the reviewer again for the valuable comments, which have helped us improve the completeness of the paper.

[1] Yisen Gao, Jiaxin Bai, Haoyu Huang, Zhongwei Xie, Yufei Li, Hong Ting Tsang, Sirui Han, and Yangqiu Song. KGPFN: Unlocking the Potential of Knowledge Graph Foundation Model via In-Context Learning. arXiv preprint arXiv:2605.14907, 2026.

Dear Reviewer,

We sincerely thank you for your time and valuable feedback.

We have posted our detailed responses to your comments and submitted a revised manuscript. With three days left in the discussion period, we would appreciate your feedback on whether these responses and revisions resolve your concerns.

We would be happy to provide any further clarification if needed.

Thank you again for your consideration.

Best regards,

Authors

Reviewer_BiN1OpenReview ↗
Rating
3
Confidence
3
Informativeness
2
Presentation
2
Soundness
2
Read review
Paper summary

This paper proposes ChainGram, a chain-based knowledge graph foundation model (KGFM) that aims to explicitly capture and reuse invariant structural patterns across knowledge graphs. The authors argue that existing KGFMs typically encode such patterns implicitly in learned representations, making them difficult to identify and organize for transferable reasoning. Inspired by natural language grammar, ChainGram introduces a hierarchical framework that abstracts relational chains into reusable structural patterns and uses them to guide query-specific entity prediction. The authors evaluate ChainGram on 54 target KGs across three transfer settings, considering both zero-shot inference and full fine-tuning. ChainGram achieves the best aggregate performance among the compared methods, with relative improvements of 2.82% and 5.84% in overall MRR over the strongest baseline under zero-shot and full fine-tuning, respectively. Additional experiments investigate the transferability of learned structural patterns and the contributions of individual components.

Critical strengths
  1. Transferable reasoning across heterogeneous knowledge graphs is an important problem for KGFMs. Moving beyond implicit structural representations toward explicitly modeled and reusable structural patterns is an interesting research direction.

  2. The combination of word-level structural codes, chain-level prototypes, and relation-specific pattern aggregation provides a clear representation hierarchy. Integrating these abstractions with query-dependent chain evidence is a well-motivated architectural design.

Critical weaknesses
  1. Although KG-ICL achieves the highest overall MRR among the baselines in both the zero-shot and full fine-tuning settings in Table 1, the per-dataset comparisons in Fig. 3, Fig. D.1, and Table D.6 only include FLOCK and KRLM. This makes it difficult to assess whether ChainGram's improvements over KG-ICL are consistent across different KGs or concentrated in a subset of datasets. Including per-dataset results for KG-ICL would provide stronger support for the claimed robustness of cross-KG generalization.

  2. Table D.6 reports zero-shot results for KRLM on AristoV4, whereas Appendix D.5.3 states that this result is unavailable and excludes it from the zero-shot analysis. The authors should clarify this discrepancy and verify whether the reported aggregate results are affected.

Questions for authors
  1. Eq 12 constructs grammar patterns from support chains sampled for the query relation, whereas Eq 13 requires representations for the relations involved in GNN message passing. How does the model handle relations that are not covered by the sampled support chains? Are their grammar patterns precomputed, constructed on demand, or initialized using a default representation?

  2. In Eq 16, the relation-specific grammar pattern appears to be represented by a single vector. If it is used as a single key/value token, the attention weight is necessarily one, making the MHA output independent of the query-chain representation gng_n. Could the authors clarify the actual tensor shape of the grammar pattern and explain what role MHA plays in query-dependent chain matching?

3 comments

We sincerely appreciate the reviewer for the constructive feedback and positive assessment of ChainGram. We address each comment point by point below.

W1. Per-dataset comparison with KG-ICL

Thank you for this valuable suggestion. We re-ran KG-ICL and compared it with ChainGram on each of the 54 target KGs under both zero-shot inference and full fine-tuning.

The results are summarized below. ChainGram performs on par with or better than KG-ICL on 36 of the 54 KGs (67%) under zero-shot inference and on 46 of the 54 KGs (85%) after fine-tuning. These results indicate that its improvements are not concentrated in a small subset of KGs, supporting the robustness of its cross-KG generalization. Detailed per-dataset results are provided in Table D.7.

Transfer settingZero-shot (≥ / <)Fine-tuning (≥ / <)
Inductive-E,R (23)16 / 722 / 1
Inductive-E (16)11 / 513 / 3
Transductive (15)9 / 611 / 4
Overall (54)36 / 1846 / 8

We have added KG-ICL to the per-dataset comparisons in Fig. 3 and Fig. D.1, and to the newly added Table D.7 of the revised manuscript.

W2. KRLM on AristoV4

Thank you for pointing out this inconsistency. It arose from an oversight in Appendix D.5.3, where KRLM's zero-shot result on AristoV4 was mistakenly treated as unavailable. In fact, only its fine-tuned result is unavailable due to OOM, as stated in Appendix D.2. For ease of reference, we list the result below.

KRLM on AristoV4MRRHits@10
Zero-shot0.2280.343
Fine-tuningN/A (OOM)N/A (OOM)

Including this result in the aggregates slightly changes KRLM's relative MRR drop on text-missing KGs, and the average degradation of LLM-enhanced methods changes from 43.0% to 43.1%, which does not affect the conclusion.

ModelRelative MRR drop (original)Relative MRR drop (corrected)
KRLM44.10%44.33%
LLM-enhanced average43.0%43.1%

We have corrected the description and included AristoV4 in all KRLM aggregates of Appendix D.5.3, and updated the corresponding numbers in Fig. D.6 of the revised manuscript. We thank the reviewer again for the careful check, which has helped us improve the consistency of the paper.

Q1. Relations not covered by support chains (Eqs. 12–13)

Thank you for this question. Relations not covered by the sampled support chains are initialized with a default representation; their grammar patterns are neither precomputed nor constructed on demand.

In Eq. 12, the weighted relation states are aggregated by relation slot, so that every relation rr in the KG obtains its own pattern:

hrpat=1M∑i=1MSi,rmax⁡(wi,r,1),h_r^{pat}=\frac{1}{M}\sum_{i=1}^{M}\frac{S_{i,r}}{\max(w_{i,r},1)},

where Si,rS_{i,r} is the weighted sum of the states of relation rr in the support chains of the ii-th support fact, and wi,rw_{i,r} is the corresponding total weight. For an uncovered relation, Si,r=wi,r=0S_{i,r}=w_{i,r}=0 and thus hrpat=0h^{pat}_r=\mathbf 0, which Eq. 13 maps to a shared learned default representation.

We have revised Eq. 12 to define hrpath_r^{pat} for every relation rather than only hrqpath_{r_q}^{pat}, and clarified this initialization around Eqs. 12–13 in Sec. 3.2–3.3 of the revised manuscript.

Q2. Tensor shapes and the role of MHA in Eq. (16)

Thank you for this question, and we apologize for the confusion caused by the oversimplified notation in Eq. (16). In fact, in our uploaded code, the grammar pattern is not used as a single key; instead, it is summarized and expanded into four pattern tokens over which each query chain attends. All reported results are therefore unaffected.

Specifically, the patterns from Eq. (12) are averaged into a summary uq∈Rdu_q\in\mathbb R^{d} and expanded into tokens Pq∈R4×dP_q\in\mathbb R^{4\times d}, and each query chain gn∈Rdg_n\in\mathbb R^{d} attends over them:

uq=1∣R∣∑r∈Rhrpat,Pq=Reshape(Wpuq)+O,an=MHA(gn,Pq,Pq),u_q=\frac{1}{|\mathcal R|}\sum_{r\in\mathcal R}h^{pat}_r,\qquad P_q=\mathrm{Reshape}(W_p u_q)+O,\qquad a_n=\mathrm{MHA}(g_n,P_q,P_q),

where Wp∈R4d×dW_p\in\mathbb R^{4d\times d} and O∈R4×dO\in\mathbb R^{4\times d} are learnable. Since the attention weights depend on both gng_n and PqP_q, different query chains obtain different readouts an∈Rda_n\in\mathbb R^{d}, which are then scored by fmatch([gn∥an∥gn⊙an])f_{match}([g_n\|a_n\|g_n\odot a_n]). As the four tokens are derived from the same summary, we describe them as learned views of the support grammar rather than independent patterns.

We have revised Eq. (16) in Sec. 3.3 to include this token expansion and state the tensor shapes. We thank the reviewer again for helping us improve the precision of our method description.

AuthorsOpenReview ↗

Supplement for Per-dataset comparison with KG-ICL

Supplement to W1: Per-dataset MRR comparison with KG-ICL

Following the reviewer's suggestion, we list the per-dataset MRR of KG-ICL and ChainGram on all 54 target KGs below. The better result under each protocol is shown in bold. Hits@10 results are provided in Table D.7 of the revised manuscript.

SettingKGKG-ICL (ZS)ChainGram (ZS)KG-ICL (FT)ChainGram (FT)
Inductive-E,RWK-250.4290.4290.4300.431
WK-500.2720.2710.2090.275
WK-750.4450.4520.4270.457
WK-1000.2700.2610.2810.267
FB-250.4050.4180.4200.430
FB-500.3490.3540.3720.373
FB-750.4380.4350.4340.438
FB-1000.4980.4940.4910.496
NL-00.5580.5700.5500.567
NL-250.5120.5040.5170.540
NL-500.5230.5300.5130.527
NL-750.4640.4640.4420.461
NL-1000.5640.5530.5490.557
MT1 tax0.2990.3640.3660.418
MT1 health0.3790.3800.3530.396
MT2 sci0.2500.3280.2890.385
MT2 org0.0920.0920.0990.102
MT3 art0.2520.2670.2540.314
MT3 infra0.6360.6480.6500.697
MT4 sci0.3010.3030.2670.312
MT4 health0.6770.6710.5570.712
Metafam0.3920.4580.9991.000
FBNELL0.5050.5200.5200.524
Inductive-EHM Indigo0.3570.3520.3710.387
HM 5k0.0510.0560.0520.059
HM 3k0.0580.0590.0620.057
HM 1k0.0630.0650.0560.052
ILPC2022 Large0.2790.2780.3150.327
ILPC2022 Small0.2990.3000.3160.321
FB-v20.5410.5390.5500.549
FB-v30.5080.5090.5140.515
FB-v40.4920.4900.5010.504
WN-v10.6400.6700.7070.717
WN-v20.6480.6610.6920.702
WN-v30.3810.3990.4390.445
WN-v40.5960.6030.6480.659
NL-v20.6030.5990.5980.606
NL-v30.5860.6150.5830.610
NL-v40.5570.5690.5560.567
TransductiveFB15k-2370.3530.3470.3410.394
WN18RR0.4280.4590.5360.570
CoDEx Medium0.3410.3270.3590.384
WDsinger0.4540.4780.4930.495
NELL23k0.3200.2760.3290.285
FB15k-237(10)0.2570.1720.2610.175
FB15k-237(20)0.2720.1860.2820.198
FB15k-237(50)0.3230.2330.3350.249
NELL9950.4870.5140.5240.547
ConceptNet100k0.2430.2880.3750.390
AristoV40.1660.2320.3720.452
YAGO3100.3570.4010.5550.583
CoDEx Large0.2920.2970.3400.358
DBpedia100k0.4130.4320.4780.512
Hetionet0.2440.2770.1320.427

Dear Reviewer,

We sincerely thank you for your time and valuable feedback.

We have posted our detailed responses to your comments and submitted a revised manuscript. With three days left in the discussion period, we would appreciate your feedback on whether these responses and revisions resolve your concerns.

If any questions or concerns remain, please let us know. We would be happy to address them promptly.

Thank you again for your consideration.

Best regards,

Authors

Comments on the paper

1 comment
AuthorsOpenReview ↗

General Response by Authors

General Response by Authors

Dear Program Chairs, Area Chair, and Reviewers, we sincerely appreciate the time and effort that all reviewers have devoted to evaluating our submission. We are grateful that the reviewers have recognized the strengths of our work in terms of problem motivation, methodological design, and experimental results. We have carefully considered all comments and conducted additional experiments and analyses to address the concerns. Below, we summarize the acknowledged strengths of our work and our responses to the common questions.

Reviewer Acknowledgment

We are grateful that all reviewers have recognized the following strengths of our work:

1. Motivation: Addressing an important problem in transferable reasoning across knowledge graphs.

  • Reviewer BiN1: "Transferable reasoning across heterogeneous knowledge graphs is an important problem for KGFMs..."
  • Reviewer BiN1: "Moving beyond implicit structural representations toward explicitly modeled and reusable structural patterns is an interesting research direction."
  • Reviewer 766C: "...entity and relation identities need not be shared, whereas structural patterns may be transferable."

2. Methodology: Well-designed hierarchical structural grammar and reasoning framework.

  • Reviewer BiN1: "The combination of word-level structural codes, chain-level prototypes, and relation-specific pattern aggregation provides a clear representation hierarchy..."
  • Reviewer fkMA: "Insightful hierarchical design... that organizes structural information into local structural roles, chain-level prototypes, and relation-specific grammar patterns."
  • Reviewer 766C: "The hierarchical codebooks organize local relational roles and whole-chain patterns into shared structural units..."

3. Experimental Results: Broad evaluation and comprehensive evidence of structural pattern learning.

  • Reviewer BiN1: "ChainGram achieves the best aggregate performance... with relative improvements of 2.82% and 5.84% in overall MRR..."
  • Reviewer fkMA: "The controlled synthetic experiment provides evidence that the model preserves the tested four-hop patterns across different relation identities."
  • Reviewer 766C: "The main evaluation covers 54 target benchmark configurations... the aggregate results... consistently favor the complete model."

Common Questions

We thank the reviewers for their constructive feedback. We have conducted additional experiments and clarified the methodology to address the following concerns.

Q1. Experimental robustness and the contributions of the proposed components (BiN1, fkMA, 766C).

We have expanded our experimental evaluation with additional baseline comparisons, fine-grained ablations, hyperparameter sensitivity analyses, and multi-seed experiments. The results demonstrate strong performance and robustness across diverse knowledge graphs and evaluation settings, providing further evidence of the effectiveness of our proposed approach.

Q2. Clarification of the structural grammar representation and matching mechanism (BiN1, 766C).

We have further clarified the formulation and implementation of ChainGram's structural grammar, including the construction of relation-specific patterns and the query-dependent matching mechanism. We have also revised the relevant equations and descriptions to improve the clarity and precision of the methodology.

Detailed point-by-point responses and additional experimental results are provided in our individual replies.

We sincerely thank all reviewers for their thoughtful feedback and constructive suggestions. We have provided detailed point-by-point responses to each reviewer and submitted a revised manuscript incorporating the corresponding changes. We hope our responses and revisions address the concerns raised, and would greatly appreciate it if the reviewers could revisit them and share any further thoughts or remaining concerns. We would be happy to provide additional clarifications if needed.

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Related papers

Loading the map…

Discussion (0)

Sign in to comment.