Abstract
Recently, prompt-tuning has achieved promising results for specific few-shot classification tasks. The core idea of prompt-tuning is to insert text pieces (i.e., templates) into the input and transform a classification task into a masked language modeling problem. However, for relation extraction, determining an appropriate prompt template requires domain expertise, and it is cumbersome and time-consuming to obtain a suitable label word. Furthermore, there exists abundant semantic and prior knowledge among the relation labels that cannot be ignored. To this end, we focus on incorporating knowledge among relation labels into prompt-tuning for relation extraction and propose a Knowledge-aware Prompt-tuning approach with synergistic optimization (KnowPrompt). Specifically, we inject latent knowledge contained in relation labels into prompt construction with learnable virtual type words and answer words. Then, we synergistically optimize their representation with structured constraints. Extensive experimental results on five datasets with standard and low-resource settings demonstrate the effectiveness of our approach. Our code and datasets are available in https://github.com/zjunlp/KnowPrompt for reproducibility.
Introduction
Relation Extraction (RE) is the task of identifying how two entities in a sentence are connected—for instance, determining that "Steve Jobs" founded "Apple." While Pre-trained Language Models (PLMs) like BERT excel at this, they typically require substantial labeled data for task-specific fine-tuning.
Prompt-tuning has emerged as an efficient alternative, reframing classification as a "cloze" test (e.g., "Steve Jobs [MASK] Apple"). However, RE presents unique challenges for standard prompting:
- Template Engineering: Manually designing optimal prompt templates is difficult.
- Label Mapping: Complex relation labels like
org:city_of_headquartersdo not map naturally to single vocabulary words. - Contextual Neglect: Existing methods often ignore the semantic links between entity types (e.g., "person") and their participating relations (e.g., "born in").
Methodology
KnowPrompt addresses these hurdles by moving from rigid, manual prompts to learnable, knowledge-aware ones.
Virtual Type and Answer Words
Instead of fixed words, KnowPrompt utilizes "virtual words"—continuous vectors (embeddings) that the model learns during training.
- Virtual Type Words: Placed around entities to represent their semantic roles.
- Virtual Answer Words: Represent the relation itself at the
[MASK]position.
Knowledge Injection and Synergistic Optimization
These virtual words are initialized using semantic information from relation labels. For example, per:country_of_birth implies the subject is a "person" and the object is a "country." These semantics anchor the initial embeddings. To ensure consistency, the authors apply Structured Constraints inspired by Knowledge Graph embeddings (e.g., TransE). They enforce a triplet logic: $Subject + Relation \approx Object$. This synergistic optimization ensures that entity types and relation answers are mathematically aligned.
Experimental Evaluation
The framework was evaluated on five major RE benchmarks: SemEval 2010 Task 8, DialogRE, TACRED, TACRED-Revisit, and Re-TACRED. Testing covered both standard supervised settings and low-resource (few-shot) scenarios with 8, 16, and 32 examples per class.
Key Results and Insights
KnowPrompt demonstrates that labels are more than simple identifiers; they are rich sources of prior knowledge. By treating labels as instructions and using continuous embeddings, the model can capture complex relations more effectively than discrete word mappings.
Performance Highlights
- Few-Shot Superiority: In the 8-shot setting, KnowPrompt outperformed standard fine-tuning by an average of 22.4% in F1 score across all datasets.
- State-of-the-Art Comparison: It significantly outperformed PTR, the previous leading prompting method, particularly on the multi-label DialogRE dataset (+5.4 points).
- Model Agnostic: While primarily tested on RoBERTa, the approach also proved effective with GPT-2, demonstrating its architectural flexibility.
Conclusion
KnowPrompt successfully integrates semantic knowledge into the prompt-tuning pipeline for Relation Extraction. By enforcing structural logic ($s + r \approx o$), the model learns the underlying relationship patterns rather than just surface-level text features. Future work may explore incorporating unlabeled data through semi-supervised learning or extending the framework to lifelong learning scenarios where models adaptively learn new relations over time.
Summary updated