Prompt Engineering vs RAG vs Fine tuning.

Let us explore the difference between prompt engineering, RAG, and fine-tuning.

Criteria

Prompt Engineering

RAG

Fine-Tuning

Purpose

Prompt engineering focuses on how to write an effective prompt that can maximize the generation of an optimized output for a given task.

The purpose of RAG is to relevant information for a given prompt from an external database.

Fine-tuning focuses on training and adapting a model for a specific task.

Model

Model weights are not updated. It focuses on building an effective prompt.

Model weights are not updated. It focuses on building context for a given prompt.

Model weights are updated

Complexity

No technical knowledge required

Compared to fine-tuning it is less complex as it requires skills related to vector databases and retrieval mechanisms only

Technical knowledge required

Compute Cost

Very less cost. Only costs related to API calls

Cost-effective compared to fine-tuning.

We may need specialized hardware to train the model depending on model size and dataset size

Knowledge

The model does not learn new data

The prompt is equipped with new data in the form of context

The model learns new data

Fine Tuning Large Language Model (LLM)

Large Language Models (LLMs) have revolutionized the natural language processing by excelling in tasks such as text generation, translation, summarization and question answering. Despite their impressive capabilities, these models may not always be suitable for specific tasks or domains due to compatibility issues. To overcome this fine tuning is performed. Fine tuning allows the users to customize pre-trained language models for specialized tasks. This involves refining the model on a limited dataset of task-specific information, enhancing its performance in that particular task while retaining its overall language proficiency.

Table of Content

  • What is Fine Tuning?
  • Why Fine-tune?
  • Types of Fine Tuning
  • Prompt Engineering vs RAG vs Fine tuning.
  • When to use fine-tuning?
  • How is fine-tuning performed?
  • Fine Tuning Large Language Model Implementation

Similar Reads

What is Fine Tuning?

Fine-tuning LLMs means we take a pre-trained model and further train it on a specific data set. It is a form of transfer learning where a pre-trained model trained on a large dataset is adapted to work for a specific task. The dataset required for fine-tuning is very small compared to the dataset required for pre-training....

Why Fine-tune?

The pre-trained model or foundation model is trained on a large amount of data using self-supervised training and it learns the statistical representation of language very well. It has learned how to be a good reasoning engine. With fine-tuning we...

Types of Fine Tuning

Let us explore various types of fine-tuning methods....

Prompt Engineering vs RAG vs Fine tuning.

Let us explore the difference between prompt engineering, RAG, and fine-tuning....

When to use fine-tuning?

When we build an LLM application the first step is to select an appropriate pre-trained or foundation model suitable for our use case. Once the base model is selected we should try prompt engineering to quickly see whether the model fits our use case realistically or not and evaluate the performance of the base model on our use case....

How is fine-tuning performed?

There is no standard way of fine-tuning as there are many methods and the fine-tuning steps depend on the task objective at hand. However, it can be generalized to have the below steps:...

Fine Tuning Large Language Model Implementation

Let us fine tune a model using PEFT LoRa Method. We will use flan-t5-base model and DialogSum database. Flan-T5 is the instruction fine-tuned version of T5 release by Google. DialogSum is a large-scale dialogue summarization dataset, consisting of 13,460 (Plus 100 holdout data for topic generation) dialogues with corresponding manually labeled summaries and topics....

Conclusion

...