

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 比較擷取增強生成和微調
<a name="rag-vs-fine-tuning"></a>

下表說明微調和以 RAG 為基礎的方法的優點和缺點。


****  

| 方法 | 優點 | 缺點 | 
| --- | --- | --- | 
| 微調 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/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_tw/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_tw/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_tw/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。