# Legal-BERT

**Legal-BERT** 是一系列在法律文本上预训练的 BERT 语言模型，由雅典经济与商业大学（AUEB）的 Ilias Chalkidis、Manos Fergadiotis、Prodromos Malakasiotis、Nikolaos Aletras 和 Ion Androutsopoulos 于 2020 年发布，旨在支持法律自然语言处理研究、计算法学和法律技术应用。<sup>[1](https://arxiv.org/abs/2010.02559)</sup><sup> • </sup><sup>[2](https://aclanthology.org/2020.findings-emnlp.261/)</sup> 配套论文《LEGAL-BERT：法学院直出的布偶们》（*LEGAL-BERT: The Muppets straight out of Law School*）发表于《计算语言学协会 EMNLP 2020 Findings》，第 2898–2904 页。<sup>[2](https://aclanthology.org/2020.findings-emnlp.261/)</sup>

| 关键事实 | 详情 |
|---|---|
| 发布时间 | 2020 年 10 月（arXiv 2020 年 10 月 6 日）；EMNLP 2020 Findings，第 2898–2904 页<sup>[1](https://arxiv.org/abs/2010.02559)</sup><sup> • </sup><sup>[2](https://aclanthology.org/2020.findings-emnlp.261/)</sup> |
| 作者 | Ilias Chalkidis、Manos Fergadiotis、Prodromos Malakasiotis、Nikolaos Aletras、Ion Androutsopoulos（AUEB）<sup>[2](https://aclanthology.org/2020.findings-emnlp.261/)</sup> |
| 研究的适配策略 | （a）直接使用原始 BERT，（b）在法律语料上额外预训练以适配 BERT，（c）在法律语料上从头预训练 BERT<sup>[1](https://arxiv.org/abs/2010.02559)</sup> |
| 发布的变体 | LEGAL-BERT-FP 模型分别在全部法律语料、美国合同、ECHR 案件和欧盟立法上训练 10 万步和 50 万步，另有在全部法律语料上训练 100 万步的模型<sup>[3](https://github.com/nonameemnlp2020/legalBERT/blob/master/README.md)</sup> |
| 相对 BERT Base 的实测增益 | 在合同分析评估中，LegalBERT 达到 0.846 Macro-F1 和 0.729 Span-F1，而 BERT Base 为 0.782 和 0.654<sup>[4](https://pmc.ncbi.nlm.nih.gov/articles/PMC13062225/)</sup> |
| 法律预训练语言模型的典型增益 | 在五项法律 NLP 任务中，领域特定的法律预训练语言模型比通用领域预训练语言模型高出 1%–5%<sup>[5](https://www.researchgate.net/publication/361965800_On_the_Effectiveness_of_Pre-trained_Language_Models_for_Legal_Natural_Language_Processing_An_Empirical_Study)</sup> |
| 输入限制 | 标准的基于 BERT 的法律模型最多接受 512 个 token，这对长篇法律文书构成约束<sup>[6](https://www.researchgate.net/publication/365678509_A_Legal_Information_Retrieval_System_for_Statute_Law)</sup> |

## 起源与研究问题

2020 年的论文填补了一个空白：如何将通用领域的预训练语言模型 BERT 应用于专门领域，此前缺乏相关指导。作者系统比较了三种适配策略：原样使用原始 BERT；通过在领域特定语料上额外预训练来适配 BERT；在领域特定语料上从头预训练 BERT。他们还针对下游任务微调提出了更广泛的超参数搜索空间，并指出此前发表的预训练和微调指南往往被不加审视地照搬，在法律领域并不总能很好地泛化。<sup>[1](https://arxiv.org/abs/2010.02559)</sup><sup> • </sup><sup>[2](https://aclanthology.org/2020.findings-emnlp.261/)</sup>

## 发布的模型家族

发布的 LEGAL-BERT-FP（进一步预训练）检查点覆盖不同的法律子领域和预训练预算。GitHub 仓库列出了在全部法律语料、美国合同、ECHR（[欧洲人权法院](https://www.edgepedia.org/zh/european-court-of-human-rights)）案件和欧盟立法上分别训练 10 万步和 50 万步的模型，另有在全部法律语料上训练 100 万步的模型，名称为 legal-bert-base 和 legal-bert-small。<sup>[3](https://github.com/nonameemnlp2020/legalBERT/blob/master/README.md)</sup> 公开提供的检查点 nlpaueb/legal-bert-base-uncased 采用标准 BERT-base 架构，12 层隐藏层，隐藏维度 768，12 个注意力头，最大位置数为 512 个 token，以 CC BY-SA 4.0 许可发布。<sup>[7](https://huggingface.co/nlpaueb/legal-bert-base-uncased/blob/main/config.json)</sup>

该家族中的一员 AUEB-Eurolex 在大约 18 万份欧盟和英国立法文件上进行了预训练，因此天然适合涉及立法的任务。<sup>[5](https://www.researchgate.net/publication/361965800_On_the_Effectiveness_of_Pre-trained_Language_Models_for_Legal_Natural_Language_Processing_An_Empirical_Study)</sup> 仓库中的示例展示了这些检查点的掩码语言建模行为：合同模型将“The Participant may [MASK] this Agreement”补全为“terminate”，欧盟立法模型将一句农业义务相关的句子补全为“agricultural”。<sup>[3](https://github.com/nonameemnlp2020/legalBERT/blob/master/README.md)</sup>

## 后续变体与衍生模型

**独立的法律 BERT。** Legal-BERT 这一名称已涵盖若干相关模型。Zheng 等人（2021）构建了 Custom LegalBERT，使用自定义词表在大约 350 万份美国案件判决上从头预训练 200 万步，同时也在 BERT 之上用同一语料进行了进一步预训练。<sup>[5](https://www.researchgate.net/publication/361965800_On_the_Effectiveness_of_Pre-trained_Language_Models_for_Legal_Natural_Language_Processing_An_Empirical_Study)</sup> Holzenberger 等人（2020）在 case.law 语料库中州和联邦案件的一部分（共 9 亿 token）上进一步预训练了 bert-base-cased；在法律问答上，该模型（称为 Legal-BERT@jhu）的困惑度为 2.7，而 bert-base-cased 为 14.4。<sup>[8](https://link.springer.com/article/10.1007/s10506-023-09374-7)</sup> 斯坦福的变体在哈佛 case.law 语料上预训练，但方法不同：Legal-BERT-FP@stanford 从 BERT-base 继续预训练 100 万步，沿用原始的不区分大小写词表；而 Legal-BERT-SC@stanford 则使用 [SentencePiece](https://www.edgepedia.org/zh/sentencepiece) 分词构建的自定义法律词表从头预训练 200 万步。<sup>[8](https://link.springer.com/article/10.1007/s10506-023-09374-7)</sup>

**Pile of Law。** 另一个独立的大型模型 PoL-BERT-Large（pile-of-law/legalbert-large-1.7M-1）在 256 GB 的 Pile of Law 语料上训练了 170 万步，使用配备 8 个 RDU 的 SambaNova 集群，采用掩码语言建模（即在预训练过程中预测被隐藏的词）目标，不使用下一句预测，学习率为 5e-6，批大小为 128。其词表包含 32,000 个 token：29,000 个来自在 Pile of Law 上拟合的词片词表，外加 3,000 个从《布莱克法律词典》中随机采样的法律术语。<sup>[9](https://huggingface.co/pile-of-law/legalbert-large-1.7M-1/blob/main/README.md?code=true)</sup>

**其他法域和语言。** 领域适配在其他法律体系中也得到重复。Paul 等人在约 540 万份印度法院案件上进一步预训练了 Legal-BERT@aueb 和 Legal-BERT@stanford，产出了 InLegalBERT 和 InCaseLawBERT，在印度文本以及原有的欧洲和英国领域上均提升了性能。<sup>[8](https://link.springer.com/article/10.1007/s10506-023-09374-7)</sup><sup> • </sup><sup>[10](https://arxiv.org/abs/2209.06049)</sup> 一个德语 Legal BERT 通过将法律词汇插入德语 BERT 模型并在超过 10 万份德国法院判决的数据集上微调而构建，对法律信息的捕捉略优于通用德语模型。<sup>[11](https://essay.utwente.nl/essays/80128)</sup> 希腊语、葡萄牙语及其他语言特定的法律 BERT 变体遵循同样的模式。<sup>[8](https://link.springer.com/article/10.1007/s10506-023-09374-7)</sup>

## 实测性能

**对比通用 BERT。** 在一项 2026 年的语言模型用于法律合同自动化（分类、条款抽取和摘要）的技术评估中，未经领域特定预训练的 BERT Base 在分类上得分 0.782 Macro-F1，在条款抽取上得分 0.654 Span-F1，在摘要上得分 0.415 ROUGE-L。LegalBERT 将这些指标分别提升至 0.846、0.729 和 0.467，其中分类提升 +0.064、抽取提升 +0.075，归因于法律领域预训练。其 ROUGE-L 仍然中等，表明针对分类优化的领域特定编码器不一定能转化为更优的生成式对齐。<sup>[4](https://pmc.ncbi.nlm.nih.gov/articles/PMC13062225/)</sup>

**跨任务表现。** 一项覆盖五项法律 NLP 任务（二分类、多标签分类、多项选择问答、摘要和信息检索）的广泛实证研究发现，简单基线的表现比基于预训练语言模型的方法低 4%–35%，而领域特定的法律预训练语言模型比通用领域预训练语言模型表现好 1%–5%。<sup>[5](https://www.researchgate.net/publication/361965800_On_the_Effectiveness_of_Pre-trained_Language_Models_for_Legal_Natural_Language_Processing_An_Empirical_Study)</sup> 在 POSTURE50K 和 EURLEX57K 上的法律多标签分类中，LegalBERT 和 DistilRoBERTa 在合理的计算需求下表现一贯良好。<sup>[12](https://arxiv.org/abs/2401.11852)</sup>

## 局限性

**迁移并不均衡。** 法律预训练带来的增益集中在下游数据与预训练语料高度匹配的地方。在美国案件上预训练的 Custom LegalBERT 在 POSTURE50K 和 CaseHOLD 上表现出明显改进，但在欧盟/英国立法文件上预训练的 AUEB-Eurolex 在 EUROLEX57K 上的三项指标均略低于 BERT，尽管优于 RoBERTa。当应用于仅与预训练语料“相关”的法律数据集时，领域特定预训练的收益通常被法律子领域之间的语言差异所抵消。<sup>[5](https://www.researchgate.net/publication/361965800_On_the_Effectiveness_of_Pre-trained_Language_Models_for_Legal_Natural_Language_Processing_An_Empirical_Study)</sup>

**长文档。** BERT 家族模型最多接受 512 个输入 token，而案件文书和立法文本经常超出此限制，因此检索系统必须对条文和查询进行截断或分块。<sup>[6](https://www.researchgate.net/publication/365678509_A_Legal_Information_Retrieval_System_for_Statute_Law)</sup> 在判决段落分割任务中，LegalBERT 达到 0.5929 的边界 F1，评估者认为这表明平坦的 token 级分类缺乏足够的全局上下文，从而推动了 [Longformer](https://www.edgepedia.org/zh/longformer) 等长上下文编码器的发展。<sup>[13](https://www.nature.com/articles/s41598-026-45259-w)</sup> 法律 NLP 研究中报告的性能值在数据集构成、法律领域、任务形式和评估指标上也各不相同，因此已发表的分数不应被解读为可直接比较的基准。<sup>[4](https://pmc.ncbi.nlm.nih.gov/articles/PMC13062225/)</sup>

## 在法律 NLP 中的角色

Legal-BERT 是首批面向法律的领域特定预训练语言模型之一，也是该领域的标准基线；后来的综述将其列为人工智能与法律领域主要的基于 transformer 的模型之一，与 CaseLawBERT、LegalRoBERTa 和长上下文后继模型并列。<sup>[5](https://www.researchgate.net/publication/361965800_On_the_Effectiveness_of_Pre-trained_Language_Models_for_Legal_Natural_Language_Processing_An_Empirical_Study)</sup><sup> • </sup><sup>[14](https://riunet.upv.es/bitstreams/302ccb85-5015-4b7f-88fb-ea3209da8d0b/download)</sup> 在条款抽取、判决预测、命名实体识别和法律检索等较新研究中，它仍然是频繁出现的比较对象，领域特定预训练在法律结构化语言上的益处被反复证实。<sup>[4](https://pmc.ncbi.nlm.nih.gov/articles/PMC13062225/)</sup><sup> • </sup><sup>[15](https://pmc.ncbi.nlm.nih.gov/articles/PMC12631292/)</sup>

## References

1. [Ilias Chalkidis, Manos Fergadiotis, Prodromos Malakasiotis, Nikolaos Aletras, Ion Androutsopoulos (2020). LEGAL-BERT: The Muppets straight out of Law School. arXiv:2010.02559.](https://arxiv.org/abs/2010.02559)
2. [Same paper, ACL Anthology, Findings of EMNLP 2020, pages 2898–2904.](https://aclanthology.org/2020.findings-emnlp.261/)
3. [legalBERT repository README (model list and examples), GitHub.](https://github.com/nonameemnlp2020/legalBERT/blob/master/README.md)
4. [Technical evaluation of language models adapted for the automation of legal contracts, Frontiers in Artificial Intelligence (2026) / PMC13062225.](https://pmc.ncbi.nlm.nih.gov/articles/PMC13062225/)
5. [D. Song et al. (2022). On the Effectiveness of Pre-Trained Language Models for Legal Natural Language Processing: An Empirical Study. IEEE Access Vol. 10.](https://www.researchgate.net/publication/361965800_On_the_Effectiveness_of_Pre-trained_Language_Models_for_Legal_Natural_Language_Processing_An_Empirical_Study)
6. [A Legal Information Retrieval System for Statute Law (2022).](https://www.researchgate.net/publication/365678509_A_Legal_Information_Retrieval_System_for_Statute_Law)
7. [config.json, nlpaueb/legal-bert-base-uncased, Hugging Face.](https://huggingface.co/nlpaueb/legal-bert-base-uncased/blob/main/config.json)
8. [Candida M. Greco, Andrea Tagarelli (2023/2024). Bringing order into the realm of Transformer-based language models for artificial intelligence and law. Artificial Intelligence and Law 32, 863–1010.](https://link.springer.com/article/10.1007/s10506-023-09374-7)
9. [README, pile-of-law/legalbert-large-1.7M-1, Hugging Face.](https://huggingface.co/pile-of-law/legalbert-large-1.7M-1/blob/main/README.md?code=true)
10. [Shounak Paul, Arpan Mandal, Pawan Goyal, Saptarshi Ghosh (2022/2023). Pre-trained Language Models for the Legal Domain: A Case Study on Indian Law. arXiv:2209.06049, ICAIL 2023.](https://arxiv.org/abs/2209.06049)
11. [Effects of inserting domain vocabulary and fine-tuning BERT for German legal language, University of Twente thesis.](https://essay.utwente.nl/essays/80128)
12. [Martina Forster et al. (2024). The Right Model for the Job: An Evaluation of Legal Multi-Label Classification Baselines. arXiv:2401.11852.](https://arxiv.org/abs/2401.11852)
13. [HiCoBERT: a hierarchical transformer-based framework for Pakistan legal judgment section segmentation, Scientific Reports (2026).](https://www.nature.com/articles/s41598-026-45259-w)
14. [Siino et al. (2025). Exploring LLMs Applications in Law: A Literature Review.](https://riunet.upv.es/bitstreams/302ccb85-5015-4b7f-88fb-ea3209da8d0b/download)
15. [LegNER: a domain-adapted transformer for legal named entity recognition and text anonymization, PMC12631292.](https://pmc.ncbi.nlm.nih.gov/articles/PMC12631292/)

---
*Initially written Oct 15, 2026 · Edited: Oct 25, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 现代人工智能：基础模型、生成式人工智能与人工智能产业 › Model families and named models › Large language model families › Open-weight model families

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/legal-bert

English original: https://www.edgepedia.org/legal-bert
