SlideShare a Scribd company logo
Version 1.0
LLM Fine Tuning with QLoRA -
Dataset Generation
Using GPT 3 and 4 to create a set of instructions and results
that can be used for fine-tuning an LLM.
Obioma Anomnachi
Engineer @ Anant
Fine Tuning Overview
● Fine tuning is a method of continuing the training of
an already trained large language model
○ Less computationally intensive than the pre-training
required to produce the base llm
○ Originally viewed as a method of “teaching” facts to an
llm. Turned out to be less useful/practical than methods
like RAG.
○ Fine tuning is more useful in shaping the output format
of an llm. Mostly used these days by the original owners
of llms to produce instruction following or code
generating versions of their existing models.
○ Also used by people working with diffusion image
models to control art style, resolution, or other
variables.
LLM Architecture
● Llm models are transformers with attention,
which are a type of neural network
● Like other deep learning models (image
processing, GANs, etc) they are composed of
blocks with different structures for different
purposes
● LoRA takes advantage of this structure by
freezing the existing blocks in place and
attaching new, smaller sections in between
that the training process is allowed to change
● QLoRA adds quantization to this process,
treating groupings of nearby neurons as if
they have the same value, effectively
decreasing the number of parameters that
are being optimized
Fine Tuning Types
● Instruction fine-tuning
○ Changes the way that the model responds to prompts so that it follows commands rather than just
completing prompts with whatever would follow.
● Transfer learning
○ Fine tuning on a minimum of task specific examples to create a marginal improvement over a pre-trained
model.
● Task specific fine tuning
○ Fine tuning on a specific task or domain with many more examples to work from. Runs the risk of
catastrophic forgetting.
● Multi task learning
○ Including all the desired tasks in the training set to avoid those specific tasks being affected by catastrophic
forgetting
● Sequential fine tuning
○ Task specific fine tuning in sequence to go from more general to more specific domains or tasks
Instruction Format
● For instruction fine tuning, we want specific instructions and results, even when the model is
accomplishing a task other than instruction following.
○ So an instruction that tells the model to do sentiment analysis might look like this:
■ “Analyze the sentiment of the following text and identify if it is positive.”
○ This could be categorized as just instruction fine tuning, or we could conceptualize this as a sort of multi-task
learning where the model is learning to respond to instructions, but also protecting it’s skills at sentiment
analysis or other specific tasks from catastrophic forgetting
● Our instruction data set is based around performing tasks on snippets from technical articles
about Cassandra
○ Therefore it is composed of instruction, input, and output sections. This is similar to other instruction tuning
datasets like alpaca-cleaned, except that the input field is always full
Cassandra Article Dataset
● Starting from the collection of
Cassandra articles powering
Cassandra.Link, we used OpenAI
models to build an instruction
dataset
○ These articles contain a number of
articles on a variety of topics
related to Cassandra, so not every
type of instruction is applicable to
every article
■ For example if an article
includes definitions, we
could order the model to
explain a specific concept
Instruction Generation Process
● First the entire article is attached to the main outer prompt and put through GPT-4
○ This prompt is used to extract which of the specific instruction types this article is suited for
○ We created 14 different instruction types, all of which require some context from the main article
○ This prompt is tuned to return minimal text in order to minimize the cost of using gpt 4
● We use traditional coding techniques to extract the instruction type numbers from the gpt-4
result
● Then each valid instruction type is attached to a system prompt and the article text, and passed to
gpt-3.5 with function-calling ensuring that the output will be valid JSON data
○ The result is a JSON object containing the instruction, input, and output columns that are later combined to
become a full instruction for fine tuning
Demo
Resources
● https://github.com/Anant/llm-fine-tuning-qlora/tree/main
● https://www.analyticsvidhya.com/blog/2023/08/fine-tuning-large-language-
models/
● https://huggingface.co/transformers/v4.10.1/custom_datasets.html
● https://wandb.ai/capecape/alpaca_ft/reports/How-to-Fine-Tune-an-LLM-Part-1-
Preparing-a-Dataset-for-Instruction-Tuning--Vmlldzo1NTcxNzE2
● https://www.turing.com/resources/finetuning-large-language-models
● https://www.lakera.ai/blog/llm-fine-tuning-guide
Strategy: Scalable Fast Data
Architecture: Cassandra, Spark, Kafka
Engineering: Node, Python, JVM,CLR
Operations: Cloud, Container
Rescue: Downtime!! I need help.
www.anant.us | solutions@anant.us | (855) 262-6826
3 Washington Circle, NW | Suite 301 | Washington, DC 20037

More Related Content

PPTX
Machine Learning Orchestration with Airflow
Anant Corporation
 
PDF
Data Engineer's Lunch 89: Machine Learning Orchestration with AirflowMachine ...
Anant Corporation
 
PDF
First steps with Keras 2: A tutorial with Examples
Felipe
 
PDF
End-to-End Natural Language Understanding Pipeline for Bangla Conversational ...
MD Abdullah Al Nasim
 
PDF
Introduction to Deep Learning Lecture 20 Large Language Models
i080224KashifMehmood
 
PDF
CSSC ML Workshop
GDSC UofT Mississauga
 
PPTX
Paper presentation on LLM compression
SanjanaRajeshKothari
 
PPTX
Different paradigms for problem solving.pptx
iitjeesooraj
 
Machine Learning Orchestration with Airflow
Anant Corporation
 
Data Engineer's Lunch 89: Machine Learning Orchestration with AirflowMachine ...
Anant Corporation
 
First steps with Keras 2: A tutorial with Examples
Felipe
 
End-to-End Natural Language Understanding Pipeline for Bangla Conversational ...
MD Abdullah Al Nasim
 
Introduction to Deep Learning Lecture 20 Large Language Models
i080224KashifMehmood
 
CSSC ML Workshop
GDSC UofT Mississauga
 
Paper presentation on LLM compression
SanjanaRajeshKothari
 
Different paradigms for problem solving.pptx
iitjeesooraj
 

Similar to QLoRA Fine-Tuning on Cassandra Link Data Set (1/2) Cassandra Lunch 137 (20)

PDF
C3 w3
Ajay Taneja
 
PPTX
Bert
Abdallah Bashir
 
PPTX
Thomas Wolf "Transfer learning in NLP"
Fwdays
 
PPTX
Deep learning crash course
Vishwas N
 
PDF
10 more lessons learned from building Machine Learning systems - MLConf
Xavier Amatriain
 
PDF
Xavier Amatriain, VP of Engineering, Quora at MLconf SF - 11/13/15
MLconf
 
PDF
10 more lessons learned from building Machine Learning systems
Xavier Amatriain
 
PPTX
Understanding Large Language Models (1).pptx
RabikaKhalid
 
PDF
Software Craftmanship - Cours Polytech
yannick grenzinger
 
PDF
Document Clustering using LDA | Haridas Narayanaswamy [Pramati]
Pramati Technologies
 
PDF
Nips 2017 in a nutshell
LULU CHENG
 
PDF
Overview of Artificial Intelligence - Technology
NickDAgostino3
 
PPTX
Unit 2.pptx
SherinRappai
 
PPTX
Unit 2.pptx
SherinRappai1
 
PDF
Single Responsibility Principle
BADR
 
PDF
Dealing with Data Scarcity in Natural Language Processing - Belgium NLP Meetup
Yves Peirsman
 
PPTX
Object Oriented Programming Part 2 of Unit 1
VigneshkumarPonnusam1
 
PDF
Scaling Recommendations at Quora (RecSys talk 9/16/2016)
Nikhil Dandekar
 
PPTX
AI hype or reality
Awantik Das
 
PDF
OOP concepts with respected with Python
pankajdesai217634
 
Thomas Wolf "Transfer learning in NLP"
Fwdays
 
Deep learning crash course
Vishwas N
 
10 more lessons learned from building Machine Learning systems - MLConf
Xavier Amatriain
 
Xavier Amatriain, VP of Engineering, Quora at MLconf SF - 11/13/15
MLconf
 
10 more lessons learned from building Machine Learning systems
Xavier Amatriain
 
Understanding Large Language Models (1).pptx
RabikaKhalid
 
Software Craftmanship - Cours Polytech
yannick grenzinger
 
Document Clustering using LDA | Haridas Narayanaswamy [Pramati]
Pramati Technologies
 
Nips 2017 in a nutshell
LULU CHENG
 
Overview of Artificial Intelligence - Technology
NickDAgostino3
 
Unit 2.pptx
SherinRappai
 
Unit 2.pptx
SherinRappai1
 
Single Responsibility Principle
BADR
 
Dealing with Data Scarcity in Natural Language Processing - Belgium NLP Meetup
Yves Peirsman
 
Object Oriented Programming Part 2 of Unit 1
VigneshkumarPonnusam1
 
Scaling Recommendations at Quora (RecSys talk 9/16/2016)
Nikhil Dandekar
 
AI hype or reality
Awantik Das
 
OOP concepts with respected with Python
pankajdesai217634
 
Ad

More from Anant Corporation (20)

PPTX
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
PDF
Kono.IntelCraft.Weekly.AI.LLM.Landscape.2024.02.28.pdf
Anant Corporation
 
PDF
Data Engineer's Lunch 96: Intro to Real Time Analytics Using Apache Pinot
Anant Corporation
 
PDF
NoCode, Data & AI LLM Inside Bootcamp: Episode 6 - Design Patterns: Retrieval...
Anant Corporation
 
PDF
Automate your Job and Business with ChatGPT #3 - Fundamentals of LLM/GPT
Anant Corporation
 
PPTX
YugabyteDB Developer Tools
Anant Corporation
 
PPTX
Episode 2: The LLM / GPT / AI Prompt / Data Engineer Roadmap
Anant Corporation
 
PDF
Cassandra Lunch 130: Recap of Cassandra Forward Talks
Anant Corporation
 
PDF
Data Engineer's Lunch 90: Migrating SQL Data with Arcion
Anant Corporation
 
PDF
Cassandra Lunch 129: What’s New: Apache Cassandra 4.1+ Features & Future
Anant Corporation
 
PDF
Data Engineer's Lunch #86: Building Real-Time Applications at Scale: A Case S...
Anant Corporation
 
PDF
Data Engineer's Lunch #85: Designing a Modern Data Stack
Anant Corporation
 
PPTX
CL 121
Anant Corporation
 
PDF
Data Engineer's Lunch #83: Strategies for Migration to Apache Iceberg
Anant Corporation
 
PDF
Apache Cassandra Lunch 120: Apache Cassandra Monitoring Made Easy with AxonOps
Anant Corporation
 
PPTX
Apache Cassandra Lunch 119: Desktop GUI Tools for Apache Cassandra
Anant Corporation
 
PPTX
Data Engineer's Lunch #82: Automating Apache Cassandra Operations with Apache...
Anant Corporation
 
PPTX
Data Engineer's Lunch #60: Series - Developing Enterprise Consciousness
Anant Corporation
 
PPTX
Data Engineer's Lunch #81: Reverse ETL Tools for Modern Data Platforms
Anant Corporation
 
PPTX
Data Engineer’s Lunch #67: Machine Learning - Feature Selection
Anant Corporation
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
Kono.IntelCraft.Weekly.AI.LLM.Landscape.2024.02.28.pdf
Anant Corporation
 
Data Engineer's Lunch 96: Intro to Real Time Analytics Using Apache Pinot
Anant Corporation
 
NoCode, Data & AI LLM Inside Bootcamp: Episode 6 - Design Patterns: Retrieval...
Anant Corporation
 
Automate your Job and Business with ChatGPT #3 - Fundamentals of LLM/GPT
Anant Corporation
 
YugabyteDB Developer Tools
Anant Corporation
 
Episode 2: The LLM / GPT / AI Prompt / Data Engineer Roadmap
Anant Corporation
 
Cassandra Lunch 130: Recap of Cassandra Forward Talks
Anant Corporation
 
Data Engineer's Lunch 90: Migrating SQL Data with Arcion
Anant Corporation
 
Cassandra Lunch 129: What’s New: Apache Cassandra 4.1+ Features & Future
Anant Corporation
 
Data Engineer's Lunch #86: Building Real-Time Applications at Scale: A Case S...
Anant Corporation
 
Data Engineer's Lunch #85: Designing a Modern Data Stack
Anant Corporation
 
Data Engineer's Lunch #83: Strategies for Migration to Apache Iceberg
Anant Corporation
 
Apache Cassandra Lunch 120: Apache Cassandra Monitoring Made Easy with AxonOps
Anant Corporation
 
Apache Cassandra Lunch 119: Desktop GUI Tools for Apache Cassandra
Anant Corporation
 
Data Engineer's Lunch #82: Automating Apache Cassandra Operations with Apache...
Anant Corporation
 
Data Engineer's Lunch #60: Series - Developing Enterprise Consciousness
Anant Corporation
 
Data Engineer's Lunch #81: Reverse ETL Tools for Modern Data Platforms
Anant Corporation
 
Data Engineer’s Lunch #67: Machine Learning - Feature Selection
Anant Corporation
 
Ad

Recently uploaded (20)

PDF
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
PDF
2025 Laurence Sigler - Advancing Decision Support. Content Management Ecommer...
Francisco Javier Mora Serrano
 
PDF
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
PDF
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
PPTX
Tunnel Ventilation System in Kanpur Metro
220105053
 
PPT
SCOPE_~1- technology of green house and poyhouse
bala464780
 
PPTX
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
PDF
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
PDF
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
PPTX
database slide on modern techniques for optimizing database queries.pptx
aky52024
 
PDF
Software Testing Tools - names and explanation
shruti533256
 
PDF
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
PDF
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
PPTX
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
PPTX
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
PPTX
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
PDF
Zero Carbon Building Performance standard
BassemOsman1
 
PPTX
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
PDF
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
PDF
Zero carbon Building Design Guidelines V4
BassemOsman1
 
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
2025 Laurence Sigler - Advancing Decision Support. Content Management Ecommer...
Francisco Javier Mora Serrano
 
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
Tunnel Ventilation System in Kanpur Metro
220105053
 
SCOPE_~1- technology of green house and poyhouse
bala464780
 
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
database slide on modern techniques for optimizing database queries.pptx
aky52024
 
Software Testing Tools - names and explanation
shruti533256
 
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
Zero Carbon Building Performance standard
BassemOsman1
 
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
Zero carbon Building Design Guidelines V4
BassemOsman1
 

QLoRA Fine-Tuning on Cassandra Link Data Set (1/2) Cassandra Lunch 137

  • 1. Version 1.0 LLM Fine Tuning with QLoRA - Dataset Generation Using GPT 3 and 4 to create a set of instructions and results that can be used for fine-tuning an LLM. Obioma Anomnachi Engineer @ Anant
  • 2. Fine Tuning Overview ● Fine tuning is a method of continuing the training of an already trained large language model ○ Less computationally intensive than the pre-training required to produce the base llm ○ Originally viewed as a method of “teaching” facts to an llm. Turned out to be less useful/practical than methods like RAG. ○ Fine tuning is more useful in shaping the output format of an llm. Mostly used these days by the original owners of llms to produce instruction following or code generating versions of their existing models. ○ Also used by people working with diffusion image models to control art style, resolution, or other variables.
  • 3. LLM Architecture ● Llm models are transformers with attention, which are a type of neural network ● Like other deep learning models (image processing, GANs, etc) they are composed of blocks with different structures for different purposes ● LoRA takes advantage of this structure by freezing the existing blocks in place and attaching new, smaller sections in between that the training process is allowed to change ● QLoRA adds quantization to this process, treating groupings of nearby neurons as if they have the same value, effectively decreasing the number of parameters that are being optimized
  • 4. Fine Tuning Types ● Instruction fine-tuning ○ Changes the way that the model responds to prompts so that it follows commands rather than just completing prompts with whatever would follow. ● Transfer learning ○ Fine tuning on a minimum of task specific examples to create a marginal improvement over a pre-trained model. ● Task specific fine tuning ○ Fine tuning on a specific task or domain with many more examples to work from. Runs the risk of catastrophic forgetting. ● Multi task learning ○ Including all the desired tasks in the training set to avoid those specific tasks being affected by catastrophic forgetting ● Sequential fine tuning ○ Task specific fine tuning in sequence to go from more general to more specific domains or tasks
  • 5. Instruction Format ● For instruction fine tuning, we want specific instructions and results, even when the model is accomplishing a task other than instruction following. ○ So an instruction that tells the model to do sentiment analysis might look like this: ■ “Analyze the sentiment of the following text and identify if it is positive.” ○ This could be categorized as just instruction fine tuning, or we could conceptualize this as a sort of multi-task learning where the model is learning to respond to instructions, but also protecting it’s skills at sentiment analysis or other specific tasks from catastrophic forgetting ● Our instruction data set is based around performing tasks on snippets from technical articles about Cassandra ○ Therefore it is composed of instruction, input, and output sections. This is similar to other instruction tuning datasets like alpaca-cleaned, except that the input field is always full
  • 6. Cassandra Article Dataset ● Starting from the collection of Cassandra articles powering Cassandra.Link, we used OpenAI models to build an instruction dataset ○ These articles contain a number of articles on a variety of topics related to Cassandra, so not every type of instruction is applicable to every article ■ For example if an article includes definitions, we could order the model to explain a specific concept
  • 7. Instruction Generation Process ● First the entire article is attached to the main outer prompt and put through GPT-4 ○ This prompt is used to extract which of the specific instruction types this article is suited for ○ We created 14 different instruction types, all of which require some context from the main article ○ This prompt is tuned to return minimal text in order to minimize the cost of using gpt 4 ● We use traditional coding techniques to extract the instruction type numbers from the gpt-4 result ● Then each valid instruction type is attached to a system prompt and the article text, and passed to gpt-3.5 with function-calling ensuring that the output will be valid JSON data ○ The result is a JSON object containing the instruction, input, and output columns that are later combined to become a full instruction for fine tuning
  • 9. Resources ● https://github.com/Anant/llm-fine-tuning-qlora/tree/main ● https://www.analyticsvidhya.com/blog/2023/08/fine-tuning-large-language- models/ ● https://huggingface.co/transformers/v4.10.1/custom_datasets.html ● https://wandb.ai/capecape/alpaca_ft/reports/How-to-Fine-Tune-an-LLM-Part-1- Preparing-a-Dataset-for-Instruction-Tuning--Vmlldzo1NTcxNzE2 ● https://www.turing.com/resources/finetuning-large-language-models ● https://www.lakera.ai/blog/llm-fine-tuning-guide
  • 10. Strategy: Scalable Fast Data Architecture: Cassandra, Spark, Kafka Engineering: Node, Python, JVM,CLR Operations: Cloud, Container Rescue: Downtime!! I need help. www.anant.us | [email protected] | (855) 262-6826 3 Washington Circle, NW | Suite 301 | Washington, DC 20037