🚀 📌 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}
}