🚀 合法BART系列模型卡片
合法BART(LEGIT - BART)系列模型是基於預訓練的Transformer架構,專門用於處理意大利法律文本的模型。它在BART - IT模型的基礎上,進一步在意大利法律語料庫上進行預訓練,能夠處理較長的法律文本,為法律領域的自然語言處理任務提供了強大的支持。
🚀 快速開始
以下是使用morenolq/LEGIT - SCRATCH - BART
模型的示例代碼:
from transformers import BartForConditionalGeneration, AutoTokenizer
model_name = "morenolq/LEGIT-SCRATCH-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)
✨ 主要特性
- 超長文本處理能力:藉助局部 - 稀疏 - 全局(LSG)注意力機制,模型能夠處理長達16,384個標記的文本,滿足法律文檔篇幅較長的需求。
- 專業法律語料訓練:模型在包括法規、判例法和合同等法律文檔上進行訓練,能夠更好地理解和處理法律領域的專業語言。
- 靈活適配性:模型未針對特定任務進行微調,用戶可以根據具體的法律自然語言處理任務(如摘要生成、問答系統等)進行進一步的適配。
📦 安裝指南
文檔中未提及安裝步驟,如需使用該模型,可參考transformers
庫的官方文檔進行安裝。
💻 使用示例
基礎用法
from transformers import BartForConditionalGeneration, AutoTokenizer
model_name = "morenolq/LEGIT-SCRATCH-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 進行持續預訓練 |
[🔗 鏈接](https://huggingface.co/morenolq/LEGIT - BART) |
LEGIT - BART - LSG - 4096 |
對morenolq/bart - it 進行持續預訓練,支持4,096個標記 |
[🔗 鏈接](https://huggingface.co/morenolq/LEGIT - BART - LSG - 4096) |
LEGIT - BART - LSG - 16384 |
對morenolq/bart - it 進行持續預訓練,支持16,384個標記 |
[🔗 鏈接](https://huggingface.co/morenolq/LEGIT - BART - LSG - 16384) |
LEGIT - SCRATCH - BART |
在意大利法律文本上從頭開始訓練 |
[🔗 鏈接](https://huggingface.co/morenolq/LEGIT - SCRATCH - BART) |
LEGIT - SCRATCH - BART - LSG - 4096 |
使用LSG注意力機制從頭開始訓練,支持4,096個標記 |
[🔗 鏈接](https://huggingface.co/morenolq/LEGIT - SCRATCH - BART - LSG - 4096) |
LEGIT - SCRATCH - BART - LSG - 16384 |
使用LSG注意力機制從頭開始訓練,支持16,384個標記 |
[🔗 鏈接](https://huggingface.co/morenolq/LEGIT - SCRATCH - BART - LSG - 16384) |
BART - IT - LSG - 4096 |
為morenolq/bart - it 添加LSG注意力機制,支持4,096個標記(未進行法律適配) |
[🔗 鏈接](https://huggingface.co/morenolq/BART - IT - LSG - 4096) |
BART - IT - LSG - 16384 |
為morenolq/bart - it 添加LSG注意力機制,支持16,384個標記(未進行法律適配) |
[🔗 鏈接](https://huggingface.co/morenolq/BART - IT - LSG - 16384) |
模型詳情
架構
- 基礎模型:[
morenolq/bart - it
](https://huggingface.co/morenolq/bart - it)
- 架構類型:Transformer編碼器 - 解碼器
- 注意力機制:採用LSG注意力機制處理長文檔
- 分詞器:從頭開始訓練的模型使用特定的分詞器,但在實驗中,持續預訓練的效果更佳。
訓練數據
🔧 技術細節
模型基於Transformer架構,通過LSG注意力機制實現對長文本的有效處理。在訓練過程中,使用了意大利法律領域的多種文本數據,以提高模型對法律語言的理解能力。
📄 許可證
本模型使用MIT許可證。
⚠️ 重要提示
- 模型未針對特定任務進行微調,可能需要針對具體的法律自然語言處理任務(如摘要生成、問答系統等)進行進一步的適配。
- 法律文本可能包含法律系統中存在的偏見,使用模型時應注意確保公平性和道德性。
- 模型不能替代專業的法律建議,遇到法律問題時,請諮詢合格的法律專業人士。
📚 參考資料
介紹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}
}