Understanding: AI Model Quantization, GGML vs GPTQ!

1littlecoder · Beginner ·🧠 Large Language Models ·2y ago

Key Takeaways

This video teaches AI model quantization using GGML and GPTQ techniques

Full Transcript

there is so much about quantization do you understand it what is ggml gptq this video is going to explain let's learn about weights and neural networks weights are the parameters and neural network that determine how the network learns and makes prediction they are actually real numbers that are associated with each connection between neurons in the network the weights are what a love the neural network to learn the relationships between input data and the desired output data so in in a neural network if you take a neural network each neuron receives input from another neuron and the input from each neuron is multiplied by the weight and the sum of all the weighted inputs is then passed through an activation function and the activation function ultimately decides or determines whether the neuron will fire or not initially the weights are randomly initialized but as the training process goes on the weights are optimized and adjusted based on the optimization that you have selected and this is kind of the foundation of a technique called back propagation back propagation lets you optimize and change the weights in such a way that you can minimize the error now how are weights related to quantization now when these weights are stored in the neural network that's what the model is you call it a model weight so now when these weights are stored in the neural network it can be with different precisions so you could store these weights as a 32-bit floating point or you could store this weight as a 16-bit floating point or even could be an 8-bit floating point or 8-bit integer or a four bit integer so when we talk about weights as numbers we generally call it a number but this number under the hood in computers could be of different precision and could be of different data type and based on the data type or based on the Precision a lot of things change including the amount of time this neural network takes for inference and also the size of the neural network ultimately the model in itself so just to back it up if we say something is a model the model is nothing but a neural network with its weights so the model is going to be huge when the weights are stored in a higher Precision or you know the most Precision like you know the most accurate number representation of that floating point value but the model's weight will come down as you reduce the Precision that is where you have got a very interesting technique that comes in that is called quantization quantization in neural networks is the process of reducing the Precision of the weights biases and activations of a neural network in order to reduce the size and computational requirements of the model this can be done without significantly impacting the accuracy of the model in many cases I mean when I say quantization that's the first thing that might come to your mind Hey like you are going to reduce the Precision of the weights what kind of impact it is going to have with the model accuracy that's a very good question and also quantization happens at two different places one it could be a post training quantization or the other one could be a quantization of wet training what we do mostly these days like the bloke with ggml and the gptq models or post training quantization what is a post training quantization post training quantization is the process of quantizing a pre-trained neural network and this can be simply done by rounding of weights or activations to a lower Precision but this can also lead to some kind of accuracy so in the post training quantization you might take a model that has got let's say floating Point 16 accurate precision and you can convert into a 4-bit or an 8-bit integer by doing this you are quantizing the model you are quantizing the model in such a way that the weight of the model reduces the size of the model reduces and it also improves the performance of the model in terms of you know the hardware that is required to run it but this can also lead to loss in accuracy so now the quantization part is clear again just to back it up a neural network is a bunch of numbers stored here and there and it matrix multiplication numbers are stored the form of Weights biases and activations and when these numbers are stored with higher Precision floating Point like 32-bit floating Point these models take a lot of size and these models also require more computation when the models have to predict that's what we call inference so by reducing the size of the model or by reducing the Precision of the model We Are One reducing the size of the model improving the model more performant in lower computation and the model is also going to require less compute under lesser power to do the matrix multiplication and all the this can also lead to accuracy loss now with all these things in mind the two popular model types that we see post trained quantized models are ggml and gptq models now what are these models so ggml and gptq models are quantized models in a way to reduce the models and also reduce the computation requirements of the model by reducing the model weights to a lower Precision now what are the key differences between GG ML and gptq ggml models are optimized for CPU while gptq models are optimized for GPU that means ggml model runs faster the inference speed is faster on CPUs and gptq or faster on GPU the inference quality is said to be similar but I read a blog post or I read a hugging face Community article where the blog said the during their experiment with ggml and gptq gptq scored a little bit lower than gcml but I don't have any benchmarks to prove that but anyways just keep in mind that ggml and gptq are ideally supposed to have a similar inference quality the model size the ggml is supposed to be slightly larger than gptq models and both of these models are compatible with hugging phase Transformers which means you know you have got like easy way to run these models in general the thumb rule is if you have got a CPU without any Nvidia GPU use the ggml model or if you have got an Nvidia GPU even if it is not like most powerful mission in the world you can use gptq model and I guess this helps you in understanding all these things that people are discussing these days about gptq ggml quantization reducing the model size if you have got any questions let me know in the comment section otherwise see you in another video Happy prompting

Original Description

Learning Resources: TheBloke Quantized Models - https://huggingface.co/TheBloke Quantization from Hugging Face (Optimum) - https://huggingface.co/docs/optimum/concept_guides/quantization Programming a Neural Network - https://www.mql5.com/en/articles/5486 Deep Neural Network Simplified - https://towardsai.net/p/deep-learning/deep-learning-simplified-feel-and-talk-like-an-expert-in-neural-networks INT8 Quantization Basics - https://randxie.github.io/writing/2020/10/15/int8-quantization/ ❤️ If you want to support the channel ❤️ Support here: Patreon - https://www.patreon.com/1littlecoder/ Ko-Fi - https://ko-fi.com/1littlecoder
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from 1littlecoder · 1littlecoder · 0 of 60

← Previous Next →
1 How to create your Free Data Science Blog on Github with Fastpages from Fastai
How to create your Free Data Science Blog on Github with Fastpages from Fastai
1littlecoder
2 Making Interactive Matplotlib Plots for Data Science Visualizations on Jupyter (Python)
Making Interactive Matplotlib Plots for Data Science Visualizations on Jupyter (Python)
1littlecoder
3 Create your first Data Science Web App using R Shiny
Create your first Data Science Web App using R Shiny
1littlecoder
4 How to create a Reproducible Example in R using reprex
How to create a Reproducible Example in R using reprex
1littlecoder
5 No Code Visualization using esquisse with Tableau-like Drag and Drop GUI in R
No Code Visualization using esquisse with Tableau-like Drag and Drop GUI in R
1littlecoder
6 Scrape HTML Table using rvest and Process them for insights using tidyverse in R
Scrape HTML Table using rvest and Process them for insights using tidyverse in R
1littlecoder
7 Google Teachable Machine Learning Build No Code AI solution
Google Teachable Machine Learning Build No Code AI solution
1littlecoder
8 Create meaningful fake tidy datasets in R using fakir [#rstats Package]
Create meaningful fake tidy datasets in R using fakir [#rstats Package]
1littlecoder
9 How to enable using R Programming with Visual Studio VS Code
How to enable using R Programming with Visual Studio VS Code
1littlecoder
10 Python, Community, Books - with Abhiram R - Bangpypers Co-organizers | 1littlecoder podcast
Python, Community, Books - with Abhiram R - Bangpypers Co-organizers | 1littlecoder podcast
1littlecoder
11 Growing a Tech Community across India - Anubha Maneshwar, Founder Girlscript | 1littlecoder Podcast
Growing a Tech Community across India - Anubha Maneshwar, Founder Girlscript | 1littlecoder Podcast
1littlecoder
12 Intro to Google Colab - How to use Colab
Intro to Google Colab - How to use Colab
1littlecoder
13 Intro to Plotly Express - Complex Interactive Charts with One-Line of Python Code
Intro to Plotly Express - Complex Interactive Charts with One-Line of Python Code
1littlecoder
14 Indic NLP Python Toolkit Open Source Development - iNLTK Creator Gaurav Arora | 1littlecoder Podcast
Indic NLP Python Toolkit Open Source Development - iNLTK Creator Gaurav Arora | 1littlecoder Podcast
1littlecoder
15 Do you want a career in Data Science - Tamil Webinar
Do you want a career in Data Science - Tamil Webinar
1littlecoder
16 Android Smartphone Analysis in R [Live Coding Screencast]
Android Smartphone Analysis in R [Live Coding Screencast]
1littlecoder
17 Programmatically create Images, Memes, Watermarks using Python with imgmaker
Programmatically create Images, Memes, Watermarks using Python with imgmaker
1littlecoder
18 Kaggle Walkthrough to get you started with Data Science - Webinar
Kaggle Walkthrough to get you started with Data Science - Webinar
1littlecoder
19 Community, Corporate Job, Coding - Gnana Lakshmi T C aka Gyan, WomenWhoCode Leadership Fellow
Community, Corporate Job, Coding - Gnana Lakshmi T C aka Gyan, WomenWhoCode Leadership Fellow
1littlecoder
20 Easy ggplot2 Theme Customization with {ggeasy} | Data Visualization in R
Easy ggplot2 Theme Customization with {ggeasy} | Data Visualization in R
1littlecoder
21 Excel to R - Pivot + Bar Chart in Excel  & R using tidyverse [Live Coding]
Excel to R - Pivot + Bar Chart in Excel & R using tidyverse [Live Coding]
1littlecoder
22 Excel to R #2 - VLOOKUP in Excel to LEFT_JOIN, MERGE in R
Excel to R #2 - VLOOKUP in Excel to LEFT_JOIN, MERGE in R
1littlecoder
23 5 websites to get Free Real-World Datasets for Data Science/ML Projects
5 websites to get Free Real-World Datasets for Data Science/ML Projects
1littlecoder
24 Excel to R #3 - APPROXIMATE VLOOKUP in Excel to FUZZY LEFT_JOIN in R
Excel to R #3 - APPROXIMATE VLOOKUP in Excel to FUZZY LEFT_JOIN in R
1littlecoder
25 Correlation-alternative PPS (Predictive Power Score) Python Package Demo
Correlation-alternative PPS (Predictive Power Score) Python Package Demo
1littlecoder
26 Automated Website Screenshots in R using {webshot}
Automated Website Screenshots in R using {webshot}
1littlecoder
27 Installing Custom RStudio Theme (Synthwave85)
Installing Custom RStudio Theme (Synthwave85)
1littlecoder
28 Analyse Google Trends Search Data in R using {gtrendsR}
Analyse Google Trends Search Data in R using {gtrendsR}
1littlecoder
29 3 Tips to ask question on Stack Overflow the right way to get answers
3 Tips to ask question on Stack Overflow the right way to get answers
1littlecoder
30 Learn Data Science with R - Mini Projects - Web Scraping Zomato
Learn Data Science with R - Mini Projects - Web Scraping Zomato
1littlecoder
31 Easily make Dumbbell Chart using {ggcharts} | Data Visualization in R
Easily make Dumbbell Chart using {ggcharts} | Data Visualization in R
1littlecoder
32 GET Hackernews Front Page Results using REST API in R
GET Hackernews Front Page Results using REST API in R
1littlecoder
33 Quickly deploy ML WebApps from Google Colab using ngrok
Quickly deploy ML WebApps from Google Colab using ngrok
1littlecoder
34 Use Jupyter Notebooks within VSCode (Visual Studio Code) in 2020
Use Jupyter Notebooks within VSCode (Visual Studio Code) in 2020
1littlecoder
35 Plotly Interactive Plots as Pandas Plotting Backend df.plot()
Plotly Interactive Plots as Pandas Plotting Backend df.plot()
1littlecoder
36 Stack Overflow Developer Survey 2020 Highlights for New Programmers
Stack Overflow Developer Survey 2020 Highlights for New Programmers
1littlecoder
37 Matplotlib Animation Charts in Python using Celluloid
Matplotlib Animation Charts in Python using Celluloid
1littlecoder
38 Coding, Postwoman, Passion Project Book - Liyas Thomas Open Source Developer - 1littlecoder podcast
Coding, Postwoman, Passion Project Book - Liyas Thomas Open Source Developer - 1littlecoder podcast
1littlecoder
39 Aspiring Data Scientist, Tips on How to learn Business Domain Knowledge
Aspiring Data Scientist, Tips on How to learn Business Domain Knowledge
1littlecoder
40 Bokeh Interactive Charts as Pandas Plotting Backend df.plot_bokeh()
Bokeh Interactive Charts as Pandas Plotting Backend df.plot_bokeh()
1littlecoder
41 Easy Fast Python Pandas Summary with Sidetable | Pandas Tips & Tricks
Easy Fast Python Pandas Summary with Sidetable | Pandas Tips & Tricks
1littlecoder
42 Inception, Content Ideas, Consistency - Srivatsan Srinivasan AIEngineering YouTube Content Creator
Inception, Content Ideas, Consistency - Srivatsan Srinivasan AIEngineering YouTube Content Creator
1littlecoder
43 ggplot2 Text Customization with ggtext | Data Visualization in R
ggplot2 Text Customization with ggtext | Data Visualization in R
1littlecoder
44 Penguins Dataset Overview - iris alternative | EDA Data Visualization in R
Penguins Dataset Overview - iris alternative | EDA Data Visualization in R
1littlecoder
45 YouTube Growth Tips, Content Creation - Bhavesh Bhatt, YouTuber (Data Science & Machine Learning) #7
YouTube Growth Tips, Content Creation - Bhavesh Bhatt, YouTuber (Data Science & Machine Learning) #7
1littlecoder
46 Matplotlib Animated Bar Chart Race in Python | Data Visualization
Matplotlib Animated Bar Chart Race in Python | Data Visualization
1littlecoder
47 Simple Python GUI Development using {guietta}
Simple Python GUI Development using {guietta}
1littlecoder
48 #8 Niche, Growth, Monetization - David Langer - YouTuber Dave on Data
#8 Niche, Growth, Monetization - David Langer - YouTuber Dave on Data
1littlecoder
49 Simple Fast 3-step Python OCR using Deep Learning 40+ Languages
Simple Fast 3-step Python OCR using Deep Learning 40+ Languages
1littlecoder
50 Github New Feature Profile Summary/Mini-Resume - Profile Views
Github New Feature Profile Summary/Mini-Resume - Profile Views
1littlecoder
51 Otto ML Assistant, GPT-3 on Philosophers, Nvidia-ARM - 3 ML Tech News
Otto ML Assistant, GPT-3 on Philosophers, Nvidia-ARM - 3 ML Tech News
1littlecoder
52 What is OpenAI GPT-3 - Hype, Examples, Worries
What is OpenAI GPT-3 - Hype, Examples, Worries
1littlecoder
53 Julia 1.5, Datamuse API, Live HDR+ Pixel 4a - Machine Learning Tech News
Julia 1.5, Datamuse API, Live HDR+ Pixel 4a - Machine Learning Tech News
1littlecoder
54 Self-driving Car Engineer sentenced, arXiv Dataset, AI/ML Startup Idea - Machine Learning Tech News
Self-driving Car Engineer sentenced, arXiv Dataset, AI/ML Startup Idea - Machine Learning Tech News
1littlecoder
55 GPT-3 Explorer, Ciphey (Automated Decryption), Py-Sudoku - ML Tech News
GPT-3 Explorer, Ciphey (Automated Decryption), Py-Sudoku - ML Tech News
1littlecoder
56 How to use Advanced Google Search to extract Email Ids from Linkedin
How to use Advanced Google Search to extract Email Ids from Linkedin
1littlecoder
57 Cartoonizer Toon-IT (AI Web App), GPT-3 Advice, Android Earthquake Detection - ML Tech News
Cartoonizer Toon-IT (AI Web App), GPT-3 Advice, Android Earthquake Detection - ML Tech News
1littlecoder
58 Flow - R Package to visualize code logic, functions as a Flow Diagram
Flow - R Package to visualize code logic, functions as a Flow Diagram
1littlecoder
59 Build GPT-3-like Language Model on Google Colab with minGPT [PyTorch]
Build GPT-3-like Language Model on Google Colab with minGPT [PyTorch]
1littlecoder
60 Create a Pencil Sketch Portrait with Python OpenCV
Create a Pencil Sketch Portrait with Python OpenCV
1littlecoder

Related Reads

📰
Building a Custom GPT / Chatbot for Your Own Use Case
Learn to build a custom GPT/chatbot for your specific use case using Python
Medium · Python
📰
Building a Custom GPT / Chatbot for Your Own Use Case
Learn to build a custom GPT/chatbot for your specific use case and understand the process of creating a tailored conversational AI model
Medium · RAG
📰
Open-Weight LLM API Integration: A Developer Guide to Building with Transparent AI
Learn to integrate open-weight LLM APIs for transparent AI, enabling fine-grained control and inspecting the architecture behind the intelligence
Dev.to AI
📰
Stop Writing Boilerplate: How I Automated My Entire Workflow with LLM APIs
Automate your LLM workflow using APIs to reduce repetitive code, increasing productivity and efficiency
Dev.to AI
Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →