让大模型更懂R统计工具,通过数据分布信息提升代码检索准确率。
DARE: Aligning LLM Agents with the R Statistical Ecosystem via Distribution-Aware Retrieval
- 基于数据分布特征融合函数元信息,构建R包检索嵌入模型。
- 在8,191个CRAN包上实现93.47%的NDCG@10,优于现有模型17%。
- 适合需要精准生成统计代码的研究者和自动化分析场景。
大型语言模型(LLM)代理可自动化数据科学流程,但许多成熟的统计方法因在R中实现而未被充分使用,原因是LLM难以获取统计知识并准确检索工具。现有增强检索方法仅关注函数语义,忽略数据分布,导致匹配效果不佳。本文提出DARE(Distribution-Aware Retrieval Embedding),一种轻量级、即插即用的检索模型,将数据分布信息融入函数表示以提升R包检索相关性。主要贡献包括:(i) RPKB,一个源自8,191个高质量CRAN包的结构化知识库;(ii) DARE,融合分布特征与函数元数据的嵌入模型,显著提升检索相关性;(iii) RCodingAgent,面向R的LLM代理,支持可靠代码生成及一系列统计分析任务,用于在真实分析场景下系统评估LLM代理性能。实验表明,DARE在包检索任务中达到93.47%的NDCG@10,相比最优开源嵌入模型提升高达17%,且参数量显著更少。将其集成至RCodingAgent后,在下游分析任务中取得显著提升。本工作有效缩小了大模型自动化与成熟R统计生态之间的差距。
原文摘要 · Abstract (English)
Large Language Model (LLM) agents can automate data-science workflows, but many rigorous statistical methods implemented in R remain underused because LLMs struggle with statistical knowledge and tool retrieval. Existing retrieval-augmented approaches focus on function-level semantics and ignore data distribution, producing suboptimal matches. We propose DARE (Distribution-Aware Retrieval Embedding), a lightweight, plug-and-play retrieval model that incorporates data distribution information into function representations for R package retrieval. Our main contributions are: (i) RPKB, a curated R Package Knowledge Base derived from 8,191 high-quality CRAN packages; (ii) DARE, an embedding model that fuses distributional features with function metadata to improve retrieval relevance; and (iii) RCodingAgent, an R-oriented LLM agent for reliable R code generation and a suite of statistical analysis tasks for systematically evaluating LLM agents in realistic analytical scenarios. Empirically, DARE achieves an NDCG at 10 of 93.47%, outperforming state-of-the-art open-source embedding models by up to 17% on package retrieval while using substantially fewer parameters. Integrating DARE into RCodingAgent yields significant gains on downstream analysis tasks. This work helps narrow the gap between LLM automation and the mature R statistical ecosystem.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。