Pretraining Large Language Models (LLMs) on large corpora of textual data is now a standard paradigm. When using these LLMs for many downstream applications, it is common to additionally bake in new knowledge (e.g., time-critical news, or private domain knowledge) into the pretrained model either through RAG-based-prompting, or fine-tuning. However, the optimal methodology for the model to gain such new knowledge remains an open question. In this paper, we present Retrieval Augmented FineTuning (RAFT), a training recipe that improves the model's ability to answer questions in a "open-book" in-domain settings. In RAFT, given a question, and a set of retrieved documents, we train the model to ignore those documents that don't help in answering the question, which we call, distractor documents. RAFT accomplishes this by citing verbatim the right sequence from the relevant document that would help answer the question. This coupled with RAFT's chain-of-thought-style response helps improve the model's ability to reason. In domain-specific RAG, RAFT consistently improves the model's performance across PubMed, HotpotQA, and Gorilla datasets, presenting a post-training recipe to improve pre-trained LLMs to in-domain RAG. RAFT's code and demo are open-sourced at github.com/ShishirPatil/gorilla.
翻译:在大规模文本语料上预训练大型语言模型(LLMs)已成为标准范式。当将这些LLMs用于下游应用时,通常需要通过基于RAG的提示或微调,将新知识(如时效性新闻或私有领域知识)融入预训练模型。然而,使模型获取此类新知识的最优方法仍是开放性问题。本文提出检索增强微调(RAFT),这是一种训练方案,旨在提升模型在"开卷"领域设置中回答问题的能力。在RAFT中,给定问题及一组检索文档,我们训练模型忽略那些无助于回答问题的文档(我们称之为干扰文档)。RAFT通过精确引用相关文档中能帮助回答问题的正确序列来实现这一点,并结合链式思维风格的响应,提升模型的推理能力。在领域特定的RAG中,RAFT在PubMed、HotpotQA和Gorilla数据集上持续提升了模型性能,提供了一种将预训练LLMs适配至领域内RAG的后训练方案。RAFT的代码和演示已在github.com/ShishirPatil/gorilla开源。