惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
爱范儿
爱范儿
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 叶小钗
Last Week in AI
Last Week in AI
博客园 - 三生石上(FineUI控件)
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - Franky
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 司徒正美
罗磊的独立博客
博客园 - 聂微东
T
Troy Hunt's Blog
美团技术团队
IT之家
IT之家
A
Arctic Wolf
腾讯CDC
雷峰网
雷峰网
SecWiki News
SecWiki News
博客园_首页
L
LINUX DO - 最新话题
Cloudbric
Cloudbric
量子位
N
News and Events Feed by Topic
小众软件
小众软件
C
CXSECURITY Database RSS Feed - CXSecurity.com
Cyberwarzone
Cyberwarzone
J
Java Code Geeks
V
V2EX
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Latest news
Latest news
Webroot Blog
Webroot Blog
F
Fortinet All Blogs
P
Privacy International News Feed
NISL@THU
NISL@THU
Google Online Security Blog
Google Online Security Blog
WordPress大学
WordPress大学
PCI Perspectives
PCI Perspectives
GbyAI
GbyAI
宝玉的分享
宝玉的分享
阮一峰的网络日志
阮一峰的网络日志
S
Secure Thoughts
Simon Willison's Weblog
Simon Willison's Weblog
P
Palo Alto Networks Blog
V
Visual Studio Blog

Runpod Blog.

DeepSeek V4 in the wild, and how to run it on Runpod New Runpod datacenter now live: AP-IN-1 Track GPU spend across your team with Cost Centers The GPU supply supercycle is here. Here’s what AI builders need to know. Community Spotlight: One-click AI image and video generation on Runpod with SwarmUI | Runpod Blog Community Spotlight: LoRA Pilot Data Prep to Inference Introducing the Runpod Assistant: Manage Your Cloud GPU Resources with Natural Language OpenAI's Parameter Golf: Train the Best Language Model That Fits in 16MB on Runpod LLM inference optimization: techniques that actually reduce latency and cost Pruna P-Video and Vidu Q3 public endpoints now available on Runpod Runpod brand spelling guide Quickstart - Runpod Documentation The AI market looks nothing like the narrative Training StyleGAN3 with Vision-Aided GAN on Runpod KoboldAI – The Other Roleplay Front End, And Why You May Want to Use It How to Connect Cursor to LLM Pods on Runpod for Seamless AI Dev Community Spotlight: How AnonAI Scaled Its Private Chatbot Platform with Runpod Prompt Scheduling with Disco Diffusion on Runpod Runpod's Latest Innovation: Dockerless CLI for Streamlined AI Development Run Your Own AI from Your iPhone Using Runpod Introducing Flash: Run GPU workloads on Runpod Serverless: No Docker required Use Claude Code with your own model on Runpod: No Anthropic account required Avoid Errors by Selecting the Proper Resources for Your Pod What hackers built on Runpod at TreeHacks 2026 Easily Back Up and Restore Your Pod with Cloud Sync + Backblaze B2 The Complete Guide to GPU Requirements for LLM Fine-Tuning AI Guides, Tutorials & GPU Infrastructure Insights | Runpod Your first Claude Code project within Runpod: a complete setup guide 10 billion Serverless requests and counting Building for resilience: Runpod’s response to the AWS us-east-1 outage How to Connect Google Colab to Runpod Founder Series #1: The Runpod Origin Story AMD MI300X vs. NVIDIA H100: Mixtral 8x7B Inference Benchmark How to Run the FLUX Image Generator with ComfyUI on Runpod Run Llama 3.1 405B with Ollama on Runpod: Step-by-Step Deployment How to Run FLUX Image Generator with Runpod (No Coding Needed) How to Use 65B+ Language Models on Runpod Deploy Llama 3.1 with vLLM on Runpod Serverless: Fast, Scalable Inference in Minutes Open Source Video & LLM Roundup: The Best of What’s New Run vLLM on Runpod Serverless: Deploy Open Source LLMs in Minutes Introduction to vLLM and PagedAttention New update to Github integration: release rollback! | Runpod Blog A note to the developers who built Runpod with us Deploy ComfyUI as a Serverless API Endpoint Setting up Slurm on Runpod Clusters: A Technical Guide Building an OCR System Using Runpod Serverless From No-Code to Pro: Optimizing Mistral-7B on Runpod for Power Users Lessons While Using Generative Language and Audio For Practical Use Cases Runpod RoundUp 3 – AI Music and Stock Sound Effect Creation New Navigational Changes To Runpod UI Use alpha_value To Blast Through Context Limits in LLaMa-2 Models Runpod Roundup 5 – Visual/Language Comprehension, Code-Focused LLMs, and Bias Detection Runpod is Proud to Sponsor the StockDory Chess Engine Runpod Roundup 4 – Open Source LLM Evaluators, 3D Scene Reconstruction, Vector Search Meta and Microsoft Release Llama 2 as Open Source SuperHot 8k Token Context Models Are Here For Text Generation How to Manage Funding Your Runpod Account Encrypted Volumes on Runpod: Protect Your Data at Rest How to Run a "Hello World" on Runpod Serverless Runpod AI field notes: December 2025 Faster GitHub Builds: Major Performance Improvements to Our Automated Integration Partnering with Defined AI to Bridge the Data Wealth Gap How to Run Serverless AI and ML Workloads on Runpod How to fine-tune a model using Axolotl Transcribe and translate audio files with Faster Whisper Runpod Achieves SOC 2 Type II Certification: Continuing Our Compliance Journey Orchestrating GPU workloads on Runpod with dstack Exploring Runpod Serverless: Create Workers From Templates DeepSeek V3.1: A Technical Analysis of Key Changes from V3-0324 Deep Cogito Releases Suite of LLMs Trained with Iterative Policy Improvement Wan 2.2 Releases With a Plethora Of New Features Iterative Refinement Chains with Small Language Models The New Runpod.io: Clearer, Faster, Built for What’s Next Introducing Clusters: On-Demand Multi-Node AI Compute Run DeepSeek R1 on Just 480GB of VRAM How Do I Transfer Data Into My Runpod? Spot vs. On-Demand Instances: What’s the Difference? Deploy GitHub Repos to Runpod with One Click Run GGUF Quantized Models Easily with KoboldCPP on Runpod How to Work with GGUF Quantizations in KoboldCPP Introducing Better Forge: Spin Up Stable Diffusion Pods Faster Supercharge Your LLMs with SGLang: Boost Performance and Customization Mastering Serverless Scaling on Runpod: Optimize Performance and Reduce Costs Run Larger LLMs on Runpod Serverless Than Ever Before – Llama-3 70B (and beyond!) How to Run vLLM on Runpod Serverless (Beginner-Friendly Guide) Embracing New Beginnings: Welcoming Banana.dev Community to Runpod Stable Diffusion + ComfyUI on Runpod: Easy Setup Guide Runpod RoundUp 2 – 32k Token Context LLMs and New StabilityAI Offerings Runpod Roundup: High-Context LLMs, SDXL, and Llama 2 16k Context LLM Models Now Available On Runpod Savings Plans Are Here For Secure Cloud Pods – How To Purchase a Monthly Plan And Save Big Pygmalion-7b from PygmalionAI has been released, and it's amazing Ada Architecture Pods Are Here – How Do They Stack Up Against Ampere? Spin up a Text Generation Pod with Vicuna and Experience a GPT-4 Rival Using OpenPose to Annotate Poses Within Stable Diffusion Set Up a Chatbot with Oobabooga on Runpod Connect VSCode to Your Runpod Instance (Quick SSH Guide) Deploy a Stable Diffusion UI on Runpod in Minutes Google Colab Pro vs. Runpod: Best GPU Cloud for AI Workloads How to Run a GPU-Accelerated Virtual Desktop on Runpod
RAG vs. Fine-Tuning: Which Is Best for Your LLM?
Shaamil Karim · 2024-07-11 · via Runpod Blog.

Large Language Models (LLMs) have changed the way we interact with technology, powering everything from chatbots to content-generation tools. But these models often struggle with handling domain-specific prompts and new information that isn't included in their training data.

So, how can we make these powerful models more adaptable? Enter Retrieval-Augmented Generation (RAG) and fine-tuning. Both are valuable but operate very differently:

  • RAG enhances an LLM's knowledge by fetching external information during inference, ensuring responses are current and contextually accurate.
  • Fine-tuning involves retraining an existing LLM on a specific dataset, embedding specialized knowledge directly into the model.

Which one should you choose? Let’s dive in.

What is Retrieval-Augmented Generation (RAG)?

Definition and Explanation

Think of Retrieval-Augmented Generation (RAG) like an open-book test. Instead of memorizing everything, the model retrieves relevant information from external sources during inference to generate a response.

Example of RAG in Action

Imagine you’re chatting with a customer service bot about a new product you just bought. You ask, "How do I set up my new smart speaker?"

Here’s how RAG handles it:

  1. Question or Prompt: You start with a question. In this case, "How do I set up my new smart speaker?"
  2. Retrieval Mechanism: The model searches through a database or set of documents to find the most relevant information. It might look through the product manual, setup guides, or FAQs.
  3. Combine and Generate: The model uses the retrieved information along with its pre-trained knowledge to generate a response. It might say, "To set up your smart speaker, plug it into a power source, download the companion app, and follow the on-screen instructions."

With RAG, the chatbot doesn’t need to have all the specific setup details memorized. Instead, it pulls in the latest and most relevant information to give you an accurate and helpful response. This process is like an open-book test—minimal prep but longer response times compared to pre-trained knowledge.

Definition and Explanation

Fine-tuning is like preparing for a closed-book test. You start with a pre-trained model that has a broad understanding, and then you give it extra, specialized training so it becomes an expert in a specific area.

Example of Fine-Tuning in Action

Let’s say you’re building a chatbot for a healthcare app that needs to answer questions about medical conditions. You start with a pre-trained language model that’s good at general language understanding, but you want it to be an expert in healthcare.

Here’s how fine-tuning handles it:

  1. Start with a Pre-trained Model: You begin with a model that already knows a lot about language in general, ex: Llama 70B.
  2. Select Your Specific Dataset: You gather a bunch of medical texts, like doctor’s notes, medical journals, and health guides.
  3. Further Training: You train the model on this specific dataset. The model learns to recognize and understand medical terminology and the context in which it’s used.

Now, when someone asks the chatbot, "What are the symptoms of the flu?", the fine-tuned model responds with detailed, accurate information: "Common symptoms of the flu include fever, chills, muscle aches, cough, congestion, runny nose, headaches, and fatigue."

By fine-tuning the model with specific medical texts, it becomes really good at answering healthcare-related questions. It’s like going from a generalist to a specialist.

Different Types of Fine-Tuning

Fine-tuning isn’t a one-size-fits-all approach. Depending on your needs, you can choose different methods to refine your model. Each technique has its own strengths and use cases, making it important to pick the right one for your specific goals. Here’s a quick overview of the main types of fine-tuning you might encounter:

  • Supervised Fine-Tuning (SFT): This method uses labeled input-output pairs to teach the model how to perform specific tasks. For example, if you want your model to respond to customer service inquiries, you’d provide it with examples of questions and the correct answers.
  • Reinforcement Learning (RL): Think of this as a trial-and-error approach. The model learns by receiving feedback on its actions, which helps it improve over time. A well-known example is Reinforcement Learning from Human Feedback (RLHF), where the model is trained based on human evaluations of its responses.
  • Unsupervised Fine-Tuning: This approach continues pre-training the model by predicting the next word or token in a sequence. It’s useful for instilling new knowledge into the model without needing labeled examples, like expanding the model’s general understanding of a new topic.

RAG vs. Fine-Tuning

Now that we understand RAG and fine-tuning, let’s compare them:

RAG vs Fine-Tuning comparison

RAG vs Fine-Tuning comparison

Choosing between RAG and fine-tuning depends on what you need. RAG is fantastic for tasks that require up-to-date information, keeping responses current and relevant. On the other hand, fine-tuning works well for specialized applications, making your model an expert in specific areas.

RAG Example Use Cases

  • Customer Support: A chatbot that retrieves the latest policy changes or product details to provide accurate answers.
  • Research: A system that pulls recent studies and data to provide a comprehensive overview of a topic.
  • Personal Assistant: Chatbots gathering up-to-date information to ensure accuracy and timeliness.

Fine-Tuning Example Use Cases

  • Domain-Specific Tasks: For example, a healthcare provider fine-tuning a model on medical records to assist in diagnosing diseases.
  • NSFW Content Detection: Fine-tuning a model on NSFW datasets to better detect and classify inappropriate content.
  • Customized Tone of Voice: Fine-tuning a model to output texts like Shakespeare or craft legal arguments like a lawyer.

RAG vs. Fine-Tuning Accuracy On Domain-Specific Knowledge

A paper published by Microsoft Research in January 2024 compared the performance of RAG, fine-tuning, and fine-tuning used in conjunction with RAG on the Massively Multilingual Language Understanding Evaluation (MMLU) benchmark. They looked at how accurate LLMs were in domains like anatomy, astronomy, college biology, college chemistry, and prehistory.

Here’s a quick look at how these methods stack up for informational accuracy:

Results for the MMLU datasets in “ Fine-Tuning or Retrieval? Comparing Knowledge Injection in LLMs ”

Results for the MMLU datasets in “Fine-Tuning or Retrieval? Comparing Knowledge Injection in LLMs
  • RAG Performance: RAG always improves the base model’s accuracy. For example, in College Biology (0-shot), RAG significantly boosted accuracy compared to the base model.
  • Fine-tuning Performance: Fine-tuning almost always infers more accurately than the base model. However, RAG generally outperforms fine-tuning. Fine-tuning only beats RAG in two instances, and even then, only by a slim margin.
  • Combining fine-tuning and RAG: Sometimes, combining fine-tuning with RAG gives better results than using RAG alone. However, RAG still outperforms this combination in about 75% of cases.

While this study shows RAG often outperforms on informational accuracy, this is only one of many use cases. Fine-tuning could perform better than RAG at other tasks like sentiment analysis, NSFW content detection, and tone of voice curation.

RAFT: Using Fine-Tuning to Improve RAG

So far, we’ve explored RAG, fine-tuning, and even using RAG with fine-tuning to enhance language models. Each method has its own strengths, but what if we could combine them in a more integrated way?

A recent paper from a team at Berkeley introduces RAFT (Retrieval-Augmented Fine-Tuning), a novel approach that fine-tunes a model specifically to improve the retrieval and generative process of RAG. This creates a more powerful and adaptable language model, taking the best of both worlds to new heights.

What is RAFT?

RAFT, which stands for Retrieval-Augmented Fine-Tuning, is a novel approach developed by a research team at UC Berkeley to enhance the performance of large language models (LLMs) in domain-specific tasks. This method combines the strengths of Retrieval-Augmented Generation (RAG) and fine-tuning to create a more effective training strategy for LLMs.

How RAFT Works

The RAFT method involves preparing the training data in a way that mimics an "open-book" setting. Here's a simplified breakdown of the process:

  1. Question and Documents: Each training data point includes a question, a set of documents (both relevant and irrelevant), and a detailed answer derived from the relevant documents.
  2. Oracle and Distractor Documents: Documents are categorized as 'oracle' (relevant) and 'distractor' (irrelevant). The model is trained to generate answers by referencing the oracle documents while ignoring the distractors.
  3. Chain-of-Thought Reasoning: The model is encouraged to explain its answers in a detailed, step-by-step manner, which helps improve its reasoning capabilities.

Key Benefits

  • Improved Accuracy: RAFT enhances the model's ability to reason and generate accurate answers by citing specific parts of the documents.
  • Domain-Specific Adaptation: It is particularly effective for domain-specific tasks, improving performance across datasets like PubMed, HotpotQA, and Gorilla.
  • Self-Critique: The approach includes mechanisms for the model to critique its own answers, promoting continuous learning and accuracy.

Differences between RAFT and Using RAG vs. Fine-Tuning Separately

  • Integrated Training: Instead of training retrieval and generation independently, RAFT trains them together. This means that the model will get better at finding relevant documents for certain query prompt while plainly fine-tuning would only improve the generative part of this process.
  • Combined Loss Function: RAFT uses a combined loss function that incorporates both retrieval and generation losses. This helps the model learn to retrieve documents that are most beneficial for generating accurate answers

We can use our open-book and closed-book analogy to imagine what the combination of the two would look like below:

Easy visual understanding of RAFT

Easy visual understanding of RAFT

Research and Results

The RAFT approach has shown significant improvements over traditional fine-tuning and RAG methods, making it a promising technique for future LLM applications.

The paper’s results found that RAFT improves performance for all specialized domains across PubMed, HotPot, HuggingFace, Torch Hub, and Tensorflow Hub. We see comparison of their model, RAFT-7B (Fine-tuned Llama-7B) with LLaMA, with RAG on Llama and also GPT-3.5 below:

Comparison of the RAFT model to base Llama, RAG and Fine-tuned variants from the RAFT paper

Comparison of the RAFT model to base Llama, RAG and Fine-tuned variants from the RAFT paper

Conclusion – Which Should You Choose?

As we’ve explored, RAG, fine-tuning, and RAFT each bring unique strengths to the table for enhancing large language models. RAG excels in retrieving up-to-date information, making it ideal for tasks that require current and relevant data. Fine-tuning, on the other hand, allows models to specialize in specific domains, providing in-depth expertise and tailored responses.

RAFT, the innovative approach from UC Berkeley, combines the best aspects of both RAG and fine-tuning. By training models to integrate retrieval and generative processes, RAFT creates a more powerful and adaptable language model. This method improves accuracy, enhances reasoning, and adapts to domain-specific needs effectively.

In choosing the right method, consider your specific requirements. If you need up-to-date information, RAG is your go-to. For specialized applications, fine-tuning is the way to go. And if you’re looking for a comprehensive approach that leverages the strengths of both, RAFT offers a promising solution.

Check out some videos made by Data Science Dojo and AI Anytime on fine-tuning and implementing it on Runpod. Also, look out for a blog from us soon about implementing RAG on Runpod!

Start Fine-Tuning on Runpod

Author profile: Shaamil Karim