GenAI with Open-Source LLMs
From Training to Deployment
April 24th, 2024
Jon Krohn, Ph.D.
Co-Founder & Chief Data Scientist
Click to edit Master title style
Let’s stay connected:
jonkrohn.com to sign up for email newsletter
linkedin.com/in/jonkrohn
jonkrohn.com/youtube
twitter.com/JonKrohnLearns
Slides: jonkrohn.com/talks
Code: github.com/jonkrohn/NLP-with-LLMs
GenAI with Open-Source LLMs
From Training to Deployment
GPT4All-inference.ipynb hands-on demo!
The Pomodoro Technique
Rounds of:
Questions best handled at breaks, so save questions until then.
When people ask questions that have already been answered, do me a favor and let them know, politely providing response if appropriate.
Except during breaks, I recommend attending to this lecture only as topics are not discrete: Later material builds on earlier material.
POLL
Where are you?
POLL
What are you?
POLL
What’s your level of experience with the topic?
35% off orders:
bit.ly/iTkrohn
(use code KROHN during checkout)
Will sign your book at
ODSC Events
Click to edit Master title style
ODSC AI+ Deep Learning Series
20 hours of content…
…introducing deep learning and PyTorch.
aiplus.training
ODSC AI+ ML Foundations Series
Subjects…
…are foundational for deeply understanding ML models.
github.com/jonkrohn/ML-foundations
jonkrohn.com/youtube
NLP with GPT-4 and other LLMs
From Training to Deployment
Massive thanks to:
NLP with GPT-4 and other LLMs
Click to edit Master title style
NLP with GPT-4 and other LLMs
Click to edit Master title style
Brief History of NLP
Human tech-era analogy inspired by Rongyao Huang:
Click to edit Master title style
Transformer (Vaswani et al., 2017)
Click to edit Master title style
Transformer in a Nutshell
Vaswani et al. (2017; Google Brain) was NMT
Hello world!
Bonjour le monde!
Great resources:
Click to edit Master title style
Subword Tokenization
Token: in NLP, basic unit of text
hands-on demo: GPT.ipynb
Click to edit Master title style
Language Models
Autoregressive Models
Predict future token, e.g.:
The joke was funny. She couldn’t stop ___.
NL generation (NLG)
E.g.: GPT architectures
Autoencoding Models
Predict token based on past and future context, e.g.,:
He ate the entire ___ of pizza.
NL understanding (NLU)
E.g.: BERT architectures
Click to edit Master title style
Large Language Models
Click to edit Master title style
ELMo (Peters et al., 2018)
Click to edit Master title style
BERT (Devlin et al., 2018)
Click to edit Master title style
T5 (Raffel et al., 2019)
Hands-on
code demo:
T5.ipynb
Click to edit Master title style
OpenAI’s GPT
Etymology:
Click to edit Master title style
The OpenAI GPT Family
*includes RLHF: Reinforcement Learning from Human Feedback
Version | Release Year | Parameters | n Tokens |
GPT | 2018 | 117 m | 1024 |
GPT-2 | 2019 | 1.5 b | 2048 |
GPT-3 | 2020 | 175 b | 4096 |
GPT-3.5* | 2022 | 175 b | 4096 |
GPT-4* | 2023 | ? | 8k or 32k |
More on these in the next section…
Click to edit Master title style
Three Major Ways to Use LLMs
Click to edit Master title style
Section Summary
Click to edit Master title style
NLP with GPT-4 and other LLMs
Click to edit Master title style
LLM Capabilities
Without fine-tuning, pre-trained transformer-based LLMs can, e.g.:
…
Click to edit Master title style
…more, provided by GPT-4:
Click to edit Master title style
LLM Playgrounds
Hands-on
GPT-4 demo
Click to edit Master title style
Staggering GPT-Family Progress
Click to edit Master title style
Key Updates with GPT-4
Hands-on
code demo:
GPT4-API.ipynb
Click to edit Master title style
Section Summary
Click to edit Master title style
NLP with GPT-4 and other LLMs
Click to edit Master title style
Training and Deploying LLMs
In this section:
Click to edit Master title style
Hardware
Click to edit Master title style
🤗 Transformers
Hands-on code demo:
GPyT-code-completion.ipynb
Click to edit Master title style
Efficient Training
Hands-on code demo:
IMDB-GPU-demo.ipynb
Click to edit Master title style
Gradient Accumulation
Source: MosaicML
Click to edit Master title style
Gradient Checkpointing
Model Size (N)
O(√N)
Click to edit Master title style
Automatic Mixed-Precision
Click to edit Master title style
Dynamic Padding & Uniform-Length Batching
Source: Sajjad Ayoubi
Click to edit Master title style
Single-GPU Open-Source “ChatGPT” LLMs
Hands-on skim: Sinan’s “Dolly Lite” NB
Click to edit Master title style
PyTorch Lightning
Hands-on code demo:
Finetune-T5-on-GPU.ipynb
Click to edit Master title style
Multi-GPU Training
Click to edit Master title style
LLM Deployment Options
Lightning makes deployment easy. Options include:
LLMs are, however, shrinking through:
Click to edit Master title style
Monitoring ML Models in Production
Click to edit Master title style
Major LLM Challenges
Click to edit Master title style
Section Summary
Click to edit Master title style
NLP with GPT-4 and other LLMs
Click to edit Master title style
Supporting ML with LLMs
Support development of another LLM or any other ML model:
Click to edit Master title style
Repetitive Tasks are Replaceable
Click to edit Master title style
Creative Tasks are Augmentable
Click to edit Master title style
You Are Now a Data Product Manager
Be creative about:
Click to edit Master title style
Click to edit Master title style
Click to edit Master title style
What’s next for A.I./LLMs?
Click to edit Master title style
Ultra-Intelligent Abundance
Click to edit Master title style
NLP with GPT-4 and other LLMs
Click to edit Master title style
ODSC AI+ Deep Learning Series
20 hours of content…
…introducing deep learning and PyTorch.
aiplus.training
ODSC AI+ ML Foundations Series
Subjects…
…are foundational for deeply understanding ML models.
github.com/jonkrohn/ML-foundations
jonkrohn.com/youtube
Resources for Facilitating Utopia
Stay in Touch
jonkrohn.com to sign up for email newsletter
linkedin.com/in/jonkrohn
youtube.com/c/JonKrohnLearns
twitter.com/JonKrohnLearns