Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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-SCRATCH-BART** | Trained from scratch on **Italian legal texts** | [π Link](https://huggingface.co/morenolq/LEGIT-SCRATCH-BART) |
|
36 |
+
| **LEGIT-BART** | Continued pre-training of `morenolq/bart-it` on **Italian legal texts** | [π Link](https://huggingface.co/morenolq/LEGIT-BART) |
|
37 |
+
| **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) |
|
38 |
+
| **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) |
|
39 |
+
| **LEGIT-BART-LSG-4096** | Continued pre-training of `morenolq/bart-it`, supporting **4,096 tokens** | [π Link](https://huggingface.co/morenolq/LEGIT-BART-LSG-4096) |
|
40 |
+
| **LEGIT-BART-LSG-16384** | Continued pre-training of `morenolq/bart-it`, supporting **16,384 tokens** | [π Link](https://huggingface.co/morenolq/LEGIT-BART-LSG-16384) |
|
41 |
+
| **BARTIT-LSG-16384** | Continued pre-training of `morenolq/bart-it`, supporting **16,384 tokens** | [π Link](https://huggingface.co/morenolq/LEGIT-BART-LSG-16384) |
|
42 |
+
| **BART-IT-LSG-4096** | `morenolq/bart-it` with **LSG attention**, supporting **4,096 tokens** | [π Link](https://huggingface.co/morenolq/BART-IT-LSG-4096)
|
43 |
+
| **BART-IT-LSG-16384** | `morenolq/bart-it` with **LSG attention**, supporting **16,384 tokens** | [π Link](https://huggingface.co/morenolq/BART-IT-LSG-16384) |
|
44 |
+
|
45 |
+
---
|
46 |
+
|
47 |
+
## π οΈ Model Details
|
48 |
+
|
49 |
+
πΉ **Architecture**
|
50 |
+
- Base Model: [`morenolq/bart-it`](https://huggingface.co/morenolq/bart-it)
|
51 |
+
- Transformer Encoder-Decoder
|
52 |
+
- **LSG Attention** for long documents
|
53 |
+
- Specific tokenizers for models trained from scratch (underperforming continual pre-training in our experiments).
|
54 |
+
|
55 |
+
πΉ **Training Data**
|
56 |
+
- Dataset: [`joelniklaus/Multi_Legal_Pile`](https://huggingface.co/datasets/joelniklaus/Multi_Legal_Pile)
|
57 |
+
- Types of legal texts used:
|
58 |
+
- **Legislation** (laws, codes, amendments)
|
59 |
+
- **Case law** (judicial decisions)
|
60 |
+
- **Contracts** (public legal agreements)
|
61 |
+
|
62 |
+
---
|
63 |
+
|
64 |
+
## π How to Use
|
65 |
+
|
66 |
+
```python
|
67 |
+
from transformers import BartForConditionalGeneration, AutoTokenizer
|
68 |
+
|
69 |
+
# Load tokenizer and model
|
70 |
+
model_name = "morenolq/LEGIT-BART"
|
71 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
72 |
+
model = BartForConditionalGeneration.from_pretrained(model_name)
|
73 |
+
|
74 |
+
# Example input
|
75 |
+
input_text = "<mask> 1234: Il contratto si intende concluso quando..."
|
76 |
+
inputs = tokenizer(input_text, return_tensors="pt", max_length=4096, truncation=True)
|
77 |
+
|
78 |
+
# Generate summary
|
79 |
+
summary_ids = model.generate(inputs.input_ids, max_length=150, num_beams=4, early_stopping=True)
|
80 |
+
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
81 |
+
print("π Summary:", summary)
|
82 |
+
```
|
83 |
+
|
84 |
+
---
|
85 |
+
|
86 |
+
β οΈ Limitations & Ethical Considerations
|
87 |
+
- **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).
|
88 |
+
- **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.
|
89 |
+
- **Legal advice**: The models are not a substitute for professional legal advice. Always consult a qualified legal professional for legal matters.
|
90 |
+
|
91 |
+
---
|
92 |
+
|
93 |
+
## π Reference
|
94 |
+
|
95 |
+
The paper presenting LEGIT-BART models is currently under review and will be updated here once published.
|
96 |
+
|
97 |
+
```bibtex
|
98 |
+
Coming soon...
|
99 |
+
```
|
100 |
+
|
101 |
+
---
|