Fine-Tuning or Retrieval? Comparing Knowledge Injection in LLM s (2024)

Abstract: Large language models (LLMs) encapsulate a vast amount of factual information within their pre-trained weights, as evidenced by their ability to answer diverse questions across different domains. However, this knowledge is inherently limited, relying heavily on the characteristics of the training data. Consequently, using external datasets to incorporate new information or refine the capabilities of LLMs on previously seen information poses a significant challenge. In this study, we compare two common approaches: unsupervised fine-tuning and retrieval-augmented generation (RAG). We evaluate both approaches on a variety of knowledge-intensive tasks across different topics. Our findings reveal that while unsupervised fine-tuning offers some improvement, RAG consistently outperforms it, both for existing knowledge encountered during training and entirely new knowledge. Moreover, we find that LLMs struggle to learn new factual information through unsupervised fine-tuning, and that exposing them to numerous variations of the same fact during training could alleviate this problem.

## introduction large language models (llms) are able to capture vast amounts of factual information @xcite @xcite . llms exhibit a remarkable level of knowledge in various domains due to their massive pre-training datasets. however, there are two significant limitations to this knowledge. first, it is static and does not update with time. second, it is non-specific and thus may lack nuanced expertise in particular domains. while these are two different problems, they are deeply related since their solution is the same: enhancing the model's knowledge. recently, the idea of adapting llms to particular domains and updating their knowledge has * equal contribution. in this work, we focus on the evaluation of a model's knowledge and its ability to memorize, understand, and retrieve factual data. we aim to understand the concept of knowledge injection @xcite @xcite . given some knowledge base in the form of a text corpus, what is the best way to teach a pre-trained model this knowledge? one way to add knowledge to a pre-trained model is through fine-tuning. with fine-tuning, we continue the model's training process and adapt it using task-specific data. by exposing the model to a specific knowledge base, we expect the model weights to adapt accordingly. this process is meant to optimize the model for targeted applications, enhancing its performance and contextual relevance in specialized domains. another method to enhance a model's knowledge base is through the use of in-context learning (icl) @xcite @xcite . the main idea behind icl is to improve the performance of pretrained llms on new tasks by modifying the input query to the model without directly changing the weights of the model. one form of icl is retrieval augmented generation (rag) @xcite . rag uses information retrieval techniques to enable llms to obtain relevant information from a knowledge source and incorporate it into generated text. this study aims to evaluate the knowledge injection capabilities of llms through a comparison of fine-tuning and rag. to illustrate the rationale, let us use an analogy. consider three college students taking a test on a specific topic. all had access to class materials but didn't know the topic beforehand. the first student had the textbook only during the test, the second had pre-test access and studied, and the third lost access upon the test announcement. who would probably perform better? ## background to assess knowledge injection, we must first understand what knowledge means for llms. knowledge and language models defining knowledge is a complex philosophical task far beyond the scope of this research. however, we can examine what factual knowledge means in the context of language models. if a model knows a fact, it can accurately and consistently answer questions about it. furthermore, it can reliably distinguish between true and false statements related to this fact. we can then extend this definition to a whole knowledge base, not just a single fact. mathematically, let @xmath0, where each question has l possible answers and exactly one correct answer. let @xmath1, . . . , a l n )} n @xmath2, and @xmath3. let m be a language model. we denote by m(q n ) ∈ {a 1 n , . . . , a l n } the predicted answer of the model to the n-th question. we define the knowledge score l of m in relation to q to be the standard accuracy score: we say that the model m possesses any knowledge regarding the set of questions q if the following holds: in simpler terms, the model can consistently give correct answers, outperforming a simple random guessing baseline. naturally, if the knowledge score l m,q is higher for one model compared to another, then we assert that the former is more knowledgeable with regards to q compared to the latter. previously seen knowledge one important distinction to make is between knowledge that the model has been exposed to before during pretraining as opposed to entirely new facts. considering the size of modern llm training sets, they cover a vast amount of information available through web-sourced text. as a result, even in niche domains, the goal of knowledge injection is not necessarily to teach the model entirely new facts but rather to "refresh" its memory by inducing a bias toward a particular domain. knowledge and reasoning we emphasize that this knowledge evaluation framework for llms is imperfect. importantly, it doesn't address other quality metrics influencing a model's response. creating a purely knowledge-intensive dataset without involving some level of reasoning is challenging. consequently, a model with robust reasoning abilities might excel on unfamiliar knowledge-intensive tasks by making "educated guesses" in a multiple-choice exam. therefore, any evaluation of knowledge in llms should consider this, with results seen as part of a broader range of benchmarks for reasoning @xcite , reading comprehension @xcite , and general language abilities @xcite . however, this evaluation framework still strongly emphasizes factual information above all else. ## injecting knowledge to language models following the background given in section 2, it is clear that general pre-training is insufficient for many knowledge-intensive tasks. to solve this, an additional post-processing step is essential to augment the knowledge of a pre-trained model. this step is often reffered to as knowledge injection @xcite @xcite . in this section, we examine two widely used frameworks for knowledge injection: fine-tuning (ft) and retrieval augmented generation (rag). we begin by formulating the knowledge injection problem, aiming to explain both methods using consistent terminology. ## the importance of repetition unlike the other tasks, where the model has been exposed to aspects related to the topic during pretraining, current events includes new information. in this case, standard regular fine-tuning not only did not improve the performance of llama2 but also significantly degraded it. to improve the finetuning results, we explored augmentation of the data using paraphrases. data augmentation data augmentation is a well-established method for enhancing the performance of language models and has been surveyed extensively @xcite . using generative models for augmentations has also been used successfully to improve classification models in the past @xcite . an example of data augmentation using paraphrasing can be found in appendix c. ## conclusion and future work large language models possess vast amounts of knowledge on various topics. in this work, we tested their capability to adapt to new knowledge: both specialized and completely unseen. this is among the first studies to compare two prominent approaches in this domain, namely fine-tuning and retrieval augmented generation. while fine-tuning can be useful for many use-cases, we found that rag is a more reliable choice for knowledge injection. some aspects of this work still warrant further research. for example, we focused on unsupervised training as our primary fine-tuning method, as opposed to instruction-tuning or rl-based methods. researching combinations of various techniques, with diverse auxiliary knowledge bases, may yield improved results. this approach, combined with our hypothesis from section 6, could further enhance our understanding of knowledge injection via ft. while we believe that this work further enhances our understanding of knowledge in llms, there is a lot more work to be done in this field. specifically, more research is required regarding the question of knowledge representation in llms, especially from a theoretical perspective. finally, further efforts are needed to measure knowledge in llms. while we employed an empirical approach as described in equation (2), it is important to explore other definitions and perspectives on knowledge as well, and extend upon this work.