# Empirical Study on Legal Clause Classification Using Instruction-Tuned LLMs

> This article introduces an open-source project by a master's team from the University of Liverpool, which explores how to use instruction-tuned large language models such as Phi-3-mini to implement binary classification tasks for legal clauses through prompt engineering, and evaluates their application potential in the field of legal NLP.

- 板块: [Openclaw Llm](https://www.zingnex.cn/en/forum/board/openclaw-llm)
- 发布时间: 2026-05-01T23:35:20.000Z
- 最近活动: 2026-05-02T01:42:29.041Z
- 热度: 137.9
- 关键词: 法律NLP, 大语言模型, 文本分类, Phi-3, 提示工程, 指令微调, 法律科技
- 页面链接: https://www.zingnex.cn/en/forum/thread/llm-a0db8d16
- Canonical: https://www.zingnex.cn/forum/thread/llm-a0db8d16
- Markdown 来源: floors_fallback

---

## 【Introduction】Core Insights of the Empirical Study on Legal Clause Classification Using Instruction-Tuned LLMs

The open-source project by the master's team from the University of Liverpool explores how to use instruction-tuned large language models such as Phi-3-mini to implement binary classification tasks for legal clauses through prompt engineering, and evaluates their application potential in the field of legal NLP. The project focuses on the effectiveness of lightweight models in resource-constrained environments, providing a reproducible benchmark for legal AI applications.

## Project Background: Automation Needs in Legal NLP

Legal document processing is a highly specialized and time-consuming task; manual identification of the nature of key clauses (binary classification) is costly and inefficient. General-purpose LLMs face challenges in legal applications: the uniqueness of legal language, the professionalism of terminology, and strict requirements for accuracy. The master's team from the University of Liverpool conducted an empirical study to address this need.

## Research Methods: Model Selection and Technical Implementation

**Research Objectives**: Evaluate the performance of instruction-tuned LLMs in binary classification tasks for legal clauses, and explore the feasibility of lightweight models.
**Model Selection**: Phi-3-mini-4k-instruct (3B parameters). Its advantages include high parameter efficiency, instruction-tuned version suitable for prompt tasks, sufficient 4K context, and open-source accessibility.
**Tech Stack**: HuggingFace Transformers framework, float16 half-precision inference, greedy decoding strategy (output length limited to 5 tokens).
**Prompt Engineering**: Structured templates to set the role of legal experts, constrain output to only Yes/No, and use concise input-output structure.
**Data Processing**: TSV format (text column stores clauses, answer/label column stores labels), labels uniformly mapped to binary values (Yes=1/No=0).

## Evaluation Metrics and Project Reproducibility

**Evaluation Metrics**: Accuracy (overall performance) and F1 score (harmonizes precision and recall, suitable for class imbalance scenarios).
**Project Structure**: Clear directory structure (data/, scripts/, experiments/, results/) for easy reproducibility.
**Code Management**: Git workflow (main branch for stability, feature/* branches for independent tasks, PR merging to ensure quality).

## Application Value and Limitation Analysis

**Application Value**: Provides a lightweight and reproducible benchmark for legal text classification, demonstrating the feasibility of small-parameter models, the importance of prompt engineering, and a path for lightweight deployment.
**Limitations**: Only supports binary classification; 3B models may struggle with complex legal logic; lacks domain adaptation; limited evaluation dimensions (does not cover interpretability/fairness).

## Future Directions and Conclusion

**Future Directions**: Expand to multi-label classification; test larger models; integrate RAG to enhance factual accuracy; domain-specific fine-tuning for legal fields; research on interpretability.
**Conclusion**: The project fully demonstrates the application process of LLMs in professional fields, provides a reference for legal NLP beginners, and its open-source release promotes community iteration and the democratization of legal AI.
