Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- it
|
| 4 |
+
tags:
|
| 5 |
+
- text2text-generation
|
| 6 |
+
- summarization
|
| 7 |
+
- legal-ai
|
| 8 |
+
- italian-law
|
| 9 |
+
license: mit
|
| 10 |
+
datasets:
|
| 11 |
+
- joelniklaus/Multi_Legal_Pile
|
| 12 |
+
library_name: transformers
|
| 13 |
+
pipeline_tag: text2text-generation
|
| 14 |
+
widget:
|
| 15 |
+
- text: "<mask> 1234: Il contratto si intende concluso quando..."
|
| 16 |
+
base_model:
|
| 17 |
+
- morenolq/bart-it
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# π Model Card: LEGIT-BART Series
|
| 21 |
+
|
| 22 |
+
## ποΈ Model Overview
|
| 23 |
+
The **LEGIT-BART** models are a family of **pre-trained transformer-based models** for **Italian legal text processing**.
|
| 24 |
+
They build upon **BART-IT** ([`morenolq/bart-it`](https://huggingface.co/morenolq/bart-it)) and are further pre-trained on **Italian legal corpora**.
|
| 25 |
+
|
| 26 |
+
π‘ Key features:
|
| 27 |
+
- **Extended context length** with **Local-Sparse-Global (LSG) Attention** (up to **16,384 tokens**) π
|
| 28 |
+
- **Trained on legal documents** such as **statutes, case law, and contracts** π
|
| 29 |
+
- **Not fine-tuned for specific tasks** (requires further adaptation)
|
| 30 |
+
|
| 31 |
+
## π Available Models
|
| 32 |
+
|
| 33 |
+
| Model | Description | Link |
|
| 34 |
+
|--------|-------------|------|
|
| 35 |
+
| **LEGIT-BART** | Continued pre-training of `morenolq/bart-it` on **Italian legal texts** | [π Link](https://huggingface.co/morenolq/LEGIT-BART) |
|
| 36 |
+
| **LEGIT-BART-LSG-4096** | Continued pre-training of `morenolq/bart-it`, supporting **4,096 tokens** | [π Link](https://huggingface.co/morenolq/LEGIT-BART-LSG-4096) |
|
| 37 |
+
| **LEGIT-BART-LSG-16384** | Continued pre-training of `morenolq/bart-it`, supporting **16,384 tokens** | [π Link](https://huggingface.co/morenolq/LEGIT-BART-LSG-16384) |
|
| 38 |
+
| **LEGIT-SCRATCH-BART** | Trained from scratch on **Italian legal texts** | [π Link](https://huggingface.co/morenolq/LEGIT-SCRATCH-BART) |
|
| 39 |
+
| **LEGIT-SCRATCH-BART-LSG-4096** | Trained from scratch with **LSG attention**, supporting **4,096 tokens** | [π Link](https://huggingface.co/morenolq/LEGIT-SCRATCH-BART-LSG-4096) |
|
| 40 |
+
| **LEGIT-SCRATCH-BART-LSG-16384** | Trained from scratch with **LSG attention**, supporting **16,384 tokens** | [π Link](https://huggingface.co/morenolq/LEGIT-SCRATCH-BART-LSG-16384) |
|
| 41 |
+
| **BART-IT-LSG-4096** | `morenolq/bart-it` with **LSG attention**, supporting **4,096 tokens** (no legal adaptation) | [π Link](https://huggingface.co/morenolq/BART-IT-LSG-4096)
|
| 42 |
+
| **BART-IT-LSG-16384** | `morenolq/bart-it` with **LSG attention**, supporting **16,384 tokens** (no legal adaptation) | [π Link](https://huggingface.co/morenolq/BART-IT-LSG-16384) |
|
| 43 |
+
|
| 44 |
+
---
|
| 45 |
+
|
| 46 |
+
## π οΈ Model Details
|
| 47 |
+
|
| 48 |
+
πΉ **Architecture**
|
| 49 |
+
- Base Model: [`morenolq/bart-it`](https://huggingface.co/morenolq/bart-it)
|
| 50 |
+
- Transformer Encoder-Decoder
|
| 51 |
+
- **LSG Attention** for long documents
|
| 52 |
+
- Specific tokenizers for models trained from scratch (underperforming continual pre-training in our experiments).
|
| 53 |
+
|
| 54 |
+
πΉ **Training Data**
|
| 55 |
+
- Dataset: [`joelniklaus/Multi_Legal_Pile`](https://huggingface.co/datasets/joelniklaus/Multi_Legal_Pile)
|
| 56 |
+
- Types of legal texts used:
|
| 57 |
+
- **Legislation** (laws, codes, amendments)
|
| 58 |
+
- **Case law** (judicial decisions)
|
| 59 |
+
- **Contracts** (public legal agreements)
|
| 60 |
+
|
| 61 |
+
---
|
| 62 |
+
|
| 63 |
+
## π How to Use
|
| 64 |
+
|
| 65 |
+
```python
|
| 66 |
+
from transformers import BartForConditionalGeneration, AutoTokenizer
|
| 67 |
+
|
| 68 |
+
# Load tokenizer and model
|
| 69 |
+
model_name = "morenolq/LEGIT-BART"
|
| 70 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 71 |
+
model = BartForConditionalGeneration.from_pretrained(model_name)
|
| 72 |
+
|
| 73 |
+
# Example input
|
| 74 |
+
input_text = "<mask> 1234: Il contratto si intende concluso quando..."
|
| 75 |
+
inputs = tokenizer(input_text, return_tensors="pt", max_length=4096, truncation=True)
|
| 76 |
+
|
| 77 |
+
# Generate summary
|
| 78 |
+
summary_ids = model.generate(inputs.input_ids, max_length=150, num_beams=4, early_stopping=True)
|
| 79 |
+
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
| 80 |
+
print("π Summary:", summary)
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
---
|
| 84 |
+
|
| 85 |
+
β οΈ Limitations & Ethical Considerations
|
| 86 |
+
- **Not fine-tuned for specific tasks**: The models are pre-trained on legal texts and may require further adaptation for specific legal NLP tasks (e.g., summarization, question-answering).
|
| 87 |
+
- **Bias and fairness**: Legal texts may contain biases present in the legal system. Care should be taken to ensure fairness and ethical use of the models.
|
| 88 |
+
- **Legal advice**: The models are not a substitute for professional legal advice. Always consult a qualified legal professional for legal matters.
|
| 89 |
+
|
| 90 |
+
---
|
| 91 |
+
|
| 92 |
+
## π Reference
|
| 93 |
+
|
| 94 |
+
The paper presenting LEGIT-BART models is currently under review and will be updated here once published.
|
| 95 |
+
|
| 96 |
+
```bibtex
|
| 97 |
+
@article{benedetto2025legitbart,
|
| 98 |
+
title = {LegItBART: a summarization model for Italian legal documents},
|
| 99 |
+
author = {Benedetto, Irene and La Quatra, Moreno and Cagliero, Luca},
|
| 100 |
+
year = 2025,
|
| 101 |
+
journal = {Artificial Intelligence and Law},
|
| 102 |
+
publisher = {Springer},
|
| 103 |
+
pages = {1--31},
|
| 104 |
+
doi = {10.1007/s10506-025-09436-y},
|
| 105 |
+
url = {doi.org/10.1007/s10506-025-09436-y}
|
| 106 |
+
}
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
---
|