TL;DR
This paper introduces BertNet, a novel framework for automatically extracting knowledge graphs (KGs) with arbitrary new relations directly from large language models (LMs). By requiring only minimal input (a relation definition and a few example entity pairs), BertNet efficiently harvests rich, symbolic knowledge that goes beyond existing KGs and can even be used to interpret the internal knowledge of LMs.
What Problem Does This Paper Address?
Constructing comprehensive knowledge graphs (KGs) is crucial for many AI applications, but traditional methods face significant hurdles. Manual crowdsourcing is expensive and time-consuming, often limiting KGs to a predefined set of relations. Text mining approaches, while more scalable, also struggle with extracting relations not explicitly present in the training corpus or those that are complex. While recent research has explored using large language models (LMs) as implicit knowledge bases, this knowledge is "black-box" – difficult to access, navigate, edit, or assure its quality. This paper addresses the need for a flexible, scalable, and automated method to extract explicit, symbolic KGs of diverse and novel relations directly from LMs, bridging the gap between implicit LM knowledge and structured KGs.
Methods
BertNet's core innovation lies in its ability to harvest KGs from LMs with minimal input. The process involves two main stages:
- Diverse Weighted Prompt Creation: Given a relation definition (an initial prompt and a few example entity pairs), the framework automatically generates a diverse set of semantically consistent prompts. These prompts are then assigned confidence weights based on their compatibility with the example entity pairs, evaluated using the LM itself. This ensures that the generated prompts accurately reflect the intended relation.
- Efficient Search for Consistent Knowledge: Using the weighted prompts, BertNet searches through the vast space of potential entity pairs within the LM. It employs an efficient "search-and-rescore" mechanism. Initially, it uses a simplified scoring function (minimum token log-likelihood) to quickly propose candidate entity pairs, allowing for pruning strategies. Subsequently, these candidates are re-ranked using the full consistency score, ensuring that the harvested tuples are consistent across multiple prompts. This approach is designed to be computationally efficient, even with large vocabularies.
Datasets
The paper utilizes several existing datasets for evaluation and relation definition:
- ConceptNet: A large commonsense knowledge graph used to filter and define a set of 20 common relations.
- LAMA (Language Model Analysis): Used for its T-REx split of 41 relations from Wikipedia, such as "capital_of" and "member_of."
- Human-defined relations: 12 new relations of interest, including complex ones like "A is capable of, but not good at, B," were manually defined with prompts and example pairs.
- E-KAR: A dataset for analogical reasoning, from which a large set of 487 "Auto" relations were automatically derived.
Key Insights and Ideas
- LMs as explicit KG sources: The paper demonstrates that LMs, often treated as implicit knowledge stores, can be effectively mined to produce explicit, symbolic KGs.
- Minimal input for maximal output: The requirement of only a relation definition and a few examples is a significant departure from previous methods, making KG construction far more accessible.
- Prompt engineering automation: Automatically generating and weighting diverse prompts is key to capturing the nuances of relations and improving extraction accuracy.
- Symbolic interpretation of LMs: The harvested KGs serve as a valuable tool for understanding the internal knowledge and capabilities of black-box LMs, revealing how factors like model size and pretraining strategies impact knowledge encoding.
- Harvesting complex relations: BertNet can extract not only simple binary relations but also more complex n-ary relations and nuanced predicates that are difficult to define manually.
Key Results
- BertNet successfully harvested KGs of over 400 new relations, an order of magnitude more than typical existing KGs like ConceptNet.
- Human evaluations showed competitive accuracy, with results comparable to or exceeding those of KG completion models like COMET and text mining methods, especially considering BertNet's flexibility and lack of reliance on external training data.
- For ConceptNet relations, BertNet achieved high novelty (proportion of new entities) while maintaining comparable accuracy to COMET.
- The "Multi-Prompts" approach consistently outperformed single-prompt methods, demonstrating the benefit of ensembling diverse prompts.
- Analysis of different LMs revealed that larger models generally encode better knowledge, and improved pretraining strategies (like those in RoBERTa) lead to better knowledge learning and storage. Interestingly, knowledge distillation (DistilBERT) even improved accuracy in some cases.
Limitations and Future Work
- Domain limitations: The current studies are limited to LMs in the generic domain. Future work could explore extracting healthcare knowledge or other domain-specific knowledge from relevant neural models.
- Ethical considerations: While the system itself is minimal in risk, the potential for LMs to generate unethical knowledge tuples is acknowledged. Future work could involve filtering sensitive words or developing methods to better interpret and understand LM ethics.
- Scalability for extremely large KGs: While efficient, the process of harvesting extremely large KGs might still require further optimization.
- Interpreting LM nuances: Further research could delve deeper into using the harvested KGs to understand the specific knowledge capabilities and biases of different LMs.
Summary updated