Master LLMs with our FREE course in collaboration with Activeloop & Intel Disruptor Initiative. Join now!


Inside RAFT: UC Berkeley’s Method to Improve RAG for Domain Specific Scenarios
Artificial Intelligence   Latest   Machine Learning

Inside RAFT: UC Berkeley’s Method to Improve RAG for Domain Specific Scenarios

Author(s): Jesus Rodriguez

Originally published on Towards AI.

Created Using DALL-E

I recently started an AI-focused educational newsletter, that already has over 165,000 subscribers. TheSequence is a no-BS (meaning no hype, no news, etc) ML-oriented newsletter that takes 5 minutes to read. The goal is to keep you up to date with machine learning projects, research papers, and concepts. Please give it a try by subscribing below:

TheSequence U+007C Jesus Rodriguez U+007C Substack

The best source to stay up-to-date with the developments in the machine learning, artificial intelligence, and data…

Pretraining Large Language Models (LLMs) on massive text datasets has become the norm. When these LLMs are applied to specific tasks, it’s often necessary to integrate additional information, such as the latest news or specialized knowledge, into the already trained model. This can be achieved either by prompting the model with new data or by fine-tuning it. Yet, the best way to incorporate this new knowledge into the models is still under debate. A recent paper from UC Berkeley proposes RAFT, a new technique to address precisely that issue.

One of the key challenges in enhancing LLMs with new information is figuring out how to adjust these models for use in Retrieval Augmented Generation (RAG) within specialized fields. The main strategies considered are in-context learning through RAG and supervised fine-tuning. RAG allows LLMs to refer to external documents for answers, but this approach doesn’t fully utilize the learning potential in specific domain settings or make use of available documents beforehand. On the other hand, supervised fine-tuning aims to identify broader patterns in the documents, which could lead to better performance in tasks and alignment with user needs. However, this method may not always take advantage of documents during the testing phase or may overlook errors in document retrieval.

To make this easier to understand, think of it as preparing for an open-book test. Current in-context retrieval methods are like sitting for the test without prior study, while fine-tuning methods are akin to studying without using the book during the actual test. Despite focusing on in-domain learning, these strategies might not be well-prepared for the real-world application of their knowledge.

Image Credit:

Enter RAFT

The Berkeley paper introduces Retrieval-Augmented Fine Tuning (RAFT), a new strategy designed to refine LLMs by embedding domain-specific knowledge and enhancing RAG performance in those areas. RAFT seeks to teach models about specific fields through fine-tuning and to maintain accuracy even when faced with imperfect data retrieval.

RAFT introduces a unique approach for preparing training data to suit domain-specific, open-book scenarios similar to in-domain RAG. In this method, training data is organized to include a question, a series of documents, and a detailed answer derived from these documents. Documents are categorized into two types: ‘oracle’ documents, which directly inform the answer, and ‘distractor’ documents, which do not. Oracle documents might consist of more than one document for certain questions, mirroring real-world complexities. During training, the language model is fine-tuned to generate answers based on the documents and questions provided, improving its performance and accuracy.

Image Credit:

Additionally, RAFT encourages LLMs to critique their own answers and reasoning by comparing them to correct ones, promoting self-improvement.

Image Credit:

To demonstrate RAFT’s effectiveness, it was tested against models fine-tuned with a different method on the HotpotQA dataset. Results showed that while other models might retrieve incorrect information, RAFT accurately identified the right details, showcasing its superior capability in applying domain-specific knowledge accurately.

Image Credit:

RAFT is one of the most novel RAG techniques published recently. The implementation is also relatively straightforward so its likely that we will RAFT integrated into RAG frameworks very soon.

Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

Published via Towards AI

Feedback ↓