Knowledge graph embedding (KGE) models perform well on link prediction but struggle with unseen entities, relations, and especially literals, limiting their use in dynamic, heterogeneous graphs. In contrast, pretrained large language models (LLMs) generalize effectively through prompting. We reformulate link prediction as a prompt learning problem and introduce RALP, which learns string-based chain-of-thought (CoT) prompts as scoring functions for triples. Using Bayesian Optimization through MIPRO algorithm, RALP identifies effective prompts from fewer than 30 training examples without gradient access. At inference, RALP predicts missing entities, relations or whole triples and assigns confidence scores based on the learned prompt. We evaluate on transductive, numerical, and OWL instance retrieval benchmarks. RALP improves state-of-the-art KGE models by over 5% MRR across datasets and enhances generalization via high-quality inferred triples. On OWL reasoning tasks with complex class expressions (e.g., ∃hasChild.Female, ≥5hasChild.Female), it achieves over 88% Jaccard similarity. These results highlight prompt-based LLM reasoning as a flexible alternative to embedding-based methods. We release our implementation, training, and evaluation pipeline as open source: https://github.com/dice-group/RALP .
Figures & tables
Figure 1: Overview of the RALP framework in three different tasks within the link prediction problem. Notice that sampling of triples or MIPRO optimization can be performed in all three of them but is omitted because of space limitations.
Models
S1
S2
S3
MRR
@1
@3
@10
MRR
@1
@3
@10
MRR
@1
@3
@10
\textscRALP† light
0.979
0.958
1.000
1.000
0.750
0.500
1.000
1.000
0.595
0.375
0.791
0.833
\textscRALP† medium
1.000
1.000
1.000
1.000
0.750
0.500
1.000
1.000
0.764
0.541
1.000
1.000
Table 1: Link prediction results of \textscRALP† on Countries-S1, Countries-S2, and Countries-S3. RALP single Bold and underlined results indicate the best results and second best results.
Models
S1
S2
S3
MRR
@1
@3
@10
MRR
@1
@3
@10
MRR
@1
@3
@10
DistMult
0.783
0.583
0.979
1.000
0.582
0.583
0.667
0.958
0.283
0.104
0.375
0.604
DistMult- RALP
0.990
0.979
1.000
1.000
0.753
0.458
0.938
0.958
0.670
0.542
0.771
0.896
Keci
0.716
0.479
0.917
1.000
0.627
0.501
0.667
0.896
0.292
0.188
0.333
0.583
Keci- RALP
1.000
1.000
1.000
1.000
0.596
0.521
0.696
0.950
0.667
0.500
0.771
0.917
DeCaL
0.712
0.500
0.896
0.979
0.481
0.271
0.708
0.812
0.312
0.188
0.354
0.583
Table 2: Link prediction results on Countries-S1, Countries-S2, and Countries-S3. Link prediction results on the training and testing datasets are denoted with train and test. Bold results indicate the best generalization performance of a respective model.
Data Property
yavg
σ
y^avg
ICR
IW
population
60923964
± 3 44077886
58504042
0.90
167280658
age_of_majority_years_old
18.3
± 1.1
18.1
0.90
3.175
total_fertility_rate
3.029
± 1.435
2.756
0.80
2.709
nominal_gdp_per_capita_usd
11510
±19408
11034
0.75
15140
human_development_index
0.677
± 0.145
0.698
0.79
0.236
life_expectancy_second
2220348629
±236968936
2204513934
0.81
640296028
Table 3: Numerical link prediction results in LitWD1K dataset. The shown data properties are selected randomly without replacement for the illustration purposes. We predict y^ together with interval bounds y^max and y^min . For our evaluation we measure the mean value of y , standard deviation σ , the mean value of y^ and for the interval prediction, we measure interval coverage rate (ICR) for calibration and interval width (IW) for sharpness.
Figure 2: RALP predictions for the human_development_index property (P1081) in LitWD1K dataset. Ground truth depicted in black dots, regression prediction in blue cross and interval range in teal lines. For this property we report a mean squared error of 0.006 and a mean absolute error of 0.059. Some countries are omitted from the plot because of the limited space.
Concept Types
#
Namespace
No Namespace
M
DL
M
DL
Atomic
3
1.000
1.000
1.000
1.000
Negation
55
0.887
0.803
0.869
0.801
Conjunction
19
0.986
0.881
0.973
0.973
Disjunction
33
0.984
0.775
0.969
0.818
Existential
44
0.656
0.700
0.673
0.764
Table 4: Results of instance retrieval on Father datasets using RALP. We show the mean Jaccard similarity measured between the true set and the predicted set for each concept type where ’#’ denotes the number of concepts per concept type, ’Namespace’ denotes whether we included the namespace for triples in the graph or not, ’M’ means that the expression was set in Manchester syntax and ’DL’ means that the expression was set in Description Logics syntax. The best results for each concept type are marked in bold.
1Key Laboratory of AI Safety, Institute of Computing Technology, Chinese Academy of Sciences · 2Shandong University · 3Shandong University-Weihai Research Institute of Industrial Technology