KaLM: Knowledge-aligned Autoregressive Language Modeling via Dual-view Knowledge Graph Contrastive Learning

Peng Yu, Cheng Deng, Beiya Dai, Xinbing Wang, Ying Wen · 2024

Read KaLM: Knowledge-aligned Autoregressive Language Modeling via Dual-view Knowledge Graph Contrastive Learning by Peng Yu, Cheng Deng, Beiya Dai, Xinbing Wang, Ying Wen (2024) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2412-04948.txt.

Introduction

Peng Yu, Cheng Deng, Beiya Dai, Xinbing Wang, and Ying Wen align language models with knowledge graphs in a 2024 paper. Models trained to predict the next token write fluently but answer factual queries poorly. Knowledge graphs hold structured facts that could fill the gap, if alignment can avoid dulling generation.

Their method, KaLM, fine tunes a model with two objectives. Explicit alignment shapes the model's knowledge vectors through contrastive learning on two graph views. Implicit alignment teaches fact patterns through triple completion styled as language modeling. Tests on graph completion and question answering showed clear gains. The team presents the joint objective as a way to add facts without losing generative skill.

Catalog record

CREATORPeng Yu, Cheng Deng, Beiya Dai, Xinbing Wang, Ying Wen
YEAR2024
COLLECTIONPAPERS
FORMATTXT
FILE SIZE62 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2412-04948

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

KaLM: Knowledge-aligned Autoregressive Language Modeling via Dual-view Knowledge Graph Contrastive Learning Peng Yu, Cheng Deng, Beiya Dai, Xinbing Wang, Ying Wen Abstract Autoregressive large language models (LLMs) pre-trained by next token prediction are inherently proficient in generative tasks. However, their performance on knowledge-driven tasks such as factual knowledge querying remains unsatisfactory. Knowledge graphs (KGs), as high-quality structured knowledge bases, can provide reliable knowledge for LLMs, potentially compensating for their knowledge deficiencies. Aligning LLMs with explicit, structured knowledge from KGs has been a challenge; previous attempts either failed to effectively align knowledge representations or compromised the generative capabilities of LLMs, leading to less-than-optimal outcomes. This paper proposes KaLM , a Knowledge-aligned Language Modeling approach, which fine-tunes autoregressive LLMs to align with KG knowledge via the joint objective of explicit knowledge alignment and implicit knowledge alignment. The explicit knowledge alignment objective aims to directly optimize the knowledge representation of LLMs through dual-view knowledge graph contrastive learning. The implicit knowledge alignment objective focuses on incorporating textual patterns of knowledge into LLMs through triple completion language modeling. Notably, our method achieves a significant performance boost in evaluations of knowledge-driven tasks, specifically embedding-based knowledge graph completion and generation-based knowledge graph question answering. 1 Introduction Large language models (LLMs) like PaLM 2 Anil et al. (2023) and GPT-4 Achiam et al. (2023) have recently made remarkable advancements in a wide range of natural language processing tasks Li et al. (2022) ; Su et al. (2019) . However, LLMs still face challenges in tasks requiring factual or domain-specific knowledge, resulting in unsatisfactory performance in knowledge-driven tasks. From the perspective of knowledge representation, LLMs serve as parametric knowledge bases, providing implicit, non-deterministic knowledge, while knowledge graphs (KGs) function as structured knowledge bases, offering explicit, deterministic knowledge. KGs, commonly organized as factual knowledge triples describing relations between entities, can serve as a reliable knowledge source for LLMs. Aligning LLMs with KG knowledge can enhance the knowledge reasoning capabilities of LLMs and improve their performance on knowledge-driven tasks, such as knowledge graph completion (KGC) and knowledge graph question answering (KGQA). Autoregressive LLMs pre-trained through next token prediction tasks often exhibit limitations in knowledge representation, leading to embeddings that lack diversity and specificity. This limitation becomes evident in tasks that demand distinctive sentence embeddings, such as dense retrieval and semantic search Muennighoff (2022) ; Ma et al. (2023) . As demonstrated in Figure 1(a) , the representations generated by LLMs tend to be overly homogeneous across different pieces of knowledge, undermining their effectiveness in applications requiring fine-grained semantic distinctions. (a) LLaMA (b) KaLM Figure 1: Similarity matrix of knowledge representations of (a) Llama-2-7B Touvron et al. (2023) and (b) KaLM. The values denote the cosine similarity between the head-relation and tail embedding. The diagonal elements represent positive <head-relation, tail> pairs from the same KG triple, which should maintain high similarity (darker color); off-diagonal elements represent negative <head-relation, tail> pairs from different KG triples, which should have lower similarity (lighter color). In an ideal setting, knowledge representations should be able to distinguish between different triples, while maintaining alignment and uniformity of the representation, as shown in Figure 1(b) . The concept of explicit knowledge alignment is introduced to directly optimize the knowledge representation within language models by devising direct knowledge training objectives. This strategy emerges in response to the observed degradation in knowledge representation within autoencoder-based pre-trained language models (PLMs), a phenomenon termed representation anisotropy Ethayarajh (2019) . This issue is characterized by the clustering of learned token and sentence embeddings within a constrained area of the representation space, leading to a lack of distributional uniformity Li et al. (2020) . While previous efforts to address representation anisotropy have largely concentrated on promoting uniformity among token representations, they often overlook the critical alignment of similar sentence representations Su et al. (2021) ; Li et al. (2020) ; Su et al. (2022) . More recent works advocate for integrating KG triples and using knowledge graph embedding losses to fine-tune PLMs, aiming to bolster their knowledge representation abilities Shen et al. (2022) ; Wang et al. (2022b) . Nonetheless, such approaches may limit themselves to optimizing at the token level or reduce the model to a mere text encoder, thereby diminishing its inherent generative capabilities. Conversely, implicit knowledge alignment leverages the pre-training or fine-tuning of language models with external knowledge sources, employing the vanilla language modeling objective or its variations. This approach predominantly preserves the next token prediction framework, essentially retaining the native text generation prowess of LLMs. In the realm of implicit knowledge alignment, the prevalent practice involves the fine-tuning of LLMs with KG triples and their textual descriptions, as opposed to directly altering the hidden knowledge representations Chen et al. (2022) ; Yao et al. (2023) . Nevertheless, the efficacy of these methods on knowledge graph completion tasks remains substantially inferior when compared to strategies that directly fine-tune knowledge representations Wang et al. (2022b) ; Wang et al. (2022a) . Intriguing findings from Fu et al. (2023) reveal that fine-tuning PLMs with randomly unaligned KG triples can achieve performance on par with that obtained through fine-tuning with aligned triples in various tasks, including named entity recognition and relation classification. Their findings suggest that the hidden states of entities, whether infused with aligned or random knowledge, exhibit remarkable similarity. Consequently, existing implicit alignment methods fail to effectively utilize the injected knowledge or accurately discern the connection between newly introduced knowledge and the model’s inherent knowledge, culminating in suboptimal performance. In this paper, we propose KaLM , a Knowledge-aligned Language Modeling approach for aligning LLMs with KG knowledge. Specifically, we use KG triples and their textual descriptions to fine-tune LLMs via the joint objective of explicit knowledge alignment and implicit knowledge alignment. The explicit knowledge alignment objective aims to directly optimize the hidden representations of knowledge in LLMs through dual-view knowledge graph contrastive learning . We theoretically prove and empirically show that this objective can facilitate knowledge representation alignment and alleviate representation anisotropy. For KG triples, we consider tail entity description and the concatenation of head entity description and relation description as two distinct views of the same knowledge. The key insight is that: (1) representations of two different views of the same knowledge (i.e., from the same triple) should be pulled together, while (2) representations of different knowledge (i.e., from different triples) should be pushed apart. The first term encourages semantically similar knowledge to remain close in the representation space, promoting knowledge representation alignment. The second term forces dissimilar knowledge to be as far apart as possible in the vector space, improving knowledge representation uniformity and mitigating representation anisotropy. As shown in Figure 1(b) , our method can obtain the ideal knowledge representations that are both aligned and uniform. The implicit knowledge alignment objective focuses on incorporating textual patterns of knowledge into LLMs through triple completion language modeling , which can maintain the generative capability of LLMs and boost performance on knowledge inference tasks. We constructed a triple completion dataset based on the KG triples to fine-tune LLMs, improving their instruction-following ability and facilitating implicit knowledge alignment. We also show the implicit knowledge alignment objective can further boost knowledge representation performance. This confirms that both explicit alignment and implicit alignment are crucial for

Read the complete text