ragR: R中检索增强生成与RAG评估
ragR: Retrieval-Augmented Generation and RAG Assessment in R
AI总结:
ragR是首个在R中集成RAG系统构建与评估的框架,提供文档处理、嵌入存储、相似性检索、生成及RAGAS评估功能,支持四种核心指标评估。
摘要:
检索增强生成(RAG)结合文档检索与大语言模型,以外部证据生成响应。尽管已有多个R包支持RAG工作流的核心组件,但R中RAG系统的集成评估仍有限,通常通过Python工具如RAGAS框架实现。为填补这一空白,我们引入ragR,一个R包,统一了文档摄入、嵌入和向量存储、基于相似性的检索、有据生成、结构化问题-答案日志记录及RAGAS风格的评估,全部在单一R原生工作流中完成。当前实现提供基于LLM的评分,用于四个核心RAGAS指标:上下文精确度、上下文召回率、忠实度和答案相关性。在受控环境下进行的验证实验表明,ragR在多个用例中表现出与参考Python RAGAS工作流相似的指标行为。通过在R中集成RAG构建与评估,ragR提供了一个可复现的工作流,为RAG系统在R生态系统内的研究、教学和中等规模实验提供实用框架。
英文摘要:
Retrieval-augmented generation (RAG) combines document retrieval with large language models (LLMs) to produce responses grounded in external evidence. While several R packages support core components of RAG workflows, integrated evaluation of RAG systems in R remains limited and is often conducted through Python-based tools, most notably the RAG assessment (RAGAS) framework. To address this gap, we introduce ragR, an R package that unifies document ingestion, embedding and vector storage, similarity-based retrieval, grounded generation, structured question-answer logging, and RAGAS-style evaluation within a single R-native workflow. Its evaluation module, ragR-RAGAS, uses an LLM as a judge to score four core RAGAS metrics: context precision, context recall, faithfulness, and answer relevance. To assess the credibility of these automated judgments, we compared ragR-RAGAS with two independent human annotators on three document collections. The human annotators demonstrated consistently high agreement, and ragR-RAGAS generally aligned with their judgments, although discrepancies were more pronounced for context precision and the identification of unsupported statements. By integrating RAG construction and evaluation within a reproducible workflow in R, ragR provides a practical framework for research, teaching, and moderate-scale experimentation on RAG systems entirely within the R ecosystem.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。