A multi-source heterogeneous knowledge injected prompt learning method for legal charge prediction

Jingyun Sun, Chi WeiApplied Soft Computing 2025

TL;DR

This paper introduces a novel prompt learning framework that integrates multi-source heterogeneous knowledge (legal knowledge base, conversational LLM, legal articles) to improve legal charge prediction. By transforming the task into a masked language modeling problem and leveraging external knowledge, the method achieves state-of-the-art results on a large legal dataset while demonstrating lower data dependency and improved interpretability.

What Problem Does This Paper Address?

Legal charge prediction, a critical task in legal AI, aims to automatically assign the correct legal charge label to a given case description. Existing methods often focus on modeling case descriptions directly using various neural network architectures. However, these approaches struggle to effectively leverage the rich, multi-source external knowledge that is crucial for accurate legal reasoning. Legal texts are also distinct from general text, containing specialized terminology and requiring a focus on factual information, which poses challenges for generic models. Furthermore, many existing methods are heavily reliant on large amounts of annotated data, which can be scarce in specialized domains like law.

Methods

The proposed method, "A Multi-Source Heterogeneous Knowledge Injected Prompt Learning Method for Legal Charge Prediction," tackles these challenges by integrating external knowledge into a prompt learning framework. The core idea is to transform the classification task into a masked language modeling (cloze test) problem.

Here's a breakdown of their approach:

  • Prompt Learning Framework: Instead of direct classification, the model predicts masked tokens within a specially constructed prompt. This allows it to leverage the language modeling capabilities of pre-trained models.
  • Multi-Source Knowledge Integration:
    • Legal Knowledge Base: A specialized legal knowledge base (THUOCL_Law) is used to match relevant knowledge snippets (keywords) from case descriptions. These snippets are then incorporated as prompts.
  • Conversational LLM: A conversational LLM (like GLM-130B or ChatGPT) is used to extract factual elements from case descriptions, guided by relevant legal articles.
  • Legal Articles: A joint semantic space is learned between case descriptions and legal articles using contrastive training with RoBERTa. This space is then used to retrieve the most relevant legal articles for a given case.
  • Factual Element Encoding: The extracted factual elements are encoded into a semantic vector using a BiGRU encoder. This vector is then injected into the soft prompt tokens to enhance the model's reasoning.
  • Knowledge-Enhanced Prompt Construction: The final input to the legal language model (Lawformer) includes:
  • Soft prompt tokens enriched with factual element information.
  • Hard prompt templates.
  • Masked tokens.
  • The original case description.
  • Concatenated knowledge snippets from the legal knowledge base.
  • Legal Charge Mapping: The predicted masked tokens are then mapped to legal charge categories using Jaccard similarity.

Datasets

The primary dataset used for training and evaluation is CAIL-2018, described as the largest legal charge prediction dataset. It contains 2,676,075 case description texts, each associated with one of 196 unique legal charge labels. The dataset was split into 2/3 for training and 1/3 for testing.

Key Insights and Ideas

  • Prompt Learning for Legal Tasks: Adapting prompt learning, typically used for general NLP tasks, to legal charge prediction proves effective, allowing for better utilization of pre-trained models.
  • Synergy of Heterogeneous Knowledge: Combining knowledge from a structured legal knowledge base, unstructured legal articles, and conversational LLMs significantly boosts prediction accuracy, suggesting that a diverse knowledge pool is more powerful than isolated sources.
  • Data Scarcity Advantage: The proposed method shows remarkable resilience to reduced training data, outperforming even advanced LLMs like ChatGLM in low-data scenarios. This is a crucial advantage in specialized domains where large labeled datasets are hard to come by.
  • Interpretability through Knowledge: The method's ability to explicitly match keywords and extract factual elements provides a degree of interpretability, allowing users to understand why a certain prediction was made, which is vital in legal applications.
  • LLMs' Domain-Specific Limitations: While conversational LLMs are powerful, they can struggle with hallucination in specialized domains like law, making domain-specific models and knowledge integration essential.

Key Results

The proposed method achieved state-of-the-art performance on the CAIL-2018 dataset, reaching a macro F1 score of 0.84. This significantly outperformed several strong baselines, including CNN (0.71), Attention (0.76), BERT (0.61), and even the conversational LLM ChatGLM (0.68).

Ablation studies confirmed the contribution of each module:

  • Removing knowledge snippets decreased the F1 score by 0.02.
  • Removing factual elements decreased the F1 score by 0.03.
  • Removing both decreased the F1 score by 0.06.
  • Contrastive training for joint semantic space learning was also shown to be crucial, with its removal leading to a 0.02 decrease in F1.

The study also highlighted the method's robustness to training data size, maintaining a high F1 score even with only 10% of the training data.

Limitations and Future Work

The authors acknowledge that their current study focuses on single-label legal charge prediction. They suggest that future research should delve into predictive tasks involving multiple legal charges, which is a more complex but realistic scenario. Additionally, while the method demonstrates good interpretability, further exploration in this area could be beneficial for legal professionals.

Summary updated

BibTeX
@article{sun2025multi,
  author = {Jingyun Sun and Chi Wei},
  title = {{A multi-source heterogeneous knowledge injected prompt learning method for legal charge prediction}},
  journal = {Applied Soft Computing},
  year = {2025},
  doi = {10.1016/j.asoc.2025.113438},
}
Figure