Cobus Greyling

A Study Comparing RAG & Fine-Tuning For Knowledge Base Use-Cases

Written by Cobus Greyling | Oct 24, 2024 9:06:14 AM

The selection of technology should be driven primarily by the requirements and goals of a particular use-case or problem, rather than being determined solely by the capabilities or preferences of the available technology.

Introduction

Because I am interested and fascinated with technology, I tend to focus on the technology and not the use-case requirements.

However, for any organisation a fundamental principle in technology and product development should be identifying an appropriate use-case.

Hence emphasising that the selection of technology should be driven primarily by the requirements and goals of a particular use-case or problem, rather than being determined solely by the capabilities or preferences of available technology.

Technology must align with needs and different technologies excel in different areas. By focusing on the specific requirements of a use-case, you can choose the technology that best aligns with those needs. This ensures that the solution will be effective and efficient in addressing the problem at hand.

Tailoring the technology to the use-case allows for optimisation. This means you can choose the most appropriate tools, frameworks, languages, and platforms to achieve the desired outcome efficiently. It also enables you to optimise factors such as performance, scalability, and cost-effectiveness.

Stop trying to fit a solution into a predefined technology stack, approach problems with an open mind, exploring various options and selecting the one that best meets the requirements.

Having said all of this, solutions must be flexible and highly scaleable.

In practice, this principle requires careful analysis and evaluation of the requirements, constraints, and objectives of the use-case before making decisions about the technology to be employed. It also involves ongoing assessment and adjustment as the project progresses and new information becomes available.

Back To The Study

This study examines the performance of both RAG and Fine-Tuning for the following large language models:

  • GPT-J-6B,
  • OPT-6.7B,
  • LlaMA &
  • LlaMA-2.

The study demonstrates that RAG-based architectures are more efficient than models produced with Fine-Tuning for Knowledge Base, Question-Answering implementations. And hence my introduction on the importance of the use-case.

This obviously does not say fine-tuning is less efficient than RAG, but it means that in this particular use-case and scenario RAG was more efficient.

The study points out that connecting RAG and Fine-Tuning is not trivial; in this study connecting, Fine-Tuned models with RAG can caused a deprecation in performance.

The flow diagram below illustrates the RAG model (best approach) used as a search engine based on the vector embeddings of sentences.

Source

Findings

When building LLM-based knowledge base systems, RAG (Retrieval-Augmented Generation) showcases superior performance compared to Fine-Tuned Models. RAG achieves this by harnessing indexing with embedded vectors, enabling the creation of a dataset conducive to rapid and efficient searches. Consequently, RAG surpasses the performance of fine-tuned models.

One prominent strength of RAG lies in its adeptness at managing hallucinations, which are instances of false information generated by the model.

RAG-based systems excel in minimising hallucinations, resulting in more precise and accurate outcomes when compared to fine-tuned systems.

The process of expanding RAG-based systems with new information is simpler and requires less computational effort compared to fine-tuning.

The simplicity of RAG-based systems stems from the straightforward process of integrating new data.

This involves simply appending the new information to the existing dataset. In contrast, FN often requires more intricate calculations, leading to increased complexity.

In Conclusion

This study illustrates the importance of determining the use-case and based on the requirements of the use-case, make technology decisions.

And when technology decisions are made, factors like scaleability, flexibility and user-experience must not be neglected.

Find the study here.