模型简介
模型特点
模型能力
使用案例
🚀 LEGAL-BERT:刚从法学院毕业的布偶们
LEGAL-BERT 是一系列适用于法律领域的 BERT 模型,旨在助力法律自然语言处理研究、计算法学以及法律科技应用。为了预训练不同版本的 LEGAL-BERT,我们从多个领域(如立法、法院判例、合同等)的公开资源中收集了 12GB 多样的英文法律文本。子领域变体模型(如 CONTRACTS-、EURLEX-、ECHR-)和/或通用的 LEGAL-BERT 在特定领域任务中的表现优于直接使用 BERT 模型。
这是在欧盟立法文本上进行预训练的子领域变体模型。
引用信息
I. Chalkidis、M. Fergadiotis、P. Malakasiotis、N. Aletras 和 I. Androutsopoulos 所著的 “LEGAL-BERT: The Muppets straight out of Law School”,发表于 2020 年线上举办的自然语言处理经验方法研讨会(EMNLP 2020)的研究成果(短篇论文)。(https://aclanthology.org/2020.findings-emnlp.261)
✨ 主要特性
- 专为法律领域定制,基于丰富多样的英文法律文本进行预训练。
- 不同子领域变体模型在特定法律任务中表现出色。
📦 安装指南
文档未提及安装步骤,若有需求可参考 Hugging Face Transformers 库的安装方式。
💻 使用示例
基础用法
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("nlpaueb/bert-base-uncased-eurlex")
model = AutoModel.from_pretrained("nlpaueb/bert-base-uncased-eurlex")
📚 详细文档
预训练语料
LEGAL-BERT 的预训练语料包括:
- 116,062 份欧盟立法文档,可从 EURLEX(http://eur-lex.europa.eu )获取,该平台由欧盟出版局运营,是欧盟法律的存储库。
- 61,826 份英国立法文档,可从英国立法门户网站(http://www.legislation.gov.uk )获取。
- 19,867 份欧洲法院(ECJ)的判例,同样可从 EURLEX 获取。
- 12,554 份欧洲人权法院(ECHR)的判例,可从 HUDOC(http://hudoc.echr.coe.int/eng )获取。
- 164,141 份美国各地法院的判例,可从判例法访问项目门户网站(https://case.law )获取。
- 76,366 份美国合同文档,来自美国证券交易委员会(SECOM)的 EDGAR 数据库(https://www.sec.gov/edgar.shtml )。
预训练详情
- 使用 Google BERT 的 GitHub 仓库(https://github.com/google-research/bert )提供的官方代码进行训练。
- 发布的模型类似于英文 BERT-BASE 模型(12 层、768 隐藏层、12 头注意力机制、1.1 亿参数)。
- 采用相同的训练设置:100 万训练步骤,批次大小为 256 个长度为 512 的序列,初始学习率为 1e - 4。
- 使用了由 TensorFlow 研究云(TFRC) 免费提供的单个 Google Cloud TPU v3 - 8,并利用了 GCP 研究信用额度。非常感谢 Google 的这两个项目提供的支持!
模型列表
模型名称 | 模型路径 | 训练语料 |
---|---|---|
CONTRACTS - BERT - BASE | nlpaueb/bert-base-uncased-contracts |
美国合同 |
EURLEX - BERT - BASE | nlpaueb/bert-base-uncased-eurlex |
欧盟立法 |
ECHR - BERT - BASE | nlpaueb/bert-base-uncased-echr |
欧洲人权法院判例 |
LEGAL - BERT - BASE * | nlpaueb/legal-bert-base-uncased |
所有语料 |
LEGAL - BERT - SMALL | nlpaueb/legal-bert-small-uncased |
所有语料 |
* LEGAL - BERT - BASE 即 Chalkidis 等人(2020 年)中提到的 LEGAL - BERT - SC 模型;该模型在下面提到的法律语料库上从头开始训练,使用由在相同语料库上训练的 sentence - piece 分词器创建的新词汇表。
** 由于很多人对 LEGAL - BERT - FP 模型(基于原始 BERT - BASE 检查点的模型)感兴趣,这些模型已发布在 Archive.org(https://archive.org/details/legal_bert_fp )上,因为这些模型是次要的,可能仅对那些希望深入研究 Chalkidis 等人(2020 年)提出的开放性问题的人有吸引力。
将 LEGAL - BERT 变体用作语言模型
语料 | 模型 | 掩码标记 | 预测结果 |
---|---|---|---|
BERT - BASE - UNCASED | |||
(合同) | This [MASK] Agreement is between General Motors and John Murray . | employment | ('new', '0.09'), ('current', '0.04'), ('proposed', '0.03'), ('marketing', '0.03'), ('joint', '0.02') |
(欧洲人权法院) | The applicant submitted that her husband was subjected to treatment amounting to [MASK] whilst in the custody of Adana Security Directorate | torture | ('torture', '0.32'), ('rape', '0.22'), ('abuse', '0.14'), ('death', '0.04'), ('violence', '0.03') |
(欧盟立法) | Establishing a system for the identification and registration of [MASK] animals and regarding the labelling of beef and beef products . | bovine | ('farm', '0.25'), ('livestock', '0.08'), ('draft', '0.06'), ('domestic', '0.05'), ('wild', '0.05') |
CONTRACTS - BERT - BASE | |||
(合同) | This [MASK] Agreement is between General Motors and John Murray . | employment | ('letter', '0.38'), ('dealer', '0.04'), ('employment', '0.03'), ('award', '0.03'), ('contribution', '0.02') |
(欧洲人权法院) | The applicant submitted that her husband was subjected to treatment amounting to [MASK] whilst in the custody of Adana Security Directorate | torture | ('death', '0.39'), ('imprisonment', '0.07'), ('contempt', '0.05'), ('being', '0.03'), ('crime', '0.02') |
(欧盟立法) | Establishing a system for the identification and registration of [MASK] animals and regarding the labelling of beef and beef products . | bovine | (('domestic', '0.18'), ('laboratory', '0.07'), ('household', '0.06'), ('personal', '0.06'), ('the', '0.04') |
EURLEX - BERT - BASE | |||
(合同) | This [MASK] Agreement is between General Motors and John Murray . | employment | ('supply', '0.11'), ('cooperation', '0.08'), ('service', '0.07'), ('licence', '0.07'), ('distribution', '0.05') |
(欧洲人权法院) | The applicant submitted that her husband was subjected to treatment amounting to [MASK] whilst in the custody of Adana Security Directorate | torture | ('torture', '0.66'), ('death', '0.07'), ('imprisonment', '0.07'), ('murder', '0.04'), ('rape', '0.02') |
(欧盟立法) | Establishing a system for the identification and registration of [MASK] animals and regarding the labelling of beef and beef products . | bovine | ('live', '0.43'), ('pet', '0.28'), ('certain', '0.05'), ('fur', '0.03'), ('the', '0.02') |
ECHR - BERT - BASE | |||
(合同) | This [MASK] Agreement is between General Motors and John Murray . | employment | ('second', '0.24'), ('latter', '0.10'), ('draft', '0.05'), ('bilateral', '0.05'), ('arbitration', '0.04') |
(欧洲人权法院) | The applicant submitted that her husband was subjected to treatment amounting to [MASK] whilst in the custody of Adana Security Directorate | torture | ('torture', '0.99'), ('death', '0.01'), ('inhuman', '0.00'), ('beating', '0.00'), ('rape', '0.00') |
(欧盟立法) | Establishing a system for the identification and registration of [MASK] animals and regarding the labelling of beef and beef products . | bovine | ('pet', '0.17'), ('all', '0.12'), ('slaughtered', '0.10'), ('domestic', '0.07'), ('individual', '0.05') |
LEGAL - BERT - BASE | |||
(合同) | This [MASK] Agreement is between General Motors and John Murray . | employment | ('settlement', '0.26'), ('letter', '0.23'), ('dealer', '0.04'), ('master', '0.02'), ('supplemental', '0.02') |
(欧洲人权法院) | The applicant submitted that her husband was subjected to treatment amounting to [MASK] whilst in the custody of Adana Security Directorate | torture | ('torture', '1.00'), ('detention', '0.00'), ('arrest', '0.00'), ('rape', '0.00'), ('death', '0.00') |
(欧盟立法) | Establishing a system for the identification and registration of [MASK] animals and regarding the labelling of beef and beef products . | bovine | ('live', '0.67'), ('beef', '0.17'), ('farm', '0.03'), ('pet', '0.02'), ('dairy', '0.01') |
LEGAL - BERT - SMALL | |||
(合同) | This [MASK] Agreement is between General Motors and John Murray . | employment | ('license', '0.09'), ('transition', '0.08'), ('settlement', '0.04'), ('consent', '0.03'), ('letter', '0.03') |
(欧洲人权法院) | The applicant submitted that her husband was subjected to treatment amounting to [MASK] whilst in the custody of Adana Security Directorate | torture | ('torture', '0.59'), ('pain', '0.05'), ('ptsd', '0.05'), ('death', '0.02'), ('tuberculosis', '0.02') |
(欧盟立法) | Establishing a system for the identification and registration of [MASK] animals and regarding the labelling of beef and beef products . | bovine | ('all', '0.08'), ('live', '0.07'), ('certain', '0.07'), ('the', '0.07'), ('farm', '0.05') |
下游任务评估
可参考论文 “LEGAL - BERT: The Muppets straight out of Law School” 中的实验。Chalkidis 等人,2020 年,(https://aclanthology.org/2020.findings-emnlp.261)
作者与出版物
@inproceedings{chalkidis-etal-2020-legal,
title = "{LEGAL}-{BERT}: The Muppets straight out of Law School",
author = "Chalkidis, Ilias and
Fergadiotis, Manos and
Malakasiotis, Prodromos and
Aletras, Nikolaos and
Androutsopoulos, Ion",
booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2020",
month = nov,
year = "2020",
address = "Online",
publisher = "Association for Computational Linguistics",
doi = "10.18653/v1/2020.findings-emnlp.261",
pages = "2898--2904"
}
关于我们
雅典经济与商业大学自然语言处理小组 致力于开发让计算机处理和生成自然语言文本的算法、模型和系统。
该小组目前的研究兴趣包括:
- 用于数据库、本体、文档集合和网络的问答系统,特别是生物医学问答。
- 从数据库和本体(特别是语义网络本体)生成自然语言。
- 文本分类,包括过滤垃圾邮件和不良内容。
- 信息提取和观点挖掘,包括法律文本分析和情感分析。
- 希腊语自然语言处理工具,如解析器和命名实体识别器。
- 自然语言处理中的机器学习,特别是深度学习。
该小组隶属于雅典经济与商业大学信息学系信息处理实验室。
Ilias Chalkidis 代表 雅典经济与商业大学自然语言处理小组
| GitHub: @ilias.chalkidis | Twitter: @KiddoThe2B |
📄 许可证
本项目采用 CC - BY - SA - 4.0 许可证。



