Lawyer LLaMA Technical Report

Quzhe Huang,Mingxu Tao,Chen Zhang,Zhenwei An,Cong Jiang,Zhibin Chen,Zirui Wu,Yansong Feng
2023-10-14
Abstract:Large Language Models (LLMs), like LLaMA, have exhibited remarkable performance across various tasks. Nevertheless, when deployed to specific domains such as law or medicine, the models still confront the challenge of a deficiency in domain-specific knowledge and an inadequate capability to leverage that knowledge to resolve domain-related problems. In this paper, we propose a new framework to adapt LLMs to specific domains and build Lawyer LLaMA, a legal domain LLM, based on this framework. Specifically, we inject domain knowledge during the continual training stage and teach the model to learn professional skills using properly designed supervised fine-tuning tasks. Moreover, to alleviate the hallucination problem during the model's generation, we add a retrieval module and extract relevant legal articles before the model answers any queries. When learning domain-specific skills, we find that experts' experience is much more useful than experiences distilled from ChatGPT, where hundreds of expert-written data outperform tens of thousands of ChatGPT-generated ones. We will release our model and data.
Computation and Language,Artificial Intelligence
What problem does this paper attempt to address?
### What problems does this paper attempt to solve? This paper aims to solve two major challenges faced by large language models (LLMs) when applied in specific fields such as law or medicine: 1. **Lack of domain knowledge**: - Current LLMs are mainly trained on general corpora, such as C4 and Wikipedia. Therefore, they lack professional knowledge in specific domains. For example, in the legal field, LLMs may not know specific legal regulations or be unable to correctly cite relevant legal provisions. 2. **Inability to use domain knowledge to solve problems**: - Even if LLMs can obtain all the knowledge in a specific domain, they still have difficulty applying this knowledge to solve practical problems. For example, even if the necessary legal provisions are provided, LLMs may still be unable to understand and correctly apply this knowledge to answer specific questions. To solve these problems, the author proposes a new framework to adapt LLMs to specific domains and constructs a model specifically for the legal field - Lawyer LLaMA. Specifically, this framework trains a reliable domain - specific LLM through the following steps: 1. **Injecting domain - specific knowledge**: - Collect a large amount of original text in the legal field, including legal provisions, judicial interpretations, and court judgment documents, etc., and conduct continuous pre - training to help the model acquire legal knowledge. 2. **Learning professional skills**: - Collect solutions from domain experts and teach the model how to use appropriate knowledge to solve domain - specific tasks. If experts are not available, powerful LLMs (such as ChatGPT) can be used as alternatives, but hundreds of high - quality examples written by experts are more valuable than tens of thousands of examples generated by ChatGPT. 3. **Enhancing external knowledge and filtering irrelevant information**: - Introduce an information retrieval module to alleviate the hallucination problem and generate more reliable answers. In the legal field, retrieve relevant legal provisions as external knowledge to answer clients' questions, and design mechanisms to let the model learn to filter irrelevant information. Through these methods, the author hopes that Lawyer LLaMA can provide more accurate and reliable services in the legal field.