Skip to main content
QUICK REVIEW

[Paper Review] LegalLens: Leveraging LLMs for Legal Violation Identification in Unstructured Text

Dor Bernsohn, Gil Semo|arXiv (Cornell University)|Feb 6, 2024
Artificial Intelligence in LawSocial Sciences3 citations
TL;DR

This paper introduces LegalLens, a two-stage framework leveraging LLMs to detect legal violations in unstructured text and link them to affected individuals. Using GPT-4 for synthetic data generation and expert-validated datasets, it achieves an F1-score of 62.69% for violation identification and 81.02% for victim association, with publicly released datasets and code to advance legal NLP research.

ABSTRACT

In this study, we focus on two main tasks, the first for detecting legal violations within unstructured textual data, and the second for associating these violations with potentially affected individuals. We constructed two datasets using Large Language Models (LLMs) which were subsequently validated by domain expert annotators. Both tasks were designed specifically for the context of class-action cases. The experimental design incorporated fine-tuning models from the BERT family and open-source LLMs, and conducting few-shot experiments using closed-source LLMs. Our results, with an F1-score of 62.69\% (violation identification) and 81.02\% (associating victims), show that our datasets and setups can be used for both tasks. Finally, we publicly release the datasets and the code used for the experiments in order to advance further research in the area of legal natural language processing (NLP).

Motivation & Objective

  • To address the challenge of detecting hidden legal violations in vast volumes of unstructured digital text, especially in class-action contexts.
  • To develop a scalable, ethically sound method for generating high-quality, diverse synthetic legal datasets using LLMs.
  • To create a dual-task framework—named entity recognition (NER) for violation detection and natural language inference (NLI) for victim association—tailored to real-world legal cases.
  • To validate the generated data through expert annotators, ensuring realism and complexity comparable to human-authored legal content.
  • To publicly release datasets and code to accelerate research in legal natural language processing (NLP).

Proposed method

  • Synthetic legal violation data was generated using GPT-4, prompted with real-world event contexts to produce linguistically complex, domain-relevant text.
  • The NER setup identifies legal violations as named entities using fine-tuned BERT-based models and open-source LLMs.
  • The NLI setup associates detected violations with prior class-action cases by modeling entailment or contradiction between violation descriptions and resolved case summaries.
  • A two-step validation process was applied: automated quality checks followed by manual review by experienced legal annotators to ensure factual accuracy and linguistic realism.
  • Few-shot prompting with closed-source LLMs was used to evaluate zero-shot and few-shot generalization capabilities across legal domains.
  • Datasets were constructed from real class-action cases and legal news, with new legal entities introduced to avoid data leakage and improve generalization.
Figure 1: A visual representation of the data generation flow, illustrating the step-by-step process from raw input to the final synthesized dataset.
Figure 1: A visual representation of the data generation flow, illustrating the step-by-step process from raw input to the final synthesized dataset.

Experimental results

Research questions

  • RQ1To what extent do the newly introduced datasets enhance the performance of language models in identifying legal violations and associating them with victims?
  • RQ2How effectively do language models adapt to new, unseen data for detecting legal violations and correlating them with past resolved cases across different legal domains?
  • RQ3What is the level of difference between machine-generated and human-generated text in the context of legal violation identification?
  • RQ4How well do LLMs generalize across diverse legal domains when fine-tuned or prompted in few-shot settings?
  • RQ5Can synthetic data generated by LLMs achieve expert-level realism and complexity, making it suitable for training and evaluating legal NLP models?

Key findings

  • The NER-based violation identification model achieved an F1-score of 62.69% on the synthetic dataset, demonstrating moderate but reliable detection performance.
  • The NLI-based victim association model achieved a significantly higher F1-score of 81.02%, indicating strong performance in linking violations to resolved legal cases.
  • Expert validation confirmed that the machine-generated data closely resembles human-authored legal text in syntactic complexity and realism, with no significant detectable difference in quality.
  • Fine-tuned BERT-based models and open-source LLMs showed strong performance on both tasks, indicating their viability for legal NLP applications.
  • Few-shot prompting with closed-source LLMs demonstrated promising generalization, especially in the NLI setup, suggesting potential for zero-shot deployment in new legal domains.
  • The publicly released datasets and codebase are expected to serve as a foundation for future research in legal NLP, particularly in violation detection and case resolution.
Figure 2: NLI Confusion Matrix derived from the top performer model (Falcon 7B’s) predictions.
Figure 2: NLI Confusion Matrix derived from the top performer model (Falcon 7B’s) predictions.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.