RAFT: Adapting Language Model to Domain Specific RAG

Authors: tianjun  zhang
shishir g patil
naman  jain
sheng  shen
matei  zaharia
ion  stoica
joseph e gonzalez
Venue: colmweb_org_COLM_2024_Conference
Published: 2024-03-22 21:46:07

Abstract: 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 incorporate new information into the pretrained model either through RAG-based-prompting, or finetuning. 
However, the best methodology to incorporate information remains an open question. 
In this paper, we present Retrieval Augmented Fine Tuning (RAFT), a training recipe which improves the model's ability to answer questions in "open-book" in-domain settings. In training 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 to 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.

Main paper: 
 introduction: 
 Trained on vast quantities of public data, Large Language Models LLMs have achieved significant advances in a wide range of general knowledge reasoning tasks Brown et al. (2020) ; Wei et al. (2022) . However, increasingly LLMs are being employed in specialized domains to support tasks ranging from code completion for specific software frameworks to question answering on specific document collections (e.g., legal or medical documents). In these settings, general knowledge reasoning is less critical and instead the primary goal is to maximize accuracy based on a given set of documents. Indeed, adapting LLMs to the specialized domains (e.g., recent news, enterprise private documents, or program resources constructed after the training cutoff) is essential to many emerging applications (Vu et al., 2023; Lazaridou et al., 2022) and is the focus of this work. This paper studies the following question -How do we adapt pre-trained LLMs for Retrieval Augmented Generation (RAG) in specialized domains?When it comes to adapting LLMs to specialized domains, we consider the following two candidates: in-context learning through Retrieval-Augmented Generation (RAG) and supervised fine-tuning. RAG based methods allow the LLM to reference the documents when answering questions. However, RAG based in-context learning methods fail to leverage the learning opportunity afforded by the fixed domain setting and early access to the test documents. Alternatively, supervised fine-tuning offers the opportunity to learn more general patterns in the documents and better align to end tasks and user preferences Zhou et al. (2023) . However, existing fine-tuning based approaches either fail to leverage the documents at test time (don't incorporate RAG) or fail to account for the imperfections in retrieval process during training.We can draw an analogy to an open-book exam. Existing in-context retrieval methods are equivalent to taking an open-book exam without studying. Alternatively, existing finetuning based approaches implement "studying" by either directly "memorizing" Xiong et al. (2023) the input documents or answering practice questions Wang et al. (2022) without referencing the documents. While these approaches leverage in-domain learning they fail to prepare for the open-book nature of the test setting.In this paper, we study how to combine instruction fine-tuning (IFT) with retrieval augmented generation (RAG). We propose a novel adaptation strategy -Retrieval-Augmented Fine Tuning (RAFT). RAFT specifically addresses the challenge of fine-tuning LLMs to both incorporate domain knowledge while also improving in-domain RAG performance. RAFT aims to not only enable models to learn domain-specific knowledge through fine-tuning, but also to ensure robustness against distracting retrieved information. This is achieved by training the models to understand the dynamics between the question (prompt), the domain-specific documents retrieved, and the right answer. Going back to our analogy to the open book exam, our approach is analogous to studying for an open-book exam by recognizing relevant, and irrelevant retrieved documents.In RAFT, we train the model to answer the question (Q) from Document(s) (D*) to generate answer (A*), where A* includes chain-of-thought reasoning Wei et al. (2022) ; Anthropic (2023) , and in the presence of distractor documents (D k ). We explain the methodology in Section 3 and analyze the sensitivity to the number of distractor documents (k) at train-and test-time in Section 5. RAFT consistently outperforms Supervised-finetuning both withand without-RAG across PubMed Dernoncourt & Lee (2017) , HotPot QA Yang et al. (2018), and HuggingFace Hub, Torch Hub, and Tensorflow Hub Gorilla datasets Patil et al. (2023) , presenting a novel, yet simple technique to improve pre-trained LLMs for in-domain RAG. Our code is available at https://github.com/ShishirPatil/gorilla. 
llms for open-book exam: 
 To understand our goal better, we expand on our analogy between training an LLM with the real-world setting of prepararing for an exam.A closed book exam often refers to the scenario where the LLMs do not have access to any additional documents or references to answer the questions during Figure 2 : Overview of our RAFT method. The top-left figure depicts our approach of adapting LLMs to reading solution from a set of positive and distractor documents in contrast to standard RAG setup where models are trained based on the retriever outputs, which is a mixture of both memorization and reading. At test time, all methods follow the standard RAG setting, provided with a top-k retrieved documents in the context. the exam. For LLMs, this is equivalent to the scenario, for example, in which the LLM is used as a chatbot. In this scenario the LLM draws from the knowledge baked in during pre-training and supervised-finetuning to respond to the users' prompt.In contrast, we liken the open-book exam setting to the scenario in which the LLM can refer to external sources of information (e.g., a website or a book chapter). In such scenarios, typically, the LLM is paired with retriever which retrieves 'k' documents (or specific segments of the document) which are appended to the users' prompt. It is only through these documents retrieved that the LLM gains access to "domain-specific information". As a result, we argue that the LLM's performance in these settings, where it is trained as a general-purpose LLM is largely dependent on the quality of the retriever and how accurately the retriever can identify the most relevant piece of information.In this paper, we focus on the narrower but increasingly popular domain than the general open book exam, which we call the domain-specific open-book exam. Here, we know apriori the domain in which the LLM will be tested. The LLM can respond to the users' prompt using use any and all information from this specific domain, which it has been fine-tuned on. Examples of domain specific examples include enterprise documents, code repositories belonging to an organization, etc. In all these scenarios, the LLM will be used to respond to the questions, whose answers can be found within a collection of documents. The retrieval technique itself has little to no-impact on the mechanism (though it may impact the accuracy). This paper studies the domain-specific open-book setting and how to adapt a pretrained LLM to this specific domain, including how to make it more robust to a varying number of retrieved documents and distractors. 
raft: 
 In this section, we present RAFT, a novel way of training LLMs for domain-specific openbook exams. We first introduce the classical technique of supervised fine-tuning, followed with the key takeaways from our experiments. Then, we introduce RAFT , a modified version of general instruction tuning. Lastly, we provide an overview of the experiments to expect in the later sections.Consider the supervised fine-tuning (SFT) setting for a Question-Answer dataset. The formulation consists of the Dataset (D) from which a set of Question (Q) and corresponding answer (A) pairs are derived or already available. In the classical SFT setting, the model is trained to improve it's ability to answer the questions based on it's knowledge -obtained either during pre-training, or during the SFT training phase. The model so trained can also Figure 3 : RAFT prompt to help LLM evaluate its own generated reasoning and answers, contrasting them with the correct reasoning and answers. The LLM is prompted to identify errors in its reasoning and extract key insights for improvement. This figure specifically represents the 'GenerateExplanation' step in the RAFT algorithm (Section 3). be used at test-time with Retrieval Augmented Generation (RAG) setting, where additional documents can be introduced in the prompt to help the model answer the question. This can be represented as follows:{Train: Q → A}, {0-shot Inference: Q → A}, {RAG Inference: Q + D → A} RAFT:Retrieval Augmented Fine-Tuning (RAFT), presents a novel recipe to prepare finetuning data to tailor the models for domain-specific open-book setting, equivalent to indomain RAG In RAFT, we prepare the training data such that each data point contains a question (Q), a set of documents (D k ), and a corresponding Chain-of-though style answer (A * ) generated from one of the document (D * ). We differentiate between two types of documents: 'golden' documents (D * ) i.e. the documents from which the answer to the question can be deduced, and 'distractor' documents (D i ) that do not contain answerrelevant information. As an implementation detail, the 'golden' document doesn't need to be a single document, but can be more than one document, as is the case in HotpotQA Yang et al. (2018) . Then, for P fraction of the questions (q i ) in the dataset, we retain the golden document (d * i ) along with distractor documents (d k-1 ). For (1 -P) fraction of the questions (q i ) in the dataset, we include no golden document and only include distractor documents (d k ). We then fine-tune the language model using standard supervised training (SFT) technique, training it to generate answers from the provided documents and question. Fig. 2 illustrates the high-level design principal for RAFT .We demonstrate that our RAG approach trains the model to perform better RAG on the set of documents it is trained on i.e., in-domain. By removing the golden documents in some instances, we are compelling the model to memorize answers instead of deriving them from the context. The training data for RAFT is as follows, and an example training data can be seen in Fig. 3 :P % of data: Q + D * + D 1 + D 2 + . . . + D k → A * (1 -P) % of data: Q + D 1 + D 2 + . . . + D k → A *Subsequently, for the test scenario, the model is provided with the Q and top-k documents retrieved by the RAG pipeline. Note that RAFT is independent of the retriever used.A key factor in enhancing training quality is the generation of a reasoning process, such as Chain-of-Thought, to explain the provided answers. RAFT approach is similar: we demonstrate that creating a full reasoning chain and in-addition, clearly citing sources enhances the model's accuracy in answering questions. In Fig. 3 , we illustrate this setup. Generating the training data in this fashion, involves presenting the model with a question, context, and verified answers, and then requesting it to form a reasoning chain that appropriately references the original context.For all the datasets in our experiments, we generate the answers using the technique described above. Note that the Gorilla APIBench dataset, already includes reasoning in the answers. We provide an example of the generation step in Fig. 3 , the detailed reasoning answer includes a citation from the original context inside ##begin_quote## and ##end_quote## as well as the detailed explanation on how to reach the conclusion based on the citations. We demonstrate that adding detailed reasoning paragraphs can help boost the model's performance in our experiment section.Table 1 : RAFT improves RAG performance for all specialized domains: Across PubMed, HotPot, HuggingFace, Torch Hub, and Tensorflow Hub, we see that Domain-specific Finetuning improves significantly of the performance of the base model, RAFT consistently outperforms the existing domain-specific finetuning method with or without RAG. This suggests the need to train the model with context. We compare our model with LLaMA finetuning receipes, and provide GPT-3.5 for reference.  
evaluation: 
 We design our experiments to study how well RAFT performs compared to various baselines. We find that the RAFT-7B model (a finetuned version of LlaMA-2) is better at reading and extracting information from in-domain documents, than domain-specific finetuned model, and general-purpose model with RAG. As an ablation, we also demonstrate how important it is for the model to learn with Chain-of-Thought responses. In this section, we will first introduce all the datasets we used in the experiments, then all the baseline model/fine-tuning techniques that we benchmark against.In our experiments, we use the following datasets to evaluate our model and all baselines. We selected these datasets to represent both popular and diverse domains including Wikipedia, Coding/API documents, and question-answering on medical documents. Natural Questions (NQ) Kwiatkowski et al. (2019) Baselines We consider the following baselines for our experiments:• LlaMA2-7B-chat model with 0-shot prompting: this is the commonly used instruction-finetuned model for QA tasks, where we provide clearly written instructions, but no reference documentation.• LlaMA2-7B-chat model with RAG (Llama2 + RAG): similar to the previous setting, except here we include reference documents. This is a popular technique when dealing with domain-specific QA tasks.• Domain-Specific Finetuning with 0-shot prompting (DSF): Standard supervisedfinetuning, without documents in context. We find that its mostly useful to align the answering style of the model as well as get familiar with the domain context.• Domain-Specific Finetuning with RAG (DSF + RAG): Equip a domain-specific finetuned-model with external knowledge using RAG. So, for the "knowledge" the model does not know, it can still refer to the context. Note that for PubMed QA, since it is a binary yes/no question, we don't observe significant gains when we compare our model with DSF + RAG. Even compared with a much larger and better model GPT-3.5, RAFT demonstrates significant advantages.Overall, the LLaMA-7B model, both with and without the RAG, performs poorly due to its answering style not aligning with the ground truth. By applying domain-specific tuning, we significantly enhance its performance. This process enables the model to learn and adopt the appropriate style of answering. However, introducing RAG to a domain-specifically fine-tuned (DSF) model doesn't invariably lead to better outcomes. This might indicate that the model lacks training in context processing and extracting useful information from it. By incorporating our method, RAFT , we train the model not only to match its answering style with that required but also to improve its document processing capabilities. Consequently, our approach outperforms all others.We also conduct an analysis to evaluate the effectiveness of the Chain-of-Thought approach in enhancing the model's performance. As indicated in Table 2 , simply providing the answer to a question may not always be adequate. This approach can lead to a rapid decrease in loss, resulting in the model beginning to overfit. Incorporating a reasoning chain that not only guides the model to the answer but also enriches the model's understanding can improve the overall accuracy and prevent overfitting to concise answers. In our experiments, integrating the Chain-of-Thought significantly enhances training robustness. We employ GPT-4-1106 to generate our Chain-of-Thought prompts and include an example of the prompt we used in Figure 3 .To illustrate the potential advantages of RAFT over the domain-specifically fine-tuned (DSF) approach, we present a comparative example in Figure 4 . This example qualitatively demonstrates a scenario where the DSF model becomes confused by a question asking for the identity of a screenwriter. Instead of providing the correct name, it mistakenly cites one of the films written by the screenwriter. In contrast, the RAFT model accurately answers the question. This discrepancy suggests that training a model solely with question-answer pairs may impair its ability to derive relevant context from provided documents. . . . ------------------------------------- ---------- RAFT: ##Reason:The screenwriter with credits for the film "Evolution," starring Nicolas Cage and Téa Leoni, is David Weissman. This information is provided in the reference documents where it mentions David Weissman as a screenwriter with film credits including "The Family Man" (2000), "Evolution" (2001), and "When in Rome" (2010). Therefore, the screenwriter for "Evolution" is David Weissman. ##Answer: David Weissman ✓ DSF: The Family Man ✗ 4.4 Should we train the LLM always with the golden context for RAG?In our exploration of whether large language models (LLMs) should always be trained with the golden context for Retrieval-Augmented Generation (RAG), we address a key question: what proportion (p%) of the training data should include golden documents? Intuitively, one might assume that for effective training in reading and extracting information from context (e.g., RAG tasks), the golden document should always be included during training (P = 100%). However, our findings challenge this assumption: incorporating a portion of the training data without the golden document in the context (P = 80%) appears to enhance the model's performance on RAG tasks.Figure 5 presents our investigation into the hyperparameter P%, which represents the percentage of training instances that should include golden documents. We find that the optimal proportion varies across datasets, with P% ranging from 40%, 60%, and 100%. This indicates that training your LLM without the correct corresponding context at times can be beneficial for the downstream task of answering questions related to the documents. In our training setup, we include four distractor documents alongside the golden document, and at test time, we maintain this format by providing the golden document with four distractors. Our findings suggest that, for domain-specific RAG tasks, including a certain percentage of training data without the golden documents in the context proves to be advantageous. 
raft generalizes to top-k rag: 
 We now study another important problem: How does the number of distractor documents in RAFT affect the model's performance when augmented with top-k RAG results during evaluation? Previous research has highlighted the vulnerability of LLMs to irrelevant text (see studies (Shi et al., 2023a; Weston & Sukhbaatar, 2023; Liu et al., 2023) ). This issue is particularly critical for LLMs + RAG since top-k RAG is frequently employed at test time to ensure high recall. Such a scenario necessitates the model to have the ability to discern and disregard irrelevant content, focusing solely on pertinent information. on NQ, TQA and HotpotQA suggest that mixing some amount of data that the golden document is not put in the context is helpful for in-domain RAG.To tackle the challenge of enhancing large language models' (LLMs) ability to sift through irrelevant text within the retrieval pipeline, our analysis revealed that training solely with golden (highly relevant) documents can inadvertently diminish the model's ability to discern and disregard irrelevant information. To address this, our algorithm, RAFT , adopts a strategy that integrates golden documents with a mix of irrelevant ones. This methodology prompts us to investigate the ideal fraction of distractor (irrelevant) documents to incorporate throughout the training process and to assess how well this training approach adapts to different volumes of documents encountered by the Retrieval-Augmented Generation (RAG) during the test phase. Our aim is to refine the balance between relevant and irrelevant information to strenghten the model's efficiency in identifying and utilizing pertinent content. Notice that Sec 4.4 looked what what P% of training data should include distractors, while in this section, we study test-time scenarios.To enhance the robustness of LLMs against irrelevant text in retrieved documents, we adopted a finetuning approach that incorporates both golden (highly relevant) documents and distractor (irrelevant) documents. The model was trained with varying numbers of distractor documents, but consistently evaluated using the top-3 documents obtained from the retriever -not to be confused with p. Our findings, detailed in Fig. 6 , reveal that finetuning with only the golden document frequently results in inferior performance compared to configurations that include a greater number of distractor documents. As we can see in the figure, the better performance for Natural Questions is training with D * + 3D and it is D * + 1D documents with Hotpot QA. This insight has been particularly beneficial for our algorithm, RAFT . In our experiments, we consistently employ a training setup consisting of one golden document alongside four distractor documents.Generalization to a variable number of test-time documents. We extended our research to examine the impact of different quantities of test-time documents on the model's performance. Specifically, our experiments focused on assessing how models, trained with varying numbers of distractor documents, respond to changes in the number of documents presented at test time. The results, illustrated in Fig. 6 , confirm that the inclusion of distractor documents during training indeed makes the model more resilient to fluctuations in the number of documents encountered during testing. This ability to maintain consistent performance despite variations in test-time document numbers further validates the robustness of our approach, RAFT . This finding underscores the importance of a well-calibrated training environment to prepare the model for a range of scenarios it may encounter in real-world. 
related works: 
 Retrieval-Augmented Language Models Retrieval-Augmented Language Models (RALMs) enhance LLMs by integrating a retrieval module that sources relevant information from external knowledge bases, significantly improving performance across various NLP tasks, including language modeling (Guu et al., 2020; Borgeaud et al., 2022; Khandelwal et al., In NQ, we find that training with 4 documents leads to optimal performance, and this changes to 3 and 2 for for Trivia QA and HotPot QA respectively. However, we see that training with only golden documents leads to poor performance.2019; Shi et al., 2023d; Lin et al., 2023b; Shi et al., 2023c; Asai et al., 2023; Xu et al., 2023; Wang et al., 2023) and open-domain question answering (Izacard et al., 2023; Lewis et al., 2020) . For instance, Atlas (Izacard et al., 2023) fine-tunes T5 models with the retriever, treating documents as latent variables, while RETRO (Borgeaud et al., 2022) modifies the decoder-only architecture to include retrieved texts and conducts pre-training from scratch. kNN-LM (Khandelwal et al., 2019) interpolates between the LM's next token distribution and distributions computed from retrieved tokens at inference. (Shi et al., 2023d; Ram et al., 2023) assume black-box access to an LLM, combining it with either off-the-shelf or fine-tuned retriever.Memorization A key question around large neural language models is whether they truly "understand" text (Feldman, 2020; Power et al., 2022) or simply rely on surface pattern memorization (Carlini et al., 2019; Tänzer et al., 2022) . (Feldman, 2020; Carlini et al., 2019; 2022) develop methodologies to quantify the extent of memorization in neural models. (Brown et al., 2020; Power et al., 2022; Liu et al., 2022) further explored how memorization impacts the models' generalization capabilities. (Carlini et al., 2021; Shi et al., 2023b) demonstrated the ability of language models to memorize and regurgitate training data, raising significant privacy concerns (Kandpal et al., 2022; Pan et al., 2020) .Finetuning for RAG More recently, several papers have been exploring the idea of finetuning a pretrained LLM to be better at RAG tasks (Lin et al., 2023a; Wang et al., 2023; Xu et al., 2023; Liu et al., 2024) . These works focus on constructing a combination of finetuning dataset for RAG and train a model to perform well on these tasks. In particular, in their settings, at test time, the domain or documents can be different than the training time; whereas our paper studies a slightly opposite scenario where we only care about testing the LLM on the same set of documents. 
conclusion: 
 RAFT is a training strategy designed to enhance the model's performance in answering questions within a specific domain, in "open-book" settings. We highlight several crucial design decisions, such as training the model alongside distractor documents, organizing the dataset so a portion lacks golden documents in their context, and formulating answers in a chain-of-thought manner with direct quotations from the relevant text. Our evaluations on PubMed, HotpotQA, and Gorilla API Bench underline RAFT's significant potential. 
 
 Appendix:  


Decision: The paper studies domain-specific RAG fine-tuning for both language and code. It shows convincing improvements from domain-specific fine-tuning with retrieved documents from the domain in the context of a language model, and also shows the effect of chain-of-thought style answers and the addition of irrelevant documents in the context. The components of the approach are ablated well.

Pros
* The paper is very clear and easy to understand
* The experiments are thorough and present convincing improvements, with additional experiments added during author response
* The evaluation spans different types of tasks, including language and code
* The results will be of interest to researchers/practitioners

Cons
* The method is not very novel, with very similar methods previously applied to more general domain RAG fine-tuning 
* It would be nice to evaluate the reasoning chains of the model – e.g. how often are references to retrieved paragraphs in the answer actually correct

Reviews: review: paper_summary: paper_summary: This paper presents RAFT, a fine-tuning method designed to enhance the performance of retrieval-augmented generation (RAG) for language models in open-book, in-domain question answering scenarios. The approach involves training language models using a mix of oracle and distractor documents, enabling them to discern relevant information from less useful content in the top-k retrieved documents. By comparing their method against conventional RAG baselines, the authors demonstrate that their approach significantly outperforms existing methods across five question answering datasets.
strength_weakness: strength_weakness: [1] Data Usage Inconsistency: The authors seem to focus on domain-specific datasets such as PubMed and Huggingface, as indicated in the title. However, they have not explicitly stated the inclusion of general domain datasets like NQ and TQA in Section 5. This data usage inconsistency may lead readers to question the analysis of "domain-specific" settings.

[2] Term Inconsistency: There are several key terms used inconsistently throughout the paper, which could reduce readability and clarity. The inconsistencies include:

Is it 'Retrieval Augmented Fine Tuning' or 'Retrieval Aware Fine-Tuning'?
Is it 'golden documents' or 'oracle documents'?
Is it 'sampled negative documents' or 'distractor documents'?

[3] Missing Implementation Details: The paper lacks detailed information on the choice of hyperparameters used in the main experiment (Table 2). This absence of details may hinder readers from reproducing the results presented in the paper.
paper_summary: paper_summary: The authors introduce retrieval-augmented finetuning (RAFT), which trains LLMs to be more robust to retrieval errors in open-domain QA by including distractor documents during instruction fine-tuning. This is achieved by incorporating training examples with mixtures of oracle and distractor documents and without oracle documents entirely, as well as the full reasoning chain to identifying the answer. The authors demonstrate consistent performance improvements over standard RAG and finetuning on PubMed, HotpotQA, and Gorilla APIBench.
strength_weakness: strength_weakness: No obvious reasons
paper_summary: paper_summary: This paper proposes Retrieval Augmented Fine Tuning (RAFT), a fine-tuning method leveraging RAG in domain-specific question-answering tasks. The main idea is to fine-tune LLMs on target domain data with a combination of oracle document context and distractor document context. Comparing with raw LLM, LLM with RAG, and Finetuned LLM, RAFT significantly performs the baselines. Analysis on the fine-tuning data is shown to demonstrate how RAFT works.
strength_weakness: strength_weakness: The idea is relatively straightforward and lacks novel contribution. Domain-specific fine-tuning and RAG are widely known to be effective to solve domain-specific tasks. Both of them are ways to leverage the domain training data. Thus, the results are mostly expected in this paper. Compared to baselines, the proposed method has the following advantages, retrieval and domain-specific annotation:
1. Retrieval is an essential step in the open domain QA task and DSF without proper prompting is a meaningless baseline. DSF with question-answer pairs could only lead to memorization of answers for LLMs since there is no clue how these answers can be generated from the input. 
2. Domain-specific annotation is also important. Even though the LLMs can generalize well on most common knowledge, they still struggle on domain-specific problems and need the downstream task's annotation. Thus, comparing RAFT to baselined without domain-specific fine-tuning, the performance gain is also expected.
Thus, combining these two components is not a novel work.
questions: questions: One possible way to justify RAFT is effective is to apply it to tasks other than open-domain QA, i.e. when the domain-specific annotation is unknown, or when the retrieval is not an essential step. Do you consider trying tasks such as text-to-SQL or reasoning-based QA?
paper_summary: paper_summary: This paper introduces RAFT to improve LLM's RAG performance. It does this by adding distractive documents and chain-of-thought reasoning during fine-tuning on open-book QA datasets. Including distractive documents helps the LLM focus on important info and ignore unimportant details in the top-k documents. Also, adding chain-of-thought reasoning makes its responses more accurate.
strength_weakness: strength_weakness: 1. Applying Chain-of-Thought (CoT) to all the fine-tuning tasks may introduce limitations.

While CoT is known to be helpful for challenging questions, it might not be suitable for simpler tasks, such as sentiment analysis. I notice that in Table 1 and Table 2, the authors only present main experiments and ablations on tasks originally designed as explainable tasks (i.e., tasks requiring CoT). However, what about the main results and ablations for NQ and Trivia QA, which were not originally presented in the CoT mode?

Also, Table 1 exceeds the page width.

2. The evaluation of domain-specific knowledge is not sufficient.

While the author proposes that RAFT can inject domain-specific knowledge into the LLM, it's essential to understand if the fine-tuned LLM can effectively apply its acquired domain knowledge from seen datasets to unseen datasets within the same domain.

For example, consider PubmedQA, which enriches the LLM with biomedical knowledge. During testing, can the fine-tuned model perform well on task types not directly related to PubmedQA but could still benefit from the domain knowledge learned from the PubmedQA dataset?
questions: questions: 1. Regarding Chain-of-Thought, I'm curious about whether fine-tuning using CoT would affect the performance of tasks not originally designed as CoT. For instance, what about the ablations on NQ and TQA? I suspect that the fine-tuned model might initially generate some CoT before producing the final answer. Therefore, I'm interested in whether the final answer aligns with the ground truth.

2. Can the domain-specific knowledge learned from the trained dataset be applied to other types of tasks? For instance, could a model trained on PubmedQA also perform well on benchmarks like MedMCQA [1] or Bio-MMLU [2]  also in the biomedicine domain? As suggested in [3], models trained on domain-specific reading comprehension corpora (i.e., a form of open-book QA) can apply domain-specific knowledge to other tasks within the same domain, which is similar to your fine-tuning setting.

[1] MedMCQA: A Large-scale Multi-Subject Multi-Choice Dataset for Medical domain Question Answering

[2] Measuring Massive Multitask Language Understanding

[3] Adapting Large Language Models via Reading Comprehension

Comments: title: Reply to authors
Thank you for your reply
Author Response
Reply to authors
comment: Thanks for the reply, it resolves my confusion and my review is still positive.
We would like to thank the reviewer for spending time replying to us. We'll add the missing reference in our next revision.
We would like to thank the reviewer for spending time replying to us. We have some new results below: 

**CoT Setting**: We ran some additional ablation on the CoT for NQ and TQA and reported the results below. As the reviewer mentioned, we see a slight degradation of CoT compared to non-CoT settings (but roughly the same number). This might be because the TQA and NQ tasks focus on citing the answering text from the context above without much reasoning involved. We want to say that given the results are very similar, adding CoT is still in general helpful in the settings where the reasoning is heavily involved. However, this indeed is an interesting finding, we will clarify this in the paper and add a discussion on this. 

NQ: CoT: 49.10%; Non-CoT: 50.90%         
TQA: CoT: 62.77%; Non-CoT: 64.77%  

**Domain Knowledge**
We managed to run some ablation on how the knowledge can be generalized between datasets. We have three anonymous figures here. In this setting, we train on NQ/TQA/Hotpot and test on News QA/Squad QA/Web Questions. We found that RAFT can indeed generalize to new domains as well. In the figure, we mainly study how the percentage of the golden documents ($p$%) included in the training dataset will affect the generalization performance. The curves demonstrate that domain generalization can mostly benefit from a training dataset of 100% golden documents, as remembering the knowledge in one domain won't necessarily help another. 

https://drive.google.com/file/d/1R30PcDaMeMyady3NZ6uFj-vlnHYron6i/view?usp=sharing

https://drive.google.com/file/d/1dckLBNICJL4YCDvkyoYc4euQFCHGtgGD/view?usp=sharing

https://drive.google.com/file/d/1bM860jzMlwmt9UqWgTEO7wam0fkxoK7A/view?usp=sharing
Hi, Authors,

Thanks for the reply. I acknowledge the solid results for the proposed domain expert RAG models. Although it might not be included in this paper's scoop, I expect it to be expanded to include more NLP tasks and domains. 

Given the strong results, I am okay with accepting the paper.

Missing reference: Distant Supervision for Multi-Stage Fine-Tuning in Retrieval-Based Question Answering
 https://dl.acm.org/doi/abs/10.1145/3366423.3380060
Dear Authors,

**Regarding the CoT Setting**

I hope you can show the results for NQ and TQA because running an inference and reporting the results does not take too much time, as far as I know. Moreover, from Figure 6 in your paper, you've already done some experiments on NQ and TQA, which suggests it is not too hard for you to run and report these results.

**Regarding Domain Knowledge**

Cross-document evaluation (where the documents are still from the same dataset) may not be enough to demonstrate that the model has gained generalizable domain knowledge. I highly recommend adding at least one cross-dataset experiment to strengthen your claims.