🚀 合法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}
}