

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 比较检索增强生成和微调
<a name="rag-vs-fine-tuning"></a>

下表描述了微调和基于 RAG 的方法的优缺点。


****  

| 方法 | 优点 | 缺点 | 
| --- | --- | --- | 
| 微调 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/retrieval-augmented-generation-options/rag-vs-fine-tuning.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/retrieval-augmented-generation-options/rag-vs-fine-tuning.html) | 
| RAG | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/retrieval-augmented-generation-options/rag-vs-fine-tuning.html) | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/retrieval-augmented-generation-options/rag-vs-fine-tuning.html) | 

如果您需要构建引用您的自定义文档的问答解决方案，那么我们建议您从基于 RAG 的方法开始。如果您需要模型执行其他任务，例如汇总，请使用微调。

您可以将微调和 RAG 方法组合到一个模型中。在这种情况下，RAG 架构不会改变，但是生成答案的 LLM 也会使用自定义文档进行微调。这结合了两全其美的优势，它可能是您的用例的最佳解决方案。有关如何将监督微调与 RAG 结合起来的更多信息，请参阅中的 [RAFT：使语言模型适应特定领域的 RAG](https://arxiv.org/pdf/2403.10131) 研究。University of California, Berkeley