🚀 📌 LEGIT - BART系列模型卡片
LEGIT - BART系列模型是基於預訓練的Transformer架構,專門用於處理意大利法律文本的模型。它在BART - IT的基礎上,進一步在意大利法律語料庫上進行預訓練,能有效處理法律領域的文本。
🚀 快速開始
以下是使用morenolq/LEGIT - BART
模型的示例代碼:
from transformers import BartForConditionalGeneration, AutoTokenizer
model_name = "morenolq/LEGIT-BART"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = BartForConditionalGeneration.from_pretrained(model_name)
input_text = "<mask> 1234: Il contratto si intende concluso quando..."
inputs = tokenizer(input_text, return_tensors="pt", max_length=512, truncation=True)
output_ids = model.generate(inputs.input_ids, max_length=150, num_beams=4, early_stopping=True)
output_text = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
print("📝:", output_text)
✨ 主要特性
- 擴展上下文長度:採用Local - Sparse - Global (LSG) Attention機制,支持最長達16,384個標記的上下文處理 📜。
- 基於法律文檔訓練:在法規、判例法和合同等法律文件上進行訓練,能更好地理解法律領域的文本 📑。
- 未針對特定任務微調:模型需要進一步調整以適應特定的法律NLP任務。
📦 安裝指南
文檔未提及安裝步驟,如需使用可參考transformers
庫的官方安裝說明。
💻 使用示例
基礎用法
from transformers import BartForConditionalGeneration, AutoTokenizer
model_name = "morenolq/LEGIT-BART"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = BartForConditionalGeneration.from_pretrained(model_name)
input_text = "<mask> 1234: Il contratto si intende concluso quando..."
inputs = tokenizer(input_text, return_tensors="pt", max_length=512, truncation=True)
output_ids = model.generate(inputs.input_ids, max_length=150, num_beams=4, early_stopping=True)
output_text = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
print("📝:", output_text)
📚 詳細文檔
可用模型
模型 |
描述 |
鏈接 |
LEGIT - BART |
在意大利法律文本上對morenolq/bart - it 進行持續預訓練 |
🔗 鏈接 |
LEGIT - BART - LSG - 4096 |
對morenolq/bart - it 進行持續預訓練,支持4,096個標記 |
🔗 鏈接 |
LEGIT - BART - LSG - 16384 |
對morenolq/bart - it 進行持續預訓練,支持16,384個標記 |
🔗 鏈接 |
LEGIT - SCRATCH - BART |
在意大利法律文本上從頭開始訓練 |
🔗 鏈接 |
LEGIT - SCRATCH - BART - LSG - 4096 |
使用LSG注意力機制從頭開始訓練,支持4,096個標記 |
🔗 鏈接 |
LEGIT - SCRATCH - BART - LSG - 16384 |
使用LSG注意力機制從頭開始訓練,支持16,384個標記 |
🔗 鏈接 |
BART - IT - LSG - 4096 |
morenolq/bart - it 採用LSG注意力機制,支持4,096個標記(未進行法律適配) |
🔗 鏈接 |
BART - IT - LSG - 16384 |
morenolq/bart - it 採用LSG注意力機制,支持16,384個標記(未進行法律適配) |
🔗 鏈接 |
模型詳情
架構
- 基礎模型:
morenolq/bart - it
- Transformer編解碼器
- LSG注意力機制:適用於長文檔處理
- 特定分詞器:從頭開始訓練的模型使用特定分詞器,但在實驗中,持續預訓練的效果更好。
訓練數據
🔧 技術細節
模型基於Transformer架構,使用BART - IT作為基礎模型,通過在意大利法律語料庫上進行預訓練,結合LSG注意力機制擴展上下文長度。在訓練過程中,使用了多種法律文本類型,以提高模型對法律領域文本的理解能力。
📄 許可證
本項目採用MIT許可證。
⚠️ 重要提示
- 未針對特定任務微調:模型在法律文本上進行了預訓練,但可能需要進一步調整以適應特定的法律NLP任務(如摘要生成、問答等)。
- 偏差和公平性:法律文本可能包含法律系統中存在的偏差。使用模型時應注意確保公平性和道德性。
- 法律建議:模型不能替代專業的法律建議。在處理法律事務時,請始終諮詢合格的法律專業人士。
📚 引用
介紹LEGIT - BART模型的論文目前正在審核中,發佈後將在此更新。
@article{benedetto2025legitbart,
title = {LegItBART: a summarization model for Italian legal documents},
author = {Benedetto, Irene and La Quatra, Moreno and Cagliero, Luca},
year = 2025,
journal = {Artificial Intelligence and Law},
publisher = {Springer},
pages = {1--31},
doi = {10.1007/s10506-025-09436-y},
url = {doi.org/10.1007/s10506-025-09436-y}
}