[CVPR 2026] DARE: Bridging the LLM Gap in the R Statistical Ecosystem through Distribution-Aware Retrieval

DARE: Aligning LLM Agents with the R Statistical Ecosystem via Distribution-Aware Retrieval

Summary
Problem
Method
Results
Takeaways
Abstract

The paper introduces DARE (Distribution-Aware Retrieval Embedding), a specialized retrieval model designed to align LLM agents with the R statistical ecosystem. By incorporating data distribution metadata into function representations, it enables the RCodingAgent to accurately select and utilize 8,191 high-quality R packages from CRAN for complex data science tasks, achieving a SOTA NDCG@10 of 93.47%.

TL;DR

While LLM agents excel at Python, they are notoriously "statistically illiterate" when it comes to the rigorous R ecosystem. DARE (Distribution-Aware Retrieval Embedding) fixes this by teaching retrieval models to look at the data (sparsity, distribution, dimensionality) before picking the tool. With only 23M parameters, it crushes massive SOTA models and boosts LLM agent success rates in statistical tasks by up to 56%.

Problem & Motivation: The "Python Bias" and Semantic Blindness

Most LLMs are trained on web-scraped code where Python dominates. Consequently, agents often "hallucinate" R functions or default to inferior Python implementations for complex statistics.

The deeper issue is Semantic Blindness. A user might ask for "clustering," and a standard RAG system might retrieve glm() and glm.nb(). Semantically, they both look like "generalized linear models," but statistically, picking the wrong one (ignoring if data is Poisson or Negative Binomial) leads to scientific garbage. Current models ignore the statistical compatibility of the data distribution.

Methodology: The Core of DARE

The authors' insight is simple yet powerful: Tool selection must be conditioned on data profiles.

1. RPKB: The Foundation

The team crawled 8,191 high-quality CRAN packages to build the R Package Knowledge Base (RPKB). This isn't just a doc-scrape; they used LLMs to extract "Data Profiles"—structured JSONs defining a function's requirements (e.g., handles NA, requires non-Gaussian distribution, high-dimensional).

2. Distribution-Aware Embedding

DARE uses a bi-encoder architecture where the query and the function documentation are both augmented with these profiles.

  • Query side: Encoder(User Request + Inferred Data Profile)
  • Function side: Encoder(Docstring + Extracted Data Profile)

By training with an InfoNCE loss (contrastive learning), the model learns that a "high-dimensional" query should stay far away from "low-dimensional" functions, even if their text descriptions overlap.

Overall Architecture of DARE Figure 1: The DARE training framework, showing the fusion of textual semantics and structured data profiles.

Experiments & Results: David vs. Goliath

Despite its tiny size (23M parameters), DARE achieved an NDCG@10 of 93.47%.

  • Efficiency: It offers a 3-4x speed advantage over BGE-M3, hitting 8,512 Queries Per Second (QPS).
  • Agentic Performance: When integrated into RCodingAgent, the results were transformative. For instance, the Grok-4.1-fast model went from an 18.75% success rate to 75% on a benchmark of 16 rigorous statistical tasks.

Performance Comparison Table 1: DARE outperforms models with 20x more parameters by focusing on domain-specific constraints.

Why it Works: A Case Study

Consider a task for Independent Component Analysis (ICA). A standard agent might write generic code that fails on high-dimensional genomic data. With DARE, the agent retrieves the sharpr2 package because the retrieval model recognized the "genomic/sequence" modality and the "Poisson" distribution assumption in the user's data context.

Case Study Figure 2: Comparison between traditional semantic search (often picking the wrong tool) and DARE's distribution-aware approach.

Critical Analysis & Conclusion

Takeaway: DARE proves that for specialized domains (Law, Medicine, Stats), "bigger" is not always "better." A small, well-conditioned encoder that understands the rules of the domain (statistical assumptions) is more valuable than a massive general-purpose model.

Limitations: The model currently relies on LLMs to synthesize "data profiles" during training. If the LLM misinterprets the documentation during the RPKB construction, the error propagates. Future work needs to bridge the "native proficiency" gap—LLMs still need to be better at writing R code, not just finding R tools.

Future Outlook: Integrating DARE into a Mixture-of-Experts (MoE) agent system could allow an agent to intelligently switch between Python for data munging and R for rigorous hypothesis testing, creating the ultimate automated data scientist.

Find Similar Papers

Try Our Examples

  • Search for recent papers that incorporate structured metadata or data distribution profiles into Retrieval-Augmented Generation (RAG) for scientific code generation.
  • Which study first introduced the concept of "Tool Learning" for LLMs, and how does DARE's decoupled retrieval approach differ from early in-context learning methods?
  • Explore research applying distribution-aware embedding techniques to other specialized domains like Bioinformatics (Bioconductor) or specialized Python libraries (e.g., PyTorch Geometric).
Contents
[CVPR 2026] DARE: Bridging the LLM Gap in the R Statistical Ecosystem through Distribution-Aware Retrieval
1. TL;DR
2. Problem & Motivation: The "Python Bias" and Semantic Blindness
3. Methodology: The Core of DARE
3.1. 1. RPKB: The Foundation
3.2. 2. Distribution-Aware Embedding
4. Experiments & Results: David vs. Goliath
5. Why it Works: A Case Study
6. Critical Analysis & Conclusion