arXiv:2509.00141cs.CYcs.AI2025-09被引 1

用线性计算的Mamba模型替代传统Transformer,提升法律文本长文档处理效率。

Scaling Legal AI: Benchmarking Mamba and Transformers for Statutory Classification and Case Law Retrieval

  • 采用线性时间选择性机制的Mamba模型,突破Transformer的二次计算瓶颈。
  • 在长文本上处理长度达数倍于Transformer,准确率和召回率仍保持领先。
  • 适合需要处理海量法律条文或判例的司法系统、政策研究者使用。

法规和司法判决的快速增长要求可扩展的法律AI系统,能在极长上下文中进行分类与检索。当前主流基于Transformer的模型(如Longformer、DeBERTa)因注意力复杂度为二次方,限制了效率与可扩展性。本文首次全面对比Mamba——一种具有线性时间选择性机制的状态空间模型(SSM)——与主流Transformer模型在法定分类与判例检索任务中的表现。评估涵盖LexGLUE、EUR-Lex、ILDC等开源法律语料库,覆盖法定标签、司法结果预测与案例检索任务。评价指标包括准确率、k阶召回率、平均倒数排名(MRR)、归一化折损累积增益(nDCG),以及每秒处理的词元数与最大上下文长度。结果表明,Mamba的线性扩展能力使其能处理比变压器长数倍的法律文档,同时维持或超越其分类与检索性能。本研究引入面向长上下文建模的新法律NLP基准套件,并开源代码与数据集以保障可复现性。研究揭示了状态空间模型与变压器之间的权衡,为在法规分析、司法决策支持与政策研究中部署可扩展法律AI提供指导。

原文摘要 · Abstract (English)

The rapid growth of statutory corpora and judicial decisions requires scalable legal AI systems capable of classification and retrieval over extremely long contexts. Transformer-based architectures (e.g., Longformer, DeBERTa) dominate current legal NLP benchmarks but struggle with quadratic attention costs, limiting efficiency and scalability. In this work, we present the first comprehensive benchmarking of Mamba, a state-space model (SSM) with linear-time selective mechanisms, against leading transformer models for statutory classification and case law retrieval. We evaluate models on open-source legal corpora including LexGLUE, EUR-Lex, and ILDC, covering statutory tagging, judicial outcome prediction, and case retrieval tasks. Metrics include accuracy, recall at k, mean reciprocal rank (MRR), and normalized discounted cumulative gain (nDCG), alongside throughput measured in tokens per second and maximum context length. Results show that Mamba's linear scaling enables processing of legal documents several times longer than transformers, while maintaining or surpassing retrieval and classification performance. This study introduces a new legal NLP benchmark suite for long-context modeling, along with open-source code and datasets to support reproducibility. Our findings highlight trade-offs between state-space models and transformers, providing guidance for deploying scalable legal AI in statutory analysis, judicial decision support, and policy research.

法律AI长文本Mamba信息检索

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。