The model is optimized to handle long court judgments and produce concise, high-quality summaries suitable for downstream legal research applications.
1import warnings
2import torch
3from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
4
5warnings.filterwarnings("ignore")
6
7tokenizer = AutoTokenizer.from_pretrained("qwertyqwerty070806/LawSummBart", trust_remote_code=True)
8model = AutoModelForSeq2SeqLM.from_pretrained("qwertyqwerty070806/LawSummBart", trust_remote_code=True).to("cuda")
9
10text = """On March 5, 2021, the Securities and Exchange Commission charged AT&T..."""
11
12inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512).to("cuda")
13
14summary_ids = model.generate(
15 **inputs,
16 max_length=220,
17 min_length=80,
18 num_beams=5,
19 length_penalty=1.0,
20 no_repeat_ngram_size=3,
21 early_stopping=True
22)
23
24print(tokenizer.decode(summary_ids[0], skip_special_tokens=True))
1LoraConfig(
2 r=16,
3 lora_alpha=32,
4 lora_dropout=0.1,
5 target_modules=["q_proj", "v_proj"],
6 task_type="SEQ_2_SEQ_LM"
7)
1TrainingArguments(
2 num_train_epochs=10,
3 per_device_train_batch_size=4,
4 gradient_accumulation_steps=2,
5 learning_rate=1e-4,
6 eval_strategy="epoch",
7 save_strategy="epoch",
8 fp16=True,
9 load_best_model_at_end=True,
10 metric_for_best_model="eval_loss"
11)
The model achieves strong performance on abstractive summarization of long-form legal text, showing improved coherence and domain fidelity compared to base BART.
1@misc{lawsummbart2024,
2 title = {LawSummBart: Legal Summarization with Extract-Then-Assign and LoRA Fine-Tuned BART},
3 year = {2024},
4 publisher = {Hugging Face},
5 howpublished = {\url{https://huggingface.co/qwertyqwerty070806/LawSummBart}},
6 note = {Accessed: [DATE]}
7}