To address the expression discrepancy between users' vague queries and the professionalism of statutes in statute retrieval, this paper proposes a bidirectional legal information enhancement learning method. By reducing the information gap between queries and statutes, this approach eases the model's learning difficulty and improves retrieval performance. On the query side, large language models are utilized to generate explanatory answers, supplementing missing legal concepts and reasoning logic. On the statute side, an incremental representation is built that incorporates law names, structures, and contents, enhancing the semantic richness of legal texts. Furthermore, by integrating both enhanced query and statute information, the paper designs a hierarchical legal information-aware contrastive learning framework, enabling precise semantic mapping between user queries and statutes. Experimental results demonstrate that the proposed method significantly improves retrieval performance, increasing Recall@5 from 52.90% to 69.74% and MRR@3 from 47.12% to 63.80%, offering high-quality statute retrieval services for both legal practitioners and large language models.
法律人工智能技术是提高法律服务质量与效率的重要手段,其中,法条检索[1]作为智能司法的基础任务,旨在从大量法律法规库中精准定位与具体法律问题高度相关的条文。我国法律体系深受大陆法系影响,以成文法为基础架构,明确的法律条文在司法实践中具有直接的指导作用。因此,高质量法条检索技术不仅具备重要的理论研究价值,更具有显著的现实意义:一方面,对于法律从业者而言,精准高效的法条检索可有效支持案件分析、合规审查、合同起草等法律业务流程,显著提高工作效率;另一方面,对于大型语言模型(Large Language Models,简称大模型)驱动的检索增强生成(Retrieval Augmented Generation)系统[2]而言,精准的法条检索提供结构化法律知识支持,有效降低大模型生成内容的幻觉风险,增强智能法律服务的专业性与可信度。因此,研究如何进一步提高法条检索的精准性和相关性,是推动智能法律服务发展亟须解决的重要问题。
目前,法律条文检索的方法主要基于通用领域信息检索(Information Retrieval)技术[3],通过计算查询内容和法条的匹配程度,按照相似值排序给出检索结果。主流匹配方法可以分为两类:一类是基于关键词匹配的传统稀疏检索模型[4],如词频-逆文档频率(Term Frequency-Inverse Document Frequency, TF-IDF)、最佳匹配25(Best Matching 25, BM25)等,通过统计查询词与法条的词频、逆文档频率等特征计算相关性,但难以捕捉深层语义信息;另一类是基于预训练语言模型(Pre-trained Language Model)[5]的稠密检索方法,将文本编码为稠密向量,通过向量相似度的计算捕捉语义层面的关联,显著提升复杂文本的语义理解能力。相对于稀疏检索,稠密检索可以更有效地建立语义关联关系,在法条检索领域展现出更优的性能。例如,Su等[6]构建了面向公众法律咨询方向的法条检索数据集(Statute Retrieval Dataset,STARD),并采用通用预训练模型(如基于Transformer的双向编码器表征(Bidirectional Encoder Representations from Transformers,BERT)[7]等)与法律预训练模型(如Lawformer[8]等)在此数据集上开展进一步模型微调,达到超过通用信息检索模型的性能。然而,法条检索任务仍然面临法律专业领域特有的挑战:(1)查询表述的多样化且缺乏专业性。由于用户法律知识水平参差不齐,查询常常存在模糊、口语化甚至不准确的问题,影响模型对其意图的正确理解;(2)法律法规与通用语料差异较大。法律语料具有高度专业化特征,与通用语料在词汇体系和语义结构上存在显著差异,导致通用语言模型在语义表征上存在“异化”问题。这两项挑战进一步加剧用户查询与法条之间关联建模的难度,使得直接应用通用或法律预训练模型难以达到理想的检索效果。图1展示了用户查询的模糊表达与检索示例,相较于常用稀疏与稠密检索方法,例如BM25和北京智源人工智能研究院多语言、多功能、多粒度通用嵌入模型(Beijing Academy of Artificial Intelligence General Embeddings-Multi-linguality,Multi-functionality,Multi-granularity,BGE-M3)[9],本文方法可以准确检索相应法条。
信息检索是法条检索的基础。信息检索旨在从大型语料库中定位与查询相关的文档,主流方法包括基于词汇匹配的稀疏检索和基于语义向量匹配的稠密检索。常用稀疏检索方法中,基于词袋模型[10]的BM25[4]通过计算词频和逆文档频率评估查询词和文档的相关性;查询似然(Query Likelihood,QL)模型[11]通过计算查询词在文档中出现的概率来选取最有可能生成查询语句的文档,视作相关文档。尽管此类词汇匹配方法高效,但忽略了深层语义信息。随着深度学习技术发展,稠密检索技术逐渐成为语义检索主流方法。其将查询文本与检索目标映射至统一语义空间,通常以向量余弦值作为二者语义相似度的度量,根据数值大小完成匹配。此类方法更擅长处理具有复杂语义信息的任务。预训练模型[5]是稠密检索方法的典型技术。BERT[7]是代表性模型之一,其首次将掩码语言建模与Transformer架构结合,奠定了语义编码的基础。随后,Karpukhin等[12]提出基于双编码器架构的稠密段落检索(Dense Passage Retriever,DPR)方法,通过对比学习独立优化查询与文档的嵌入表示,建立密集检索的标准范式。鲁棒优化的BERT方法(Robustly Optimized BERT Approach,RoBERTa)模型[13]在BERT的基础上进行了改进,采用更大规模数据与动态生成掩码模式进行训练,显著增强模型泛化能力;基于BERT的上下文交互(Contextualized Late Interaction over BERT,ColBERT)模型[14]通过词级相似度矩阵计算,提升开放域问答的准确性。针对中文任务,中文RoBERTa全词掩码(Chinese-RoBERTa-Whole Word Masking,Chinese-RoBERTa-wwm)模型[15]在RoBERTa基础上引入全词掩码策略,进一步增强中文语义理解能力。此外,BGE-M3等系列模型是目前大模型检索增强生成系统常用检索器,其支持稠密向量、稀疏向量以及多向量混合检索,并采用基于自知识蒸馏的方法来提升模型性能。
法条检索在信息检索技术基础上,一方面需要构建特定语料库,另一方面需适配法条检索的模型。法条检索查询语料整体上可以分为以案件判决书为代表的法律专业查询[16]与面向公众法律咨询[17]的非专业查询,前者具备领域一致性特点,使得模型较容易实现语义对齐,且一般局限在有限数据量法条,如刑事案件仅需关注刑法;后者从现实场景中公众法律咨询问题构建查询语料,通常存在表达模糊、术语使用不当等问题,且目标法条数量较多。例如,Lotfi等[18]根据比利时公民咨询邮件构建问题集比利时法条检索数据集(Belgian Statutory Article Retrieval Dataset,BSARD),包含1 108条查询与22 633项法条。中文情境下,Su等[6]构建包括我国55 348项法条、1 543条真实咨询问题的语料集STARD。本文关注难度更大的非专业法条检索问题。方法上,除了直接采用信息检索中常用稀疏检索与稠密检索方法外,还可采用法律领域预训练模型,例如,法律案例检索的结构感知预训练语言模型(Structure-aware Pre-traIned Language Model for Legal Case Retrieval,SAILER)[19]是一个专门为法律文档设计的结构感知预训练语言模型,利用法律文档不同部分间的逻辑连接来提高文档表示的质量;Lawformer[8]采用Longformer[20]作为基础架构,设计针对解决法律文档长度溢出问题的法律预训练模型。与法条检索相似的任务包括法条预测[21]与法条推荐[22-23],二者一般作为判决结果预测[24]子任务,根据案情预测或推荐有限范围(如刑法)的相关法条。本文主要探讨中文情境下,复杂公众法律咨询中的法条检索问题。
PHAMT N A, DOD T, LE NGUYENM. A Framework for Enhancing Statute Law Retrieval Using Large Language Models[M]//New Frontiers in Artificial Intelligence. Singapore: Springer Nature Singapore, 2024: 247-259. DOI: 10.1007/978-981-97-3076-6_17 .
[2]
LEWISP, PEREZE, PIKTUSA, et al. Retrieval-augmented Generation for Knowledge-intensive NLP Tasks[C]//Advances in Neural Information Processing Systems. San Diego: Curran Associates, Inc.,2020, 33: 9459-9474.
[3]
HUANGP-S, HEX D, GAOJ F, et al. Learning Deep Structured Semantic Models for Web Search Using Clickthrough Data[C]//Proceedings of the 22nd ACM International Conference on Information & Knowledge Management. New York: ACM, 2013: 2333-2338. DOI: 10.1145/2505515.2505665 .
[4]
ROBERTSONS, ZARAGOZAH. The Probabilistic Relevance Framework: BM25 and beyond[J]. FNT Information Retrieval, 2009, 3(4): 333-389. DOI: 10.1561/1500000019 .
[5]
WANGH F, LIJ W, WUH, et al. Pre-trained Language Models and Their Applications[J]. Engineering, 2023, 25: 51-65. DOI: 10.1016/j.eng.2022.04.024 .
[6]
SUW H, HUY R, XIEA Z, et al. STARD: A Chinese Statute Retrieval Dataset with Real Queries Issued by Non-professionals[C]//Findings of the Association for Computational Linguistics: EMNLP. Stroudsburg: ACL, 2024: 10658-10671. DOI:10.18653/v1/2024.findings-emnlp.625 .
[7]
DEVLINJ, CHANGM W, LEEK, et al. BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding[C]//North American Chapter of the Association for Computational Linguistics. Stroudsburg: Association for Computational Linguistics, 2019, 1: 4171-4186.
[8]
XIAOC J, HUX Y, LIUZ Y, et al. Lawformer: A Pre-trained Language Model for Chinese Legal Long Documents[J]. AI Open, 2021, 2: 79-84. DOI: 10.1016/j.aiopen.2021.06.003 .
[9]
CHENJ L, XIAOS T, ZHANGP T, et al. M3-Embedding: Multi-Linguality, Multi-Functionality, Multi-granularity Text Embeddings Through Self-knowledge Distillation[C]//Findings of the Association for Computational Linguistics ACL 2024. Stroudsburg, PA, USA: ACL, 2024: 2318-2335. DOI: 10.18653/v1/2024.findings-acl.137 .
[10]
RAMOSJ. Using TF-IDF to Determine Word Relevance in Document Queries[C]//Proceedings of the First Instructional Conference on Machine Learning. Citeseer, 2003: 29-48.
[11]
PONTEJ M, CROFTW B. A Language Modeling Approach to Information Retrieval[J]. SIGIR Forum, 2017, 51(2): 202-208. DOI: 10.1145/3130348.3130368 .
[12]
KARPUKHINV, OGUZB, MINS, et al. Dense Passage Retrieval for Open-domain Question Answering[C]//Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP). Stroudsburg: ACL, 2020: 6769-6781. DOI: 10.18653/v1/2020.emnlp-main.550 .
[13]
LIUY H, OTT M, GOYALN, et al. RoBERTa: A Robustly Optimized BERT Pretraining Approach[EB/OL]. (2019-07-26) [2025-11-21].
[14]
KHATTABO, ZAHARIAM. ColBERT: Efficient and Effective Passage Search via Contextualized Late Interaction over BERT[C]//Proceedings of the 43rd International ACM SIGIR Conference on Research and Development in Information Retrieval. New York: ACM, 2020: 39-48. DOI: 10.1145/3397271.3401075 .
[15]
CUIY M, CHEW X, LIUT, et al. Pre-training with Whole Word Masking for Chinese BERT[J]. IEEE/ACM Trans Audio Speech Lang Process, 2021, 29: 3504-3514. DOI: 10.1109/TASLP.2021.3124365 .
[16]
BHATTACHARYAP, GHOSHK, GHOSHS, et al. FIRE 2019 AILA Track: Artificial Intelligence for Legal Assistance[C]//Proceedings of the 11th Forum for Information Retrieval Evaluation. New York: ACM, 2019: 4-6. DOI: 10.1145/3368567.3368587 .
[17]
WANGY H, SUF D, YEHT Y, et al. A Cross-lingual Statutory Article Retrieval Dataset for Taiwan Legal Studies[EB/OL]. (2024-10-15) [2025-11-21].
[18]
LOTFIE, BANARN, YUZBASHYANN, et al. Bilingual BSARD: Extending Statutory Article Retrieval to Dutch[C]//Proceedings of the 1st Regulatory NLP Workshop. Stroudsburg: ACL, 2025: 10-21.
[19]
LIH T, AIQ Y, CHENJ, et al. SAILER: Structure-aware Pre-trained Language Model for Legal Case Retrieval[C]//Proceedings of the 46th International ACM SIGIR Conference on Research and Development in Information Retrieval. New York: ACM, 2023: 1035-1044. DOI: 10.1145/3539618.3591761 .
[20]
BELTAGYI, PETERSM E, COHANA. Longformer: The Long-document Transformer[EB/OL]. (2020-04-10) [2025-11-21].
[21]
CHENY S, CHIANGS W, WUM L. A Few-shot Transfer Learning Approach Using Text-label Embedding with Legal Attributes for Law Article Prediction[J]. Appl Intell, 2022, 52(3): 2884-2902. DOI: 10.1007/s10489-021-02516-x .
LIL, DUANW, ZHOUD, et al. Law Article Recommendation Approach Based on Deep Semantic Matching[J]. J Softw, 2022, 33(7): 2618-2632. DOI: 10.13328/j.cnki.jos.006287 .
DINGN, LIUP, SHAOH P, et al. Bi-attention Text-keyword Matching for Law Recommendation[J]. Acta Sci Nat Univ Pekin, 2024, 60(1): 79-88. DOI: 10.13209/j.0479-8023.2023.077 .
[26]
XUN, WANGP H, CHENL, et al. Distinguish Confusing Law Articles for Legal Judgment Prediction[C]//Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics. Stroudsburg, PA, USA: ACL, 2020: 3086-3095. DOI: 10.18653/v1/2020.acl-main.280 .
[27]
BHOGALJ, MACFARLANEA, SMITHP. A Review of Ontology Based Query Expansion[J]. Inf Process Manag, 2007, 43(4): 866-886. DOI: 10.1016/j.ipm.2006.09.003 .
[28]
YUH, XIONGC Y, CALLANJ. Improving Query Representations for Dense Retrieval with Pseudo Relevance Feedback[C]//Proceedings of the 30th ACM International Conference on Information & Knowledge Management. New York: ACM, 2021: 3592-3596. DOI: 10.1145/3459637.3482124 .
[29]
WANGL, YANGN, WEIF R. Query2doc: Query Expansion with Large Language Models[C]//Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing. Stroudsburg: ACL, 2023: 9414-9423. DOI: 10.18653/v1/2023.emnlp-main.585 .
[30]
MACKIEI, CHATTERJEES, DALTONJ. Generative Relevance Feedback with Large Language Models[C]//Proceedings of the 46th International ACM SIGIR Conference on Research and Development in Information Retrieval. New York: ACM, 2023: 2026-2031. DOI: 10.1145/3539618.3591992 .
[31]
GAOL Y, MAX G, LINJ, et al. Precise Zero-shot Dense Retrieval without Relevance Labels[C]//Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). Stroudsburg: ACL, 2023: 1762-1777. DOI: 10.18653/v1/2023.acl-long.99 .
[32]
JAGERMANR, ZHUANGH, QINZ, et al. Query Expansion by Prompting Large Language Models[EB/OL]. (2023-03-15) [2025-11-21].
[33]
WEIJ, WANGX Z, SCHUURMANSD, et al. Chain-of-thought Prompting Elicits Reasoning in Large Language Models[C]//Advances in Neural Information Processing Systems. San Diego: Curran Associates, Inc.,2022, 35: 24824-24837. DOI: 10.1145/2505515.2505665 .
[34]
MACKIEI, CHATTERJEES, DALTONJ. Generative and Pseudo-relevant Feedback for Sparse, Dense and Learned Sparse Retrieval[EB/OL]. (2023-04-05) [2025-11-21].
[35]
FENGJ Z, TAOC Y, GENGX B, et al. Synergistic Interplay between Search and Large Language Models for Information Retrieval[C]//Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). Stroudsburg: ACL, 2024: 9571-9583. DOI: 10.18653/v1/2024.acl-long.517 .
[36]
BAIJ, BAIS, CHUY, et al. Qwen Technical Report[EB/OL]. (2023-08-15)[2025-11-21].