InLawMate-peft is a Parameter-Efficient Fine-Tuned (PEFT) language model specifically optimized for understanding and reasoning about Indian legal documentation. The model was trained on a carefully curated dataset of nearly 7,000 question-answer pairs derived from Indian criminal law documentation, making it particularly adept at legal comprehension and explanation tasks.
The training data consists of nearly 7,000 high-quality legal Q&A pairs that were systematically generated using a sophisticated two-stage process:
-
Question Generation: Questions were extracted to cover key legal concepts, definitions, procedures, and roles, ensuring comprehensive coverage of:
- Legal terminology and definitions
- Procedural rules and steps
- Rights and penalties
- Jurisdictional aspects
- Roles of legal entities (judges, lawyers, law enforcement)
-
Answer Generation: Answers were crafted following a structured legal reasoning approach, ensuring:
- Legal precision and accuracy
- Comprehensive coverage of relevant points
- Clear explanation of legal concepts
- Professional legal discourse style
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model = AutoModelForCausalLM.from_pretrained(
4 "aryaman/legalpara-lm",
5 device_map="auto",
6 torch_dtype='auto'
7).eval()
8
9tokenizer = AutoTokenizer.from_pretrained("Aryaman02/InLawMate-peft")
10
11# Example legal query
12messages = [
13 {"role": "user", "content": "What are the requirements for cross-examination according to Indian law?"}
14]
15
16input_ids = tokenizer.apply_chat_template(
17 conversation=messages,
18 tokenize=True,
19 add_generation_prompt=True,
20 return_tensors='pt'
21)
22output_ids = model.generate(input_ids.to('cuda'))
23response = tokenizer.decode(output_ids[0][input_ids.shape[1]:], skip_special_tokens=True)
24print(response)
1@misc{legalpara-lm,
2 title={InLawMate: A PEFT Model for Indian Legal Domain Understanding},
3 year={2024},
4 publisher={Aryaman},
5 note={Model trained on Indian legal documentation}
6}
Our training data and procedure for synth data creation is outlined in
https://github.com/DarryCrucian/law-llm