LaWGPT: A New AI Tool for the Legal Profession

LawGPT is a large language model (LLM) fine-tuned for the legal sector. This implies it has been trained on a wide range of legal literature, allowing it to understand and generate legal language.

What is LaWGPT?

LaWGPT is a large language model (LLM) fine-tuned for the legal area. It is the work of Stability AI, a company that creates and deploys huge language models for a wide range of applications.

LaWGPT has been trained on a wide range of legal text, allowing it to understand and generate legal language. It is used in the legal profession for a range of activities, including:

LawGPT can be used for a variety of tasks in the legal profession, including:

  • Legal research: LawGPT can help you obtain essential legal information quickly and conveniently.
  • Legal writing: LawGPT can generate legal documents including contracts and petitions.
  • Legal analysis: LawGPT may be used to examine legal arguments and find flaws.
  • Legal education: LawGPT can be used to assist law students in learning the law.
  • Legal practice: Lawyers may utilize LawGPT to give better service to their clients.

LawGPT is still in the works, but it has the potential to transform the legal profession. LawGPT can free up attorneys to focus on more complicated and strategic work by automating processes that are now performed by humans. Furthermore, LawGPT can assist attorneys in delivering better service to their clients by giving them access to more information and assisting them in more efficiently analyzing legal arguments.

See also  How to Use Truecaller AI Feature to Improve Your Call Experience

Law GPT is a powerful new instrument with the potential to significantly alter the legal profession. Law GPT is going to have a more major part in the way law is practiced as it develops.


To get started quickly with the LaW GPT project, follow these steps to prepare the code and create the environment:

1. Download the code:

git clone [email protected]:pengxiao-song/LaWGPT.git cd LaWGPT

2. Create the environment:

conda create -n lawgpt python=3.10 -y conda activate lawgpt pip install -r requirements.txt

3. Launch the Web UI (optional, for easy parameter adjustment):

  • Execute the service startup script:

bash scripts/

  • Access the Web UI by opening your web browser and navigating to
LaWGPT: A New AI Tool for the Legal Profession 1

4. Command line inference (optional, batch testing supported)

  • First, construct the test sample set with reference to the file content;resources/example_infer_data.json
  • Second, execute the inference script: . where parameter is the test sample set path, and if it is empty or the path is wrong, it is run in interactive mode.bash scripts/

LaWGPT project directory structure

LaWGPT ├── assets # Static resources ├── resources # Project resources ├── models # Base models and Lora weights │ ├── base_models │ └── lora_weights ├── outputs # Fine-tuned instruction outputs ├── data # Experimental data ├── scripts # Script directory │ ├── # Instruction fine-tuning script │ └── # Service startup script ├── templates # Prompt templates ├── tools # Toolkits ├── utils ├── # Secondary training ├── # Instruction fine-tuning ├── # Service startup ├── └── requirements.txt

Here’s a brief description of the main directories and files:

  • assets: This directory includes the project’s static resources.
  • resources: It contains project-specific resources.
  • models: This directory contains the base models and Lora weights.
  • outputs: It stores the output weights from fine-tuning instructions.
  • data: Experimental data is stored in this directory.
  • scripts: It contains various scripts, including for instruction fine-tuning and for service startup.
  • templates: Prompt templates are stored here.
  • tools: Toolkits required for the project are located in this directory.
  • utils: Utility functions or modules can be found here.
  • This script is used for secondary training.
  • It is used for fine-tuning instructions.
  • This script is used to start the service.
  • A markdown file containing information about the project.
  • requirements.txt: A file listing the required Python packages for the project.
See also  TikTok 15-Minute Video trial: What You Need to Know

Data construction

This project is based on datasets such as legal document data and judicial examination data released by the Chinese Judgment Document Network; for more information, please see the Chinese legal data summary.

  1. Primary data generation: Using Stanford_alpaca and self-instruct techniques, generate conversational Q&A data.
  2. Knowledge-led data generation: Using a knowledge-based self-instruct technique, generate data based on Chinese legal structured knowledge.
  3. Introduce ChatGPT to clean data and assist in the creation of high-quality datasets.

Model training

The training process of Law GPT series models is divided into two phases:

  1. Phase 1: Expand the legal vocabulary and prepare Chinese-LLaMA for large-scale legal instruments and codex data.
  2. The second stage: Create a legal conversation question and response dataset, then fine-tune the instructions based on the pre-trained model.

Secondary training process

  1. Refer to Construct a secondary training datasetresources/example_instruction_train.json
  2. run scripts/

Instructions fine-tune the steps.

  1. Refer to Constructing a Directive Fine-tuning Data Setresources/example_instruction_tune.json
  2. run scripts/


Due to the limitations of computing resources, data scale, and other factors, Law GPT has many limitations at this stage:

  1. Model memory and language skills are limited due to limited data resources and model capacity. As a result, when presented with factual knowledge tests, inaccurate outcomes may be obtained.
  2. The models in the series only have a basic alignment with human purpose. As a result, potentially dangerous information and content that does not adhere to human preferences and values may be generated.
  3. There are issues with self-awareness, and Chinese understanding might be improved.

Also read: Flowise: A Drag-and-Drop UI for Building LLM Flows

This article is to help you learn LaWGPT. We trust that it has been helpful to you. Please feel free to share your thoughts and feedback in the comment section below.

See also  The Ultimate Guide for Artist Headshots in 2023 (Headshots for Artists)