模型:
joelito/legal-swiss-longformer-base
这个模型是在法律数据上预训练的多语言模型。它基于XLM-R( base 和 large )。我们使用 Multi Legal Pile ( Niklaus et al. 2023 )这个来自各种法律来源的多语言数据集进行了预训练,覆盖了24种语言。
您可以将原始模型用于掩码语言建模,因为我们没有执行下一个句子预测。但是,它的主要目的是为了进行下游任务的微调。
需要注意的是,该模型主要设计用于在整个句子上进行微调,可能包含掩码元素,以作出决策。这类任务的例子包括序列分类、标记分类或问题回答。对于文本生成任务,像GPT-2这样的模型更合适。
此外,该模型专门在法律数据上进行了训练,旨在在该领域提供强大的性能。在应用于非法律数据时,性能可能会有所变化。
对于文本生成等任务,您应该查看类似GPT2的模型。
不应将该模型用于故意为人们创造敌对或疏远环境。该模型的训练目标不是生成关于人或事件的真实或准确的表示,因此使用模型生成此类内容超出了该模型能力的范围。
已经进行了大量的研究,探讨了语言模型的偏见和公平性问题(请参见 Sheng et al. (2021) 和 Bender et al. (2021) )。由模型生成的预测可能包含有关受保护群体、身份特征以及敏感的社会和职业群体的扰人和有害的刻板印象。
用户(直接用户和下游用户)应意识到该模型的风险、偏见和局限性。
参见 huggingface tutorials 。要进行掩码词预测,请参见 this tutorial 。
该模型使用 Multi Legal Pile ( Niklaus et al. 2023 )进行了预训练。
我们的预训练过程包括以下关键步骤:
(a) 热启动:我们从原始的XLM-R检查点( base 和 large )中初始化我们的模型,以便从训练良好的基础模型受益。
(b) 分词:我们训练了一个新的128K BPE的分词器,以更好地覆盖法律语言。但是,我们重用了原始的XLM-R嵌入来处理形态上重叠的标记,并使用随机嵌入来处理其他标记。
(c) 预训练:我们在Multi Legal Pile上使用512个样本的批次进行额外的100万/500K个步骤的预训练,用于基本/大型模型。我们使用了温升步骤、线性增加的学习率和余弦衰减调度。在温升阶段,只更新嵌入,并且相对于 Devlin et al. (2019) ,使用更高的屏蔽率和基于屏蔽标记的预测的百分比。
(d) 句子采样:我们使用指数平滑的句子采样器来处理不同州和语言之间的不同标记比例,保持每个州和语言的容量。
(e) 大小写混合模型:我们的模型同时支持大写和小写字母,类似于最近开发的大型PLM。
(f) 长上下文训练:为了处理法律文件中的长上下文,我们使用窗口化的注意力在长上下文上训练基本大小的多语言模型。这个变种被命名为Legal-Swiss-LF-base,使用15%的掩码概率,增加的学习率和与小上下文模型类似的设置。
该模型使用 Multi Legal Pile ( Niklaus et al. 2023 )进行了预训练。
预处理更多详细信息请参见 Niklaus et al. 2023
训练超参数关于模型在下游任务(例如 LEXTREME ( Niklaus et al. 2023 )或 LEXGLUE ( Chalkidis et al. 2021 ))中的性能,请参考Niklaus等人在2023年的结果 1 , 2 。
这是一个基于RoBERTa的模型。运行以下代码查看架构:
from transformers import AutoModel
model = AutoModel.from_pretrained('joelito/legal-swiss-longformer-base')
print(model)
LongformerModel(
(embeddings): LongformerEmbeddings(
(word_embeddings): Embedding(128000, 768, padding_idx=0)
(position_embeddings): Embedding(4098, 768, padding_idx=0)
(token_type_embeddings): Embedding(1, 768)
(LayerNorm): LayerNorm((768,), eps=1e-05, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
(encoder): LongformerEncoder(
(layer): ModuleList(
(0-11): 12 x LongformerLayer(
(attention): LongformerAttention(
(self): LongformerSelfAttention(
(query): Linear(in_features=768, out_features=768, bias=True)
(key): Linear(in_features=768, out_features=768, bias=True)
(value): Linear(in_features=768, out_features=768, bias=True)
(query_global): Linear(in_features=768, out_features=768, bias=True)
(key_global): Linear(in_features=768, out_features=768, bias=True)
(value_global): Linear(in_features=768, out_features=768, bias=True)
)
(output): LongformerSelfOutput(
(dense): Linear(in_features=768, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-05, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(intermediate): LongformerIntermediate(
(dense): Linear(in_features=768, out_features=3072, bias=True)
(intermediate_act_fn): GELUActivation()
)
(output): LongformerOutput(
(dense): Linear(in_features=3072, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-05, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
)
)
(pooler): LongformerPooler(
(dense): Linear(in_features=768, out_features=768, bias=True)
(activation): Tanh()
)
)
谷歌TPU。
硬件谷歌TPU v3-8
软件pytorch,transformers。
@misc{rasiah2023scale,
title={SCALE: Scaling up the Complexity for Advanced Language Model Evaluation},
author={Vishvaksenan Rasiah and Ronja Stern and Veton Matoshi and Matthias Stürmer and Ilias Chalkidis and Daniel E. Ho and Joel Niklaus},
year={2023},
eprint={2306.09237},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
@article{Niklaus2023MultiLegalPileA6,
title={MultiLegalPile: A 689GB Multilingual Legal Corpus},
author={Joel Niklaus and Veton Matoshi and Matthias Sturmer and Ilias Chalkidis and Daniel E. Ho},
journal={ArXiv},
year={2023},
volume={abs/2306.02069}
}
Joel Niklaus: huggingface ; 邮箱
Veton Matoshi: huggingface ; 邮箱
Joel Niklaus: huggingface ; 邮箱
Veton Matoshi: huggingface ; 邮箱