[论文解读] RAG vs Fine-tuning: Pipelines, Tradeoffs, and a Case Study on Agriculture
这篇论文比较 Retrieval-Augmented Generation (RAG) 与微调管道在大型语言模型上的表现,给出详细的农业案例研究,并在将 RAG 与微调结合时报告了增量准确度提升。
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.
研究动机与目标
- 激励展示如何使用 RAG 或微调将领域特定数据整合到 LLM 中。
- 构建并评估一个多阶段管道(数据提取、问答生成、RAG、微调)以获得领域知识。
- 在农业场景下,对模型(Llama2-13B、GPT-3.5、GPT-4)进行权衡、成本和性能量化。
- 展示地理特定知识的获取以及答案定位的改进。
- 提供可操作的指导,基于领域数据构建行业型 AI 助手。
提出的方法
- 提出一个多阶段管道:数据获取、PDF 信息提取、问答生成、基于 RAG 的答案生成,以及模型微调。
- 使用 GROBID 将 PDF 转换为结构化的 TEI/JSON,保留文档结构以便锚定。
- 使用 Guidance 框架生成问答,以控制输入/输出结构和锚定上下文。
- 采用基于嵌入的检索(句子变换器 + FAISS)和 GPT-4 进行答案合成。
- 使用 LoRA 和基于 FSDP 的训练,在 8x A100 GPU 上对多个模型(Llama2-13B、GPT-4)进行微调;使用混合精度和余弦学习率调度。
- 使用基于 GPT-4 的指标集进行评估,并在跨域与跨地理的环境下比较 RAG 与微调。
实验结果
研究问题
- RQ1RAG 与微调在提升针对行业特定农业问题的 LLM 性能方面有何比较?
- RQ2空间范围的微调对地理特定知识准确性的影响如何?
- RQ3微调大型模型(如 GPT-4)与单独使用 RAG 或两者结合的成本与性能权衡是什么?
- RQ4地理感知的问答管道是否能提高答案的特异性和跨地理的知识转移?
- RQ5不同基础模型(Llama2-13B、GPT-4、Vicuna)在带有 RAG和/或微调的农业问答中表现如何?
主要发现
- 微调带来超过 6 个百分点的准确性提升。
- 当与微调结合时,RAG 额外带来 5 个百分点的准确性提升。
- 微调模型可以利用跨地理信息把答案相似度从 47% 提升到 72%。
- GPT-4 始终优于其他模型,但其微调和推理成本并不小。
- RAG 是在数据具有上下文相关性时有效(例如农场数据),且往往比基础模型给出更简洁的答案。
- 该研究展示了一个实用的、面向行业的管道,用于创建领域特定的 AI 助手,从问答生成到模型微调。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。