RAG vs 微调:流程、权衡与农业领域案例研究
RAG vs Fine-tuning: Pipelines, Tradeoffs, and a Case Study on Agriculture
AI总结:
本文提出RAG与微调的统一流程及评估指标,在农业数据集上验证了二者可叠加提升LLM的区位知识问答准确率,为LLM在工业领域的应用提供参考。
摘要:
开发者构建大语言模型(Large Language Models, LLM)应用时,整合专有数据与领域特定数据的常用方式有两种:检索增强生成(Retrieval-Augmented Generation, RAG)和微调。RAG通过外部数据增强提示词,而微调则将额外知识融入模型本身,但目前两种方法的优缺点尚未得到充分厘清。本文提出了一套适用于微调与RAG的流程,针对Llama2-13B、GPT-3.5、GPT-4等多款主流LLM梳理了二者的权衡关系。该流程包含多个阶段:从PDF中提取信息、生成问答对、将其用于微调,以及借助GPT-4评估结果。本文还提出了评估RAG与微调流程各阶段性能的指标。我们在一个农业数据集上开展了深入研究——农业行业的AI渗透率较低,我们探索了一项潜在颠覆性应用:能否为农民提供特定区位的洞察?结果表明,本文的数据集生成流程可有效捕捉地理特定知识,同时验证了RAG与微调在定量和定性层面的优势。对模型进行微调可使准确率提升超过6个百分点,且该提升与RAG的效果可叠加,RAG能在此基础上再提升5个百分点的准确率。在一项特定实验中我们还发现,微调后的模型可利用跨地理区域的信息回答特定问题,将答案相似度从47%提升至72%。总体而言,研究结果揭示了基于LLM构建的系统如何适配并整合对特定行业至关重要的维度的知识,为LLM在其他工业领域的进一步应用铺平了道路。
英文摘要:
There are two common ways in which developers are incorporating proprietary and domain-specific data when building applications of Large Language Models (LLMs): Retrieval-Augmented Generation (RAG) and Fine-Tuning. RAG augments the prompt with the external data, while fine-Tuning incorporates the additional knowledge into the model itself. However, the pros and cons of both approaches are not well understood. In this paper, we propose a pipeline for fine-tuning and RAG, and present the tradeoffs of both for multiple popular LLMs, including Llama2-13B, GPT-3.5, and GPT-4. Our pipeline consists of multiple stages, including extracting information from PDFs, generating questions and answers, using them for fine-tuning, and leveraging GPT-4 for evaluating the results. We propose metrics to assess the performance of different stages of the RAG and fine-Tuning pipeline. We conduct an in-depth study on an agricultural dataset. Agriculture as an industry has not seen much penetration of AI, and we study a potentially disruptive application - what if we could provide location-specific insights to a farmer? Our results show the effectiveness of our dataset generation pipeline in capturing geographic-specific knowledge, and the quantitative and qualitative benefits of RAG and fine-tuning. We see an accuracy increase of over 6 p.p. when fine-tuning the model and this is cumulative with RAG, which increases accuracy by 5 p.p. further. In one particular experiment, we also demonstrate that the fine-tuned model leverages information from across geographies to answer specific questions, increasing answer similarity from 47% to 72%. Overall, the results point to how systems built using LLMs can be adapted to respond and incorporate knowledge across a dimension that is critical for a specific industry, paving the way for further applications of LLMs in other industrial domains.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。