"okay, but I want GPT to perform 10x for my specific use case" - Here is how

AI Jason · Intermediate ·🧠 Large Language Models ·2y ago

Key Takeaways

Explains how to fine-tune a large language model for a specific use case

Full Transcript

so a lot of people are saying that I want GPT for a specific use case like medical or legal but there are two methods you should consider to achieve the outcome one method is fine tuning which means you retrieve the large layout model with a lot of private data you're holding and another is knowledge base which means you are not actually retraining the model instead you are creating an embedding or vector database of all your knowledge and try to find the relevant data to feed into large language model as part of prop and these two methods are feet for different purpose so what fine tuning is good at is making sure the large knowledge model behave in certain way for example if you want to digitize someone like the other AI talks like Trump that's where you will use fine too because you can feed all those chat history or broadcast interview transcript into large language model so it can have certain type of behavior but if your use case is that I have a bunch of domain knowledge like a legal case or financial Market stats fine tune is actually not going to work because it's not good at providing very accurate data instead you should use embedding to create a knowledge base so so that where someone asking which stock has the highest price movement yes it will get real data and feed it as part of pop so those two methods are three different use case a lot of times you can just create it in betting but find here is still super valuable for you to create a larger knowledge model that have certain Behavior it's a pretty way to decrease cost because instead of adding a big chunk of prompt to making sure large language model can behave in a certain way you can just teach large language models so you cut the cost so there's still a lot of legit use case where you should fine tune the legendary model unless I want to show you a step-by-step case study how can you fine-tune large language model for creating military power and this is a great use case because it is not a task that base model like GPT are good at what I want is a large energy model can take a simple instruction like this and turn it into a Miss Journey prompt so let's get started firstly we need to choose which model to use for fine tuning hacking face has this leaderboard for all the open larger launcher model and you can take a look to choose is the one that suits you most the one I'm going to use is the Falcon it is one of the most powerful large Lounge model there has been a number one place on the leaderboard in a very very short time it's also a few ones that are available for the commercial use so you can actually use this for production level products for your own company and it's actually not just our English a large set of different type of languages like German Spanish French and it has couple versions 40b version which is most powerful but also a bit slower think about more like gpd4 but it also a 7B version which is much faster and cheaper to train as well the next which is most important step is getting your data sets ready the quality of your data set decides the quality of your fine tune model there are two type of data sets you might use one is public data sets that you can get from internet and their model place you can get it like Kegel which is data set library that has a wide range of data across different topics like sports Health software you can just click on any of them preview the details of the data and if it's good you can download to use on the outside hugging is also have very big data set library and to find the ones that you will use for training large Lounge model you can click on data sets move down here try to find the text generation and you can try to find the relevant data sets that you want for example this is one public data set for medical related QA data sets you can preview what data actually inside but on the other side I think the most of the use case for fine tuning is actually use your own private data sets that is not available anywhere else it actually didn't require too big a data sets you can even start as little as 100 rows of data so it should be still manageable so this is one tip I want to share is that you can actually use GPT to create a huge amount of training data for example I have collected list of really high quality mid-journey prompts and I want chat GPD to reverse engineer generate a simple user instruct that might generate this mid-journing prompt and what I will do is give charity GPD a prompt like this you will help me create training data sets for generating text to image prompts and then I'll give it a few examples like this is from and this is user input and in the end it will start generating a user input that pair with this prompt which I can use them as a training data for fine-tuning Falcon model and all we need to do just repeat this process for hundreds or thousands of rows but luckily there are platforms like Randomness AI where you can run the GPT prompt f scale in bulk for example I can create an AI chain with this input variable called mediterating pump and then I will copy paste The Prompt that I was using in charge GPT the point the last prompt to the variable that we created here and let's run this so you can see it is working properly as it generates a user input and all we need to do next is go to the use tab this running block option allow me to upload the whole CSV file of the military prompt and then it will import the whole CSV file and run the GPD prompt for every single row hundreds of time automatically in the end I can have the training data like this so there's a pair of the user inputs as well as a corresponding mid Journey prompt so now let's fine tune the Falcon model I'm using Google collab as a platform to fine tune the model and I decided to use a 7B version which is much faster but if you want to use the 40p version it's basically the same code you just need to find more powerful computer before you run this making sure you check the runtime type and choose the GPU and at default I think you will be on T4 version which still works but I have upgraded so I can choose 800 model which will be faster so firstly let's install a few libraries once it's finished you will see a little check mark here then the next step is we will import all those libraries okay great and you will run this notebook login which will ask for your hacking face API key if you don't have hacking face account just create account and then copy the link here and paste here we will need to use hugging face as a way to upload and share our model the next thing we will do is we will try to load the Falcon model and tokenize it first and here the model I choose is 7B instruct shared so instruct is a fine-tuned 7B model specifically for conversation so think about as chat GPT versus gpt3 and share it just a version of samd model and shared shared is this version of 7B model that would be faster and easier to run and it will take a while for you and it is downloading the whole bottles it will take a while okay so the model is downloaded and then let's load the model Q Laura is a specific type of method called Low ranks adapters which is one way to fine-tune the large language model much more efficient and fast before we fine-tune 7B let's try this prompt with the base model to see what kind of results we get so I will create a prompt and then start loading a bunch of configuration for the model and click around so this is the results we get it's not even close to generating a good Mediterranean prop as they didn't really understand the context and as I mentioned before even check GPT is not doing a good job for this task so I'm pretty curious to see the results and let's first try to prepare the data sets so what I'll do is I will drag and drop the training data says here and once it's finished I should see this file showing up on the left side you can click on this file button to open this side panel by the way and then the first is we will load this data set that we store locally and we can preview of this data so it has two column user and prompt it has 289 rows so this is actually another point I would mention you actually don't need a huge data set even 100 or 200 rows can already generate a really good results for fine tuning and if we pick up the first row I can see the data that is properly loaded and then what we want to do is to map the whole data sets in this format human and assistant and then tokenize the prompt into our data set so once it's finished you can see the data set is fully prepared with input IDs token type IDs and attention masks and firstly we will need to create the list of training arguments and you can use this one I have here as default and then we'll just run trainer.train to start the training process and this will take a while for the higher end GPU I choose it take me two minutes I think if you're using T4 version it will probably take you around 10 minutes okay great so we just finished fine-tuning the model next we will need to save the model that we've just trained you can either save locally by doing modal.save pre-trained and once it is finished you will see on the left side there's a folder called train model and inside this is model that we just created but you can also upload this model to hugging face so you will come to hugging phase click on this new model under your profile give a name and choose a license then click create model once you finish that you can copy this and then coming back to paste on here this will upload the model to your hanging face repo okay we successfully load the model and let's run this again I will create a list of configuration for the model then I will create this prop mid Journey prompt for a boy running in the snow and let's run this okay great so we got this result as you can see it produced a really great prompt that I just tell you that why running in the snow and it is able to generate prompt if by running the snow with backpack a red scarf by the famous artist The Simpsons style the red is a bit messed up and I think if I provide him more data it probably will produce better results but it's already much better result than the base model and chatty GPT so this is how you can fine tune a large language model I'm really Keen to see the results you are getting here I'm training the 7B model because 40b takes a lot more computer power but luckily tii which is maker of Falcon model they are running a contest where the winner will be awarded with huge amount of training computer power so I think this is a brilliant opportunity if you really want to get into the fine tune space and there are a few use case you can try either customer support legal document medical diagnose or financial advisories I'm very keen to see what kind of models you guys got to train I hope you enjoyed this video if you're interested I will also produce another video talking about how can you create embedded knowledge base so if you like this video please like And subscribe and I see you next time

Original Description

Finetune Falcon 7b/40b instruct with your own data - The step by step guide about how to train falcon model for generating high quality midjourney prompt, from prep training dataset to comparing final results; - Join my community: https://2ly.link/1zq97 - Join Falcon 40B contest: https://falconllm.tii.ae/call-for-proposal.php - Follow me on twitter: https://twitter.com/jasonzhou1993 - Join my AI email list: https://www.ai-jason.com/ - My discord: https://discord.gg/eZXprSaCDE 🔗 Links - Google colab: https://colab.research.google.com/drive/1IqL0ay04RwNNcn5R7HzhgBqZ2lPhHloh?usp=sharing - Midjourney training dataset: https://docs.google.com/spreadsheets/d/1u2bbcSRV99t0Bg9AHFtakpnI3NrC_cVXlR6tZ7yOKlM/edit?usp=sharing - RelevanceAI midjourney training dataset generator: https://app.relevanceai.com/notebook/f1db6c/f86edbc1-fcb6-41f9-b9b6-be14a6f06412/ef6acb93-c3c2-4e83-86aa-5bb93c9f78ef/use/app ⏱️ Timestamps 0:00 Finetune VS Knowledge base 1:50 Step1 Choose base LLM 2:30 Step2 Prep training data 4:54 Step3 Setup google colab 5:41 Step4 Load base Falcon model 6:48 Step5 Load training data 7:36 Step6 Finetune model 7:56 Step7 Save & run finetuned model 9:08 Falcon 40b 👋🏻 About Me My name is Jason Zhou, a product designer who shares interesting AI experiments & products. Email me if you need help building AI apps! ask@ai-jason.com #gpt #autogpt #ai #artificialintelligence #tutorial #stepbystep #openai #llm #falcon7b #finetune #largelanguagemodels #largelanguagemodel #midjourney
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from AI Jason · AI Jason · 11 of 60

1 Build Your Own Auto-GPT Apps without coding Step by Step (Dust.tt Tutorial)
Build Your Own Auto-GPT Apps without coding Step by Step (Dust.tt Tutorial)
AI Jason
2 AutoGPT tutorial: Build your personal assistant WITHOUT code (Via Relevance AI)
AutoGPT tutorial: Build your personal assistant WITHOUT code (Via Relevance AI)
AI Jason
3 Create your own AI girlfriend that talks ❤️
Create your own AI girlfriend that talks ❤️
AI Jason
4 How to build with Langchain 10x easier | ⛓️ LangFlow & Flowise
How to build with Langchain 10x easier | ⛓️ LangFlow & Flowise
AI Jason
5 I build an autonomous researcher via GPT | Langchain ⛓️ Tutorial
I build an autonomous researcher via GPT | Langchain ⛓️ Tutorial
AI Jason
6 Smol AI tutorial in 5 mins | Build ENTIRE codebase with a single prompt
Smol AI tutorial in 5 mins | Build ENTIRE codebase with a single prompt
AI Jason
7 Hugging Face + Langchain in 5 mins | Access 200k+ FREE AI models for your AI apps
Hugging Face + Langchain in 5 mins | Access 200k+ FREE AI models for your AI apps
AI Jason
8 How to let GPT control anything & 10x powerful | 8 mins tutorial about GPT funtion calling
How to let GPT control anything & 10x powerful | 8 mins tutorial about GPT funtion calling
AI Jason
9 Extract data & automate EVERYTHING | 10x GPT function calling power
Extract data & automate EVERYTHING | 10x GPT function calling power
AI Jason
10 Finally, an AI agent that actually works
Finally, an AI agent that actually works
AI Jason
"okay, but I want GPT to perform 10x for my specific use case" - Here is how
"okay, but I want GPT to perform 10x for my specific use case" - Here is how
AI Jason
12 "Wait..this AI Agent does research for you 24hrs without hallucination?!" - Here is how
"Wait..this AI Agent does research for you 24hrs without hallucination?!" - Here is how
AI Jason
13 "How to give GPT my business knowledge?" - Knowledge embedding 101
"How to give GPT my business knowledge?" - Knowledge embedding 101
AI Jason
14 “Automation 2.0 coming…No more boring data entry job”
“Automation 2.0 coming…No more boring data entry job”
AI Jason
15 "How to 10x chatbot UX? 🤖 🖼️ " - Add Image Responses to GPT knowledge retrieval apps
"How to 10x chatbot UX? 🤖 🖼️ " - Add Image Responses to GPT knowledge retrieval apps
AI Jason
16 “LLAMA2 supercharged with vision & hearing?!” | Multimodal 101 tutorial
“LLAMA2 supercharged with vision & hearing?!” | Multimodal 101 tutorial
AI Jason
17 "Next Level Prompts?" - 10 mins into advanced prompting
"Next Level Prompts?" - 10 mins into advanced prompting
AI Jason
18 Build AI agent workforce - Multi agent framework with MetaGPT & chatDev
Build AI agent workforce - Multi agent framework with MetaGPT & chatDev
AI Jason
19 How to scale your AI automation pipeline
How to scale your AI automation pipeline
AI Jason
20 AI agent manages community 24/7 - Build Agent workforce ep#1
AI agent manages community 24/7 - Build Agent workforce ep#1
AI Jason
21 Autogen - Microsoft's best AI Agent framework that is controllable?
Autogen - Microsoft's best AI Agent framework that is controllable?
AI Jason
22 StreamingLLM - Extend Llama2 to 4 million token & 22x faster inference?
StreamingLLM - Extend Llama2 to 4 million token & 22x faster inference?
AI Jason
23 AI agent + Vision = Incredible
AI agent + Vision = Incredible
AI Jason
24 After 7 days letting AI agents control my email inbox... 📮
After 7 days letting AI agents control my email inbox... 📮
AI Jason
25 How to use New OpenAI DevDay features - GPT4V x TTS demo tutorial
How to use New OpenAI DevDay features - GPT4V x TTS demo tutorial
AI Jason
26 What is Q* | Reinforcement learning 101 & Hypothesis
What is Q* | Reinforcement learning 101 & Hypothesis
AI Jason
27 "Research agent 3.0 - Build a group of AI researchers" - Here is how
"Research agent 3.0 - Build a group of AI researchers" - Here is how
AI Jason
28 GPT4V + Puppeteer = AI agent browse web like human? 🤖
GPT4V + Puppeteer = AI agent browse web like human? 🤖
AI Jason
29 Real Gemini demo? Rebuild with GPT4V + Whisper + TTS
Real Gemini demo? Rebuild with GPT4V + Whisper + TTS
AI Jason
30 AI Robot's ChatGPT moment at 2024?
AI Robot's ChatGPT moment at 2024?
AI Jason
31 GPT5 unlocks LLM System 2 Thinking?
GPT5 unlocks LLM System 2 Thinking?
AI Jason
32 The REAL cost of LLM (And How to reduce 78%+ of Cost)
The REAL cost of LLM (And How to reduce 78%+ of Cost)
AI Jason
33 OpenAI's Agent 2.0: Excited or Scared?
OpenAI's Agent 2.0: Excited or Scared?
AI Jason
34 Real time AI Conversation Co-pilot on your phone, Crazy or Creepy?
Real time AI Conversation Co-pilot on your phone, Crazy or Creepy?
AI Jason
35 INSANELY Fast AI Cold Call Agent- built w/ Groq
INSANELY Fast AI Cold Call Agent- built w/ Groq
AI Jason
36 AI Employees Outperform Human Employees?! Build a real Sales Agent
AI Employees Outperform Human Employees?! Build a real Sales Agent
AI Jason
37 Future of E-commerce?! Virtual clothing try-on agent
Future of E-commerce?! Virtual clothing try-on agent
AI Jason
38 Unlock AI Agent real power?! Long term memory & Self improving
Unlock AI Agent real power?! Long term memory & Self improving
AI Jason
39 "I want Llama3 to perform 10x with my private knowledge" - Local Agentic RAG w/ llama3
"I want Llama3 to perform 10x with my private knowledge" - Local Agentic RAG w/ llama3
AI Jason
40 “Wait, this Agent can Scrape ANYTHING?!” - Build universal web scraping agent
“Wait, this Agent can Scrape ANYTHING?!” - Build universal web scraping agent
AI Jason
41 "Make Agent 10x cheaper, faster & better?" -  LLM System Evaluation 101
"Make Agent 10x cheaper, faster & better?" - LLM System Evaluation 101
AI Jason
42 Claude 3.5 struggle too?! The $Million dollar challenge
Claude 3.5 struggle too?! The $Million dollar challenge
AI Jason
43 Make your agents 10x more reliable? Flow engineer 101
Make your agents 10x more reliable? Flow engineer 101
AI Jason
44 "I want Llama3.1 to perform 10x with my private knowledge" - Self learning Local Llama3.1 405B
"I want Llama3.1 to perform 10x with my private knowledge" - Self learning Local Llama3.1 405B
AI Jason
45 AI process thousands of videos?! - SAM2 deep dive 101
AI process thousands of videos?! - SAM2 deep dive 101
AI Jason
46 "Wait, I'm using OpenAI Structured Output wrong ?!" - Advanced Structured Output tutorial
"Wait, I'm using OpenAI Structured Output wrong ?!" - Advanced Structured Output tutorial
AI Jason
47 How to use Cursor AI build & deploy production app in 20 mins
How to use Cursor AI build & deploy production app in 20 mins
AI Jason
48 Best Cursor Workflow that no one talks about...
Best Cursor Workflow that no one talks about...
AI Jason
49 This is how I scrape 99% websites via LLM
This is how I scrape 99% websites via LLM
AI Jason
50 Better than Cursor? Future Agentic Coding available today
Better than Cursor? Future Agentic Coding available today
AI Jason
51 EASIEST Way to Train LLM Train w/ unsloth (2x faster with 70% less GPU memory required)
EASIEST Way to Train LLM Train w/ unsloth (2x faster with 70% less GPU memory required)
AI Jason
52 1000x Cursor workflow for building apps
1000x Cursor workflow for building apps
AI Jason
53 Easiest way to build fancy UI with Cursor/Windsurf/Bolt/Lovable
Easiest way to build fancy UI with Cursor/Windsurf/Bolt/Lovable
AI Jason
54 From $0 to $4m with just 2 people (ComfyUI Crash-course for E-commerce)
From $0 to $4m with just 2 people (ComfyUI Crash-course for E-commerce)
AI Jason
55 Deepseek R1 - The Era of Reasoning models
Deepseek R1 - The Era of Reasoning models
AI Jason
56 Yep, o3-mini is WORTH the money - Build your own reasoning agent
Yep, o3-mini is WORTH the money - Build your own reasoning agent
AI Jason
57 The ONLY way to run your own Deepseek on mobile...
The ONLY way to run your own Deepseek on mobile...
AI Jason
58 Those MCP totally 10x my Cursor workflow…
Those MCP totally 10x my Cursor workflow…
AI Jason
59 MCP = Next Big Opportunity? EASIST way to build your own MCP business
MCP = Next Big Opportunity? EASIST way to build your own MCP business
AI Jason
60 Gemini 2.0 blew me away - The future of Multimodal Model
Gemini 2.0 blew me away - The future of Multimodal Model
AI Jason

Related AI Lessons

Sub-10ms AI Workflows: Accelerating sim.ai with On-Device Semantic Search using Moss
Learn how to accelerate AI workflows with on-device semantic search using Moss, achieving sub-10ms response times and improving user experience
Medium · Machine Learning
Anthropic Built a $100M Club for Its Smartest AI. You’re Probably Not In It.
Learn about Anthropic's Project Glasswing, a $100M club for its smartest AI, and understand the strategy behind it
Medium · LLM
Stop Guessing: Guaranteed Structured Output from LLMs in Node.js
Learn to guarantee structured output from LLMs in Node.js and stop parsing JSON manually
Dev.to · Hardik Mehta
Spring AI Tutorial — Your First REST Endpoint with OpenAI (2026)
Build a REST endpoint with Spring Boot 3 and OpenAI to create an LLM-powered API, leveraging the power of AI in your applications
Dev.to AI

Chapters (9)

Finetune VS Knowledge base
1:50 Step1 Choose base LLM
2:30 Step2 Prep training data
4:54 Step3 Setup google colab
5:41 Step4 Load base Falcon model
6:48 Step5 Load training data
7:36 Step6 Finetune model
7:56 Step7 Save & run finetuned model
9:08 Falcon 40b
Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →