Git Product home page Git Product logo

legalstories's Introduction

LegalStories

License: MIT arXiv

Official Code for our ACL 2024 Paper "Leveraging Large Language Models for Learning Complex Legal Concepts through Storytelling"

Crawl Definitions from Wikipedia

  1. Copy-paste the doctrine list from the wikipedia page. Saved as cralwer/complex-law-doctrine-list.csv.
  2. Crawl and preprocess these doctrines with their definitions from Wikipedia.
    • Downloaded 294 valid doctrine pages from wikipedia, saved as data/294-doctrines/legal_doctrines_294.csv.
    • Sampled 101 doctrines out of 294 whose definition length is between 100 and 200 words, saved as data/101-doctrines/legal_doctrines_101.csv.
    • Sampled 20 doctrines out of 101 for detailed evaluation, saved as data/20-doctrines/legal_doctrines_20.csv.

Generate Stories

  1. Fill your OpenAI key into the generate_story.py and run the following commands to generate stories for GPT-4, GPT-3.5, and LLaMA-2:
python generate_story.py --model llama2
python generate_story.py --model gpt-3.5-turbo-0613
python generate_story.py --model gpt-4-0613
  1. run organize_data.ipynb to organize the concepts, definitions, and generated stories altogether in tsv files.

Generate Questions

Fill your OpenAI key into the generate_question.py and run the following commands to generate questions for GPT-4, GPT-3.5, and LLaMA-2:

  • check out organize_data.ipynb to see how we prepare the datasets under the data folder
python generate_question.py --input_file ./outputs/294-doctrines-llama2/294_doctrine_stories.tsv --output_folder ./outputs/294-doctrines-llama2 --question_type concept_question --model llama2
python generate_question.py --input_file ./outputs/294-doctrines-llama2/294_doctrine_stories.tsv --output_folder ./outputs/294-doctrines-llama2 --question_type ending_question --model llama2
python generate_question.py --input_file ./outputs/294-doctrines-llama2/294_doctrine_stories.tsv --output_folder ./outputs/294-doctrines-llama2 --question_type limitation_question --model llama2

python generate_question.py --input_file ./outputs/294-doctrines-gpt3.5/294_doctrine_stories.tsv --output_folder ./outputs/294-doctrines-gpt3.5 --question_type concept_question --model gpt-3.5-turbo-0613
python generate_question.py --input_file ./outputs/294-doctrines-gpt3.5/294_doctrine_stories.tsv --output_folder ./outputs/294-doctrines-gpt3.5 --question_type ending_question --model gpt-3.5-turbo-0613
python generate_question.py --input_file ./outputs/294-doctrines-gpt3.5/294_doctrine_stories.tsv --output_folder ./outputs/294-doctrines-gpt3.5 --question_type limitation_question --model gpt-3.5-turbo-0613

python generate_question.py --input_file ./outputs/294-doctrines-gpt4/294_doctrine_stories.tsv --output_folder ./outputs/294-doctrines-gpt4 --question_type concept_question --model gpt-4-0613
python generate_question.py --input_file ./outputs/294-doctrines-gpt4/294_doctrine_stories.tsv --output_folder ./outputs/294-doctrines-gpt4 --question_type ending_question --model gpt-4-0613
python generate_question.py --input_file ./outputs/294-doctrines-gpt4/294_doctrine_stories.tsv --output_folder ./outputs/294-doctrines-gpt4 --question_type limitation_question --model gpt-4-0613

Evaluation & Analysis

  1. Automatic evaluation with complexity metrics: analysis/1_complexity_measure.ipynb
  2. Human evaluation: analysis/2_analyze_human_ratings_and_errors.ipynb
  3. Expert annotations on 20 legal doctrines: analysis/3_expert_annotation.ipynb
  • the final stories and their corresponding questions: analysis/expert_annotations/Final_regenerated_questions_20.tsv
  • the final expert-annotated answers for the questions: analysis/expert_annotations/Final_answer_annotations.tsv
  1. Immediate and follow-up RCT result analyses: analysis/4_analyze_rct_results.ipynb
  2. Statistical analysis on the RCT results: analysis/5_statistical_analysis.ipynb

References

If you use this repository in your research, please kindly cite our paper:

@article{jiang2024leveraging,
  title={Leveraging Large Language Models for Learning Complex Legal Concepts through Storytelling},
  author={Jiang, Hang and Zhang, Xiajie and Mahari, Robert and Kessler, Daniel and Ma, Eric and August, Tal and Li, Irene and Pentland, Alex'Sandy' and Kim, Yoon and Roy, Deb and Kabbara, Jad},
  journal={arXiv preprint arXiv:2402.17019},
  year={2024}
}

Acknowledgement

This work is done in collaboration with researchers from MIT, Harvard Law School, University of Virginia School of Law, Allen Institute for AI (AI2), and University of Tokyo. We want to thank MIT Center for Constructive Communication for funding the project.

legalstories's People

Contributors

hjian42 avatar xiajzhang avatar

Stargazers

Gurumurthi V Ramanan avatar Oscar Neto avatar  avatar Michael Corrado avatar hujili avatar

Watchers

 avatar

legalstories's Issues

Dataset resources

Hi there, I've read your terrific work! And I am interested in your dataset a lot.
Since you have put this repository url for both code and data in the preprint's footnote, I am wondering will you make this dataset public in the future? Or if anybody wishes to have access to the dataset, a permission should be granted?

Thanks so much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.