Skip to main content
QUICK REVIEW

[论文解读] CBR-RAG: Case-Based Reasoning for Retrieval Augmented Generation in LLMs for Legal Question Answering

Nirmalie Wiratunga, Ramitha Abeyratne|arXiv (Cornell University)|Apr 4, 2024
Artificial Intelligence in Law被引用 4
一句话总结

本文提出CBR-RAG,一种检索增强生成框架,将基于案例的推理(CBR)整合到基于大语言模型(LLM)的法律问答中,以提升事实准确性与上下文相关性。通过利用CBR的索引、相似性匹配与案例复用机制,将语义相似的过往案例融入LLM提示,该方法在基线模型基础上实现了平均1.94%的答案相似度提升,其中Hybrid AnglEBERT在k=3时表现最佳。

ABSTRACT

Retrieval-Augmented Generation (RAG) enhances Large Language Model (LLM) output by providing prior knowledge as context to input. This is beneficial for knowledge-intensive and expert reliant tasks, including legal question-answering, which require evidence to validate generated text outputs. We highlight that Case-Based Reasoning (CBR) presents key opportunities to structure retrieval as part of the RAG process in an LLM. We introduce CBR-RAG, where CBR cycle's initial retrieval stage, its indexing vocabulary, and similarity knowledge containers are used to enhance LLM queries with contextually relevant cases. This integration augments the original LLM query, providing a richer prompt. We present an evaluation of CBR-RAG, and examine different representations (i.e. general and domain-specific embeddings) and methods of comparison (i.e. inter, intra and hybrid similarity) on the task of legal question-answering. Our results indicate that the context provided by CBR's case reuse enforces similarity between relevant components of the questions and the evidence base leading to significant improvements in the quality of generated answers.

研究动机与目标

  • 为解决LLM生成的法律答案中缺乏事实依据与来源证据的问题,通过在检索增强生成中整合结构化的基于案例推理。
  • 评估不同嵌入表示(通用与领域特定)以及相似性比较策略(跨模态、内部、混合)对法律问答中检索质量的影响。
  • 证明CBR-RAG通过引入语义相似的法律案例生成更丰富、更具上下文相关性的提示,从而提升LLM输出质量。
  • 识别在法律RAG系统中嵌入模型与检索参数的最优配置,重点提升答案保真度并减少幻觉现象。

提出的方法

  • CBR-RAG将CBR循环中的检索、索引与相似性匹配阶段整合进RAG流程,以结构化方式增强法律案例的检索与丰富度。
  • 系统采用基于BERT、LegalBERT与AnglEBERT的嵌入表示,对法律问题与案例进行编码,以计算相似性。
  • 评估三种相似性策略:跨模态相似性(问题与案例之间)、内部相似性(问题或案例内部组件之间)以及结合两者的混合相似性。
  • 采用k-最近邻(k-NN)进行检索,k ∈ {1, 3, 5, ..., 37},基于F1分数评估,选定k=3为最优值。
  • 通过Mistral-7B模型作为生成器,计算LLM输出与参考答案之间的余弦相似度来评估生成答案。
  • 混合嵌入通过组合多种嵌入类型(如BERT + LegalBERT + AnglEBERT)并学习加权系数,以提升细粒度相似性匹配效果。
Figure 1: CBR-RAG
Figure 1: CBR-RAG

实验结果

研究问题

  • RQ1在RAG的检索阶段整合基于案例的推理(CBR)如何提升大语言模型在法律问答中生成答案的质量?
  • RQ2不同嵌入模型(通用与领域特定)对法律RAG系统中检索性能有何影响?
  • RQ3在法律问答任务中,哪种相似性比较策略——跨模态、内部或混合——能实现最有效的案例检索?
  • RQ4检索案例数量(k)如何影响生成答案的事实准确性与语义质量?
  • RQ5结合多种模型的混合嵌入是否能在法律LLM的案例检索与答案生成中超越单一嵌入模型?

主要发现

  • 在[0.25, 0.40, 0.35]权重设置下,Hybrid AnglEBERT在k=3时达到最高的F1分数,确立其为最优配置。
  • CBR-RAG在k=3且提示中包含完整案例上下文时,优于k=1与基线No-RAG模型,实现了与真实答案余弦相似度平均1.94%的提升。
  • 在k=3时,Hybrid AnglEBERT显著优于No-RAG基线与k=3下的混合LegalBERT(p < 0.05,单尾t检验),证实其统计显著性。
  • 在大多数混合嵌入变体中,将完整案例纳入提示优于仅使用支持文本。
  • 即使未在ALQA语料库上进行微调,AnglEBERT的对比学习预训练方法也表现出优于BERT与LegalBERT的性能。
  • 结果表明,在低资源法律领域中,对比学习嵌入比标准自监督掩码方法更具有效性。
Figure 2: Ten most frequent legal acts in the casebase are listed on the left, and the legal act frequency distribution appears on the right.
Figure 2: Ten most frequent legal acts in the casebase are listed on the left, and the legal act frequency distribution appears on the right.

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。