NeurIPS 2026Coming to NeurIPS in Sydney?Explore papers, orals & directions

Legal Prompting: Teaching a Language Model to Think Like a Lawyer

Fangyi Yu, Lee Quartey, Frank SchilderarXiv 2022 · OpenReview

TL;DR

This paper explores how to make large language models (LLMs) "think like lawyers" for legal reasoning tasks. By adapting prompting techniques like Chain-of-Thought and introducing legal-specific reasoning frameworks (e.g., IRAC), they significantly improve LLM performance on the challenging COLIEE legal entailment task, surpassing previous state-of-the-art results.

What Problem Does This Paper Address?

Legal reasoning is a complex task requiring analytical problem-solving, where lawyers must apply vast bodies of law to specific scenarios. This process is far from straightforward, and even highly skilled professionals face challenges. The bar exam, a critical step to becoming a lawyer, has notoriously low pass rates in many countries, highlighting the difficulty of this domain. While LLMs have shown promise in general reasoning tasks, their performance in specialized domains like law, which demands nuanced understanding and structured argumentation, has been less impressive. This paper aims to bridge this gap by investigating how advanced prompting techniques, specifically those mimicking legal reasoning methodologies, can enhance LLM capabilities in legal entailment tasks.

Methods

The researchers experimented with several prompting strategies for LLMs, primarily using OpenAI's GPT-3 (text-davinci-002). These included:

  • Zero-Shot (ZS) Prompting: Basic prompts were designed to elicit a "True or False" answer based on provided premise and hypothesis. They found that even minor prompt wording changes could significantly impact accuracy.
  • Few-Shot (FS) Prompting: GPT-3 was provided with a small number of example question-answer pairs to guide its reasoning. They tested 1-shot, 3-shot, and 8-shot configurations.
  • Zero-Shot Chain-of-Thought (ZS-CoT): Inspired by general reasoning tasks, this method involved prompting the LLM to "think step by step" before providing a final answer. This was a two-stage process: first, extracting reasoning, and second, extracting the answer.
  • Fine-tuning (FT): GPT-3 was fine-tuned on the COLIEE training data. They explored fine-tuning with binary answers only, and with both binary answers and explanations. Two types of explanations were used:
  • Pseudo-explanations: Sentences from the premise most similar to the hypothesis.
  • GPT-3-generated explanations: Explanations created by the LLM itself, inspired by the STaR approach.
  • Legal Reasoning (LR) Prompting: This was a key innovation. They adapted established legal reasoning frameworks, such as IRAC (Issue, Rule, Application, Conclusion), and incorporated them directly into the prompts. This involved instructing the LLM to "think like a lawyer" using these specific approaches.

Datasets

The primary dataset used was from the COLIEE (Competition on Legal Information Extraction/Entailment) event. Specifically, they utilized data from the Japanese Bar exam for Task 4 (Legal Entailment). This task involves determining whether a given hypothesis is true or false based on provided legal articles (premises). The dataset includes a combined training set of 806 questions from previous competitions, with separate test sets for 2021 (81 questions) and 2022 (109 questions).

Key Insights and Ideas

  • Domain-Specific Prompts Matter: While general prompting techniques like CoT show improvements, simply adapting LLMs to legal reasoning frameworks (like IRAC) yields superior results in this specialized domain. This suggests that "thinking like a lawyer" requires more than just step-by-step reasoning; it needs to incorporate established legal methodologies.
  • Zero-Shot with Legal Reasoning is Powerful: The most impactful approach for the 2021 COLIEE data was a zero-shot method employing specific legal reasoning prompts (e.g., TRRAC). This highlights the potential of well-crafted, domain-aware prompts to unlock LLM capabilities without extensive fine-tuning.
  • Few-Shot Performance Varies: While few-shot learning generally improved over zero-shot, the 8-shot approach was particularly effective for the 2022 dataset, suggesting that the optimal number of examples can depend on the specific test set.
  • Fine-tuning with Explanations is Tricky: Fine-tuning with explanations (both pseudo and GPT-3 generated) did not consistently outperform simpler methods. This indicates that the quality and relevance of explanations are crucial, and poorly generated explanations can even degrade performance.
  • Counterintuitive Findings: The paper noted that 1-shot learning sometimes underperformed zero-shot, and fine-tuning with the same prompt used in zero-shot was worse. This suggests that few-shot examples need to be carefully selected to be relevant to the test set to avoid misleading the model.

Key Results

  • The best performing approach for the 2021 COLIEE test set was a zero-shot method using legal reasoning prompts (specifically TRRAC), achieving an accuracy of 0.8148. This significantly beat the 2021 best system (0.7037) by 15.79%.
  • For the 2022 COLIEE test set, an 8-shot few-shot learning approach yielded the best results with an accuracy of 0.7431. This surpassed the 2022 best system (0.6789) by 6.42%.
  • Several legal reasoning prompts (e.g., TRRAC, IRREAC, IRRAC) outperformed the COLIEE winners for both years, demonstrating the effectiveness of this prompting strategy.
  • ZS-CoT showed mixed results, outperforming ZS on the 2022 set but underperforming on the 2021 set.

Limitations and Future Work

  • Prompt Sensitivity: The performance of LLMs is highly sensitive to prompt design, as demonstrated by the variations in accuracy with minor prompt changes.
  • Few-Shot Example Selection: The effectiveness of few-shot learning is contingent on the relevance of the provided examples to the test set. Future work should focus on carefully selecting these examples.
  • Explanation Quality: Fine-tuning with explanations did not always lead to improvements, suggesting that the quality and accuracy of generated explanations are critical.
  • "Thinking Like a Lawyer": The paper questions whether prompting truly teaches an LLM to "think like a lawyer" or merely mimics the process. Further exploration is needed to understand the depth of this learned reasoning.
  • Ensemble Methods: The authors suggest exploring ensemble methods that combine responses from multiple legal reasoning approaches to select the final answer.
  • Broader Domain Application: The effectiveness of these legal prompting techniques in other specialized domains warrants further investigation.

Summary updated

Abstract

Large language models that are capable of zero or few-shot prompting approaches have given rise to the new research area of prompt engineering. Recent advances showed that for example Chain-of-Thought (CoT) prompts can improve arithmetic or common sense tasks significantly. We explore how such approaches fare with legal reasoning tasks and take the COLIEE entailment task based on the Japanese Bar exam for testing zero-shot/few-shot and fine-tuning approaches. Our findings show that while CoT prompting and fine-tuning with explanations approaches show improvements, the best results are produced by prompts that are derived from specific legal reasoning techniques such as IRAC (Issue, Rule, Application, Conclusion). Based on our experiments we improve the 2021 best result from 0.7037 accuracy to 0.8148 accuracy and beat the 2022 best system of 0.6789 accuracy with an accuracy of 0.7431.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
COLIEE 2021 · Task 4 test setGPT-3 zero-shot with TRRAC (Thesis, rule, rule, application, conclusion)accuracy0.8148+0.11 vs baselineLegal Entailment · split: test · 0-shot · model=GPT-3 · prompt=TRRAC
Source quote
L245: TRRAC │ Thesis, rule, rule, application, conclusion │ 0.8148 │ 0.6881
COLIEE 2022 Task 4 test setGPT-3 8-shotaccuracy0.7432Legal Entailment · split: test · 8-shot · model=GPT-3
Source quote
L148: 8-shot │ 0.7531 │ 0.7432
COLIEE 2022 Task 4 test setGPT-3 zero-shot with IRREAC (Issue, rule, rule, application, conclusion)accuracy0.7156Legal Entailment · split: test · 0-shot · model=GPT-3 · prompt=IRREAC
Source quote
L249: IRREAC │ Issue, rule, rule, application, conclusion │ 0.7778 │ 0.7156
COLIEE 2022 Task 4 test setGPT-3 zero-shot with IRRAC (Issue, rule, reasoning, application, conclusion)accuracy0.7156Legal Entailment · split: test · 0-shot · model=GPT-3 · prompt=IRRAC
Source quote
L252: IRRAC │ Issue, rule, reasoning, application, conclusion │ 0.7654 │ 0.7156
Reported baseline / comparator measurements (2)
BenchmarkMethodMetricScoreProtocol / Evidence
COLIEE 2021 · Task 42021 COLIEE winner baselineaccuracy0.7037Legal Entailment · split: test
Source quote
L141: \caption{GPT-3's accuracy when provided with different numbers of examples as demonstrations. All three settings outperform 2021 and 2022 COLIEE winners (0.7037 and 0.6789, respectively).}
COLIEE 2022 Task 42022 COLIEE winner baselineaccuracy0.6789Legal Entailment · split: test
Source quote
L141: \caption{GPT-3's accuracy when provided with different numbers of examples as demonstrations. All three settings outperform 2021 and 2022 COLIEE winners (0.7037 and 0.6789, respectively).}
BibTeX
@misc{yu2022legal,
  author = {Fangyi Yu and Lee Quartey and Frank Schilder},
  title = {{Legal Prompting: Teaching a Language Model to Think Like a Lawyer}},
  year = {2022},
  eprint = {2212.01326},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2212.01326},
}
Figure