DARE: Allineare gli Agenti LLM con l'Ecosistema Statistico R tramite Recupero Consapevole della Distribuzione
DARE: Aligning LLM Agents with the R Statistical Ecosystem via Distribution-Aware Retrieval
March 5, 2026
Autori: Maojun Sun, Yue Wu, Yifei Xie, Ruijian Han, Binyan Jiang, Defeng Sun, Yancheng Yuan, Jian Huang
cs.AI
Abstract
Gli agenti basati su Large Language Model (LLM) possono automatizzare i flussi di lavoro di data science, ma molti rigorosi metodi statistici implementati in R rimangono sottoutilizzati poiché gli LLM faticano con la conoscenza statistica e il recupero degli strumenti. Gli approcci esistenti potenziati dal retrieval si concentrano sulla semantica a livello di funzione e ignorano la distribuzione dei dati, producendo corrispondenze subottimali. Proponiamo DARE (Distribution-Aware Retrieval Embedding), un modello di retrieval leggero e plug-and-play che incorpora informazioni sulla distribuzione dei dati nelle rappresentazioni delle funzioni per il recupero di pacchetti R. I nostri principali contributi sono: (i) RPKB, una R Package Knowledge Base curata, derivata da 8.191 pacchetti CRAN di alta qualità; (ii) DARE, un modello di embedding che fonde caratteristiche distributive con i metadati delle funzioni per migliorare la rilevanza del recupero; e (iii) RCodingAgent, un agente LLM orientato a R per la generazione affidabile di codice R e una suite di attività di analisi statistica per valutare sistematicamente gli agenti LLM in scenari analitici realistici. Empiricamente, DARE raggiunge un NDCG@10 del 93,47%, superando i modelli di embedding open-source all'avanguardia fino al 17% nel recupero dei pacchetti, pur utilizzando un numero di parametri sostanzialmente inferiore. L'integrazione di DARE in RCodingAgent produce miglioramenti significativi nelle attività di analisi downstream. Questo lavoro contribuisce a colmare il divario tra l'automazione tramite LLM e l'ecosistema statistico maturo di R.
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.