Do LLMs Understand Context? A Knowledge Graph-Based Evaluation Framework
Organizations: Department of Computer Science & Engineering, University of Moratuwa, Sri Lanka · Department of Electrical and Computer Engineering, University of Miami, USA
Abstract
While large language models (LLMs) have achieved remarkable linguistic capabilities, a profound question lingers at their core: do these models truly comprehend context or simply excel at pattern matching on an unprecedented scale? Contextual understanding in LLMs refers to the ability to correctly extract relevant information from a given context, integrate it into a coherent internal representation, and reason over it to produce factually consistent and contextually grounded responses. However, traditional methods such as BiLingual Evaluation Understudy (BLEU) and perplexity simply measure surface-level performance. This reveals a critical gap in question answering (QA), where responses must be contextually grounded rather than simply being memorized associations. To fill this void, we propose a novel knowledge graph (KG) based evaluation framework for LLM contextual understanding in QA. Central to this is Semantic Structural Similarity for KGs (S3KG), a hybrid similarity measure combining structural and semantic signals into a single score. In addition, a diagnostic analysis framework is developed to identify and categorize reasoning errors at the triplet level, enabling fine-grained analysis of model failures. Together, across nine benchmarks, S3KG achieves F1 gains of up to points over the strongest baseline and AUROC up to .
Figures & tables
| Positive Example | Negative Example | |
| Text | His father returned as a finished violinist of the Russian School to Bombay. | Renzo Furlan won 6–3, 6–4 against Thomas Johansson in the finals. |
| Text | His father returned to Bombay as a finished violinist of the Russian school. | Thomas Johansson won 6–3, 6–4 against Renzo Furlan in the finals. |
| Triplet ( ) | (father, returned_to, Bombay) | (Renzo Furlan, won_against, Thomas Johansson) |
| Triplet ( ) | (father, returned_to, Bombay) | (Thomas Johansson, won_against, Renzo Furlan) |
| True Label | 1 (Similar) | 0 (Not Similar) |
| Similarity scores (✓ = correct prediction; = incorrect prediction) | ||
| Dataset | S3KG (Ours) | ROUGE-1 | ROUGE-2 | ROUGE-L | BLEU | BERTScore | MiniLM | sent-T5-base |
|---|---|---|---|---|---|---|---|---|
| MRPC | 0.692 | 0.745 | 0.720 | 0.729 | 0.687 | 0.758 | 0.723 | 0.765 |
| PAWS-Wiki | 0.766 | 0.678 | 0.715 | 0.735 | 0.716 | 0.691 | 0.687 | 0.674 |
| Semantic-KG Combined | 0.834 | 0.732 | 0.707 | 0.722 | 0.715 | 0.757 | 0.770 | 0.774 |
| Wiki Swap | 0.872 | 1.000 | 0.860 | 0.729 | 0.868 | 0.747 | 0.821 | 0.767 |
| Semantic-KG Codex 400 | 0.932 | 0.835 | 0.822 | 0.792 | 0.806 | 0.823 | 0.875 | 0.872 |
| Semantic-KG FindKG | 0.767 | 0.745 | 0.717 | 0.719 | 0.711 | 0.739 | 0.802 | 0.848 |
| Dataset | Best | F1 | AUROC |
|---|---|---|---|
| MRPC | 0.3 | 0.692 | 0.673 |
| PAWS-Wiki | 0.5 | 0.766 | 0.795 |
| STS12 | 0.1 | 0.786 | 0.834 |
| SK-Codex 400 | 0.5 | 0.932 | 0.973 |
| SK-Combined | 0.5 | 0.834 | 0.829 |
| SK-FindKG | 0.0 | 0.767 | 0.796 |
| Dataset | Model | GoldSim | CtxSim | CUS |
|---|---|---|---|---|
| Gemma-7B | 0.6889 | 0.7031 | 0.6774 | |
| MesaQA | Llama-2-7B | 0.6570 | 0.7236 | 0.6752 |
| Mistral-7B | 0.6491 | 0.7356 | 0.6780 | |
| Falcon-7B | 0.6036 | 0.6458 | 0.6063 | |
| Gemma-7B | 0.5235 | 0.6401 | 0.5587 | |
| PubMedQA | Llama-2-7B | 0.5220 | 0.6567 | 0.5651 |
Appendix figures & tables8 assets
Supplementary material from the paper’s appendix.
Appendix
| Dataset | Model | ||||
|---|---|---|---|---|---|
| Llama-2-7B | 0.6570 | 0.6588 | 0.6580 | 0.6406 | |
| MesaQA | Gemma-7B | 0.6889 | 0.7060 | 0.7015 | 0.6931 |
| Mistral-7B | 0.6491 | 0.6567 | 0.6523 | 0.6444 | |
| Falcon-7B | 0.6036 | 0.6085 | 0.5558 | 0.4662 | |
| Llama-2-7B | 0.5220 | 0.5185 | 0.5143 | 0.5087 | |
| PubMedQA | Gemma-7B | 0.5235 | 0.5149 | 0.5153 | 0.5204 |
| Dataset | Model | ||||
|---|---|---|---|---|---|
| Llama-2-7B | 0.7236 | 0.7212 | 0.7248 | 0.7026 | |
| MesaQA | Gemma-7B | 0.7031 | 0.7217 | 0.7045 | 0.7013 |
| Mistral-7B | 0.7356 | 0.7585 | 0.7287 | 0.7223 | |
| Falcon-7B | 0.6458 | 0.6571 | 0.6122 | 0.5195 | |
| Llama-2-7B | 0.6567 | 0.6563 | 0.6594 | 0.6468 | |
| PubMedQA | Gemma-7B | 0.6401 | 0.6540 | 0.6434 | 0.6319 |
| Metric | KEA Baseline | Ours |
|---|---|---|
| Micro Precision | 0.853 | 0.847 |
| Micro Recall | 0.738 | 0.949 |
| Macro Precision | 0.953 | 0.803 |
| Macro Recall | 0.641 | 0.946 |
| Micro F1 | 0.836 | 0.895 |
| Macro F1 | 0.622 | 0.782 |
| MRPC | PAWS-Wiki | STS12 | ||||
|---|---|---|---|---|---|---|
| Method | F1 | AUROC | F1 | AUROC | F1 | AUROC |
| S3KG (Ours) | 0.692 | 0.673 | 0.766 | 0.795 | 0.786 | 0.834 |
| ROUGE-1 | 0.745 | 0.784 | 0.678 | 0.490 | 0.725 | 0.754 |
| ROUGE-2 | 0.720 | 0.721 | 0.715 | 0.721 | 0.681 | 0.656 |
| ROUGE-L | 0.729 | 0.760 | 0.735 | 0.807 | 0.703 | 0.710 |
| BLEU | 0.687 | 0.677 | 0.716 | 0.747 | 0.671 | 0.644 |
| Method | F1 | AUROC |
|---|---|---|
| S3KG (Ours) | 0.872 | 0.890 |
| ROUGE-2 | 0.860 | 0.772 |
| ROUGE-L | 0.729 | 0.311 |
| BLEU | 0.868 | 0.745 |
| BERTScore | 0.747 | 0.645 |
| MiniLM | 0.821 | 0.811 |
| C400 | Comb. | Find | GloBI | Oreg. | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Method | F1 | AUROC | F1 | AUROC | F1 | AUROC | F1 | AUROC | F1 | AUROC |
| S3KG (Ours) | 0.932 | 0.973 | 0.834 | 0.829 | 0.767 | 0.796 | 0.892 | 0.935 | 0.812 | 0.892 |
| ROUGE-1 | 0.835 | 0.917 | 0.732 | 0.728 | 0.745 | 0.745 | 0.784 | 0.833 | 0.745 | 0.782 |
| ROUGE-2 | 0.822 | 0.894 | 0.707 | 0.711 | 0.717 | 0.706 | 0.776 | 0.833 | 0.752 | 0.791 |
| ROUGE-L | 0.792 | 0.855 | 0.722 | 0.717 | 0.719 | 0.721 | 0.763 | 0.800 | 0.792 | 0.835 |
| BLEU | 0.806 | 0.884 | 0.715 | 0.708 | 0.711 | 0.710 | 0.775 | 0.819 | 0.745 | 0.794 |
| MRPC | PAWS-Wiki | STS12 | SK-Codex 400 | SK-Combined | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| F1 | AUROC | F1 | AUROC | F1 | AUROC | F1 | AUROC | F1 | AUROC | |
| 0.0 | 0.676 | 0.654 | 0.694 | 0.739 | 0.783 | 0.828 | 0.871 | 0.969 | 0.776 | 0.801 |
| 0.1 | 0.681 | 0.664 | 0.745 | 0.781 | 0.786 | 0.834 | 0.922 | 0.973 | 0.791 | 0.825 |
| 0.2 | 0.683 | 0.669 | 0.760 | 0.790 | 0.780 | 0.834 | 0.927 | 0.973 | 0.819 | 0.829 |
| 0.3 | 0.692 | 0.673 | 0.764 | 0.793 | 0.780 | 0.831 | 0.927 | 0.973 | 0.828 | 0.830 |
| 0.4 | 0.680 | 0.674 | 0.764 | 0.795 | 0.780 | 0.827 | 0.929 | 0.973 | 0.833 | 0.829 |
| SK-FindKG | SK-GloBI | SK-Oregano | Wiki Swap | |||||
|---|---|---|---|---|---|---|---|---|
| F1 | AUROC | F1 | AUROC | F1 | AUROC | F1 | AUROC | |
| 0.0 | 0.767 | 0.796 | 0.811 | 0.898 | 0.777 | 0.884 | 0.821 | 0.892 |
| 0.1 | 0.760 | 0.798 | 0.883 | 0.934 | 0.803 | 0.892 | 0.872 | 0.890 |
| 0.2 | 0.762 | 0.793 | 0.888 | 0.937 | 0.811 | 0.892 | 0.869 | 0.890 |
| 0.3 | 0.748 | 0.788 | 0.889 | 0.936 | 0.812 | 0.892 | 0.868 | 0.890 |
| 0.4 | 0.744 | 0.783 | 0.891 | 0.936 | 0.812 | 0.892 | 0.865 | 0.890 |
LLM Evaluation
Large language model evaluation measures what models can do, how reliably they do it, and whether benchmark scores predict real-world performance.
See all 2,408 papers