Difference between revisions of "Generative Pre-trained Transformer (GPT)"
m (→Generative Pre-trained Transformer 4 (GPT-4)) |
m |
||
| Line 36: | Line 36: | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| Line 313: | Line 209: | ||
|} | |} | ||
|}<!-- B --> | |}<!-- B --> | ||
| + | |||
| + | = Let's build GPT: from scratch, in code, spelled out | Andrej Karpathy = | ||
| + | |||
| + | |||
| + | {|<!-- T --> | ||
| + | | valign="top" | | ||
| + | {| class="wikitable" style="width: 550px;" | ||
| + | || | ||
| + | <youtube>kCc8FmEb1nY</youtube> | ||
| + | <b>Let's build GPT: from scratch, in code, spelled out. | ||
| + | </b><br>[[Creatives#Andrej Karpathy |Andrej Karpathy]] ...We build a Generatively Pretrained Transformer (GPT), following the paper "Attention is All You Need" and OpenAI's GPT-2 / GPT-3. We talk about connections to ChatGPT, which has taken the world by storm. We watch GitHub Copilot, itself a GPT, help us write a GPT (meta :D!) . I recommend people watch the earlier makemore videos to get comfortable with the autoregressive language modeling framework and basics of tensors and PyTorch nn, which we take for granted in this video. | ||
| + | |||
| + | Links: | ||
| + | * [https://colab.research.google.com/drive/1JMLa53HDuA-i7ZBmqV7ZnA3c_fvtXnx-?usp=sharing Google colab for the video] | ||
| + | * [https://github.com/karpathy/ng-video-lecture GitHub repo for the video] | ||
| + | * [https://www.youtube.com/watch?v=VMj-3S1tku0&list=PLAqhIrjkxbuWI23v9cThsA9GvCAUhRvKZ&index=2 Playlist of the whole Zero to Hero series so far] | ||
| + | * [https://github.com/karpathy/nanoGPT nanoGPT repo] | ||
| + | * [https://karpathy.ai my website] | ||
| + | * [https://twitter.com/karpathy my twitter] | ||
| + | * [https://discord.gg/3zy8kqD9Cp our Discord channel] | ||
| + | |||
| + | Supplementary links: | ||
| + | * [https://arxiv.org/abs/1706.03762 Attention is All You Need paper] | ||
| + | * [https://arxiv.org/abs/2005.14165 OpenAI GPT-3 paper] | ||
| + | * [https://openai.com/blog/chatgpt/ OpenAI ChatGPT blog post] | ||
| + | * The GPU I'm training the model on is from Lambda GPU Cloud, I think the best and easiest way to spin up an on-demand GPU instance in the cloud that you can ssh to: https://lambdalabs.com . If you prefer to work in notebooks, I think the easiest path today is Google Colab. | ||
| + | |||
| + | Suggested exercises: | ||
| + | * EX1: The n-dimensional tensor mastery challenge: Combine the `Head` and `MultiHeadAttention` into one class that processes all the heads in parallel, treating the heads as another batch dimension (answer is in nanoGPT). | ||
| + | * EX2: Train the GPT on your own dataset of choice! What other data could be fun to blabber on about? (A fun advanced suggestion if you like: train a GPT to do addition of two numbers, i.e. a+b=c. You may find it helpful to predict the digits of c in reverse order, as the typical addition algorithm (that you're hoping it learns) would proceed right to left too. You may want to modify the data loader to simply serve random problems and skip the generation of train.bin, val.bin. You may want to mask out the loss at the input positions of a+b that just specify the problem using y=-1 in the targets (see CrossEntropyLoss ignore_index). Does your Transformer learn to add? Once you have this, swole doge project: build a calculator clone in GPT, for all of +-*/. Not an easy problem. You may need Chain of Thought traces.) | ||
| + | * EX3: Find a dataset that is very large, so large that you can't see a gap between train and val loss. Pretrain the transformer on this data, then initialize with that model and finetune it on tiny shakespeare with a smaller number of steps and lower learning rate. Can you obtain a lower validation loss by the use of pretraining? | ||
| + | * EX4: Read some transformer papers and implement one additional feature or change that people seem to use. Does it improve the performance of your GPT? | ||
| + | |||
| + | Chapters: | ||
| + | * 00:00:00 intro: ChatGPT, Transformers, nanoGPT, Shakespeare baseline language modeling, code setup | ||
| + | * 00:07:52 reading and exploring the data | ||
| + | * 00:09:28 tokenization, train/val split | ||
| + | * 00:14:27 data loader: batches of chunks of data | ||
| + | * 00:22:11 simplest baseline: bigram language model, loss, generation | ||
| + | * 00:34:53 training the bigram model | ||
| + | * 00:38:00 port our code to a script Building the "self-attention" | ||
| + | * 00:42:13 version 1: averaging past context with for loops, the weakest form of aggregation | ||
| + | * 00:47:11 the trick in self-attention: matrix multiply as weighted aggregation | ||
| + | * 00:51:54 version 2: using matrix multiply | ||
| + | * 00:54:42 version 3: adding softmax | ||
| + | * 00:58:26 minor code cleanup | ||
| + | * 01:00:18 positional encoding | ||
| + | * 01:02:00 THE CRUX OF THE VIDEO: version 4: self-attention | ||
| + | * 01:11:38 note 1: attention as [[Agents#Communication | communication]] | ||
| + | * 01:12:46 note 2: attention has no notion of space, operates over sets | ||
| + | * 01:13:40 note 3: there is no [[Agents#Communication | communication]] across batch dimension | ||
| + | * 01:14:14 note 4: encoder blocks vs. decoder blocks | ||
| + | * 01:15:39 note 5: attention vs. self-attention vs. cross-attention | ||
| + | * 01:16:56 note 6: "scaled" self-attention. why divide by sqrt(head_size) Building the Transformer | ||
| + | * 01:19:11 inserting a single self-attention block to our network | ||
| + | * 01:21:59 multi-headed self-attention | ||
| + | * 01:24:25 feedforward layers of transformer block | ||
| + | * 01:26:48 residual connections | ||
| + | * 01:32:51 layernorm (and its relationship to our previous batchnorm) | ||
| + | * 01:37:49 scaling up the model! creating a few variables. adding dropout Notes on Transformer | ||
| + | * 01:42:39 encoder vs. decoder vs. both (?) Transformers | ||
| + | * 01:46:22 super quick walkthrough of nanoGPT, batched multi-headed self-attention | ||
| + | * 01:48:53 back to ChatGPT, GPT-3, pretraining vs. finetuning, RLHF | ||
| + | * 01:54:32 conclusions | ||
| + | |||
| + | Corrections: | ||
| + | * 00:57:00 Oops "tokens from the future cannot communicate", not "past". Sorry! :) | ||
| + | * 01:20:05 Oops I should be using the head_size for the normalization, not C | ||
| + | |} | ||
| + | |<!-- M --> | ||
| + | | valign="top" | | ||
| + | {| class="wikitable" style="width: 550px;" | ||
| + | || | ||
| + | <youtube>9uw3F6rndnA</youtube> | ||
| + | <b>Transformers: The best idea in AI | Andrej Karpathy and Lex Fridman | ||
| + | </b><br>[https://www.youtube.com/watch?v=cdiD-9MMpb0 Lex Fridman Podcast full episode] | ||
| + | Please support this podcast by checking out our sponsors: | ||
| + | * [https://www.eightsleep.com/lex Eight Sleep: to get special savings] | ||
| + | * [https://betterhelp.com/lex BetterHelp: to get 10% off] | ||
| + | * [https://fundrise.com/lex Fundrise] | ||
| + | * [https://athleticgreens.com/lex Athletic Greens: to get 1 month of fish oil] | ||
| + | |||
| + | GUEST BIO: | ||
| + | [[Creatives#Andrej Karpathy |Andrej Karpathy]] is a legendary AI researcher, engineer, and educator. He's the former director of AI at Tesla, a founding member of [[OpenAI]], and an educator at Stanford. | ||
| + | |||
| + | PODCAST INFO: | ||
| + | * [https://lexfridman.com/podcast Podcast website] | ||
| + | * [https://apple.co/2lwqZIr Apple Podcasts] | ||
| + | * [https://spoti.fi/2nEwCF8 Spotify] | ||
| + | * [https://lexfridman.com/feed/podcast/ RSS] | ||
| + | * [https://www.youtube.com/playlist?list=PLrAXtmErZgOdP_8GztsuKi9nrraNbKKp4 Full episodes playlist] | ||
| + | Clips playlist: https://www.youtube.com/playlist?list... | ||
| + | |||
| + | SOCIAL: | ||
| + | * [https://twitter.com/lexfridman Twitter] | ||
| + | * [https://www.linkedin.com/in/lexfridman LinkedIn] | ||
| + | * [https://www.facebook.com/lexfridman [[Meta|Facebook]]] | ||
| + | * [https://www.instagram.com/lexfridman Instagram] | ||
| + | * [https://medium.com/@lexfridman Medium] | ||
| + | * [https://reddit.com/r/lexfridman Reddit] | ||
| + | * [https://www.patreon.com/lexfridman Support on Patreon] | ||
| + | |||
| + | |} | ||
| + | |}<!-- B --> | ||
| + | |||
| + | |||
= <span id="GPT Impact to Development"></span>GPT Impact to Development = | = <span id="GPT Impact to Development"></span>GPT Impact to Development = | ||
Revision as of 15:04, 15 March 2023
YouTube search... ...Google search
- Case Studies
- Natural Language Processing (NLP) ...Generation ...LLM ...Tools & Services
- Assistants ... Hybrid Assistants ... Agents ... Negotiation
- Attention Mechanism ...Transformer Model ...Generative Pre-trained Transformer (GPT)
- Generative AI ... OpenAI's ChatGPT ... Perplexity ... Microsoft's BingAI ... You ...Google's Bard
- Sequence to Sequence (Seq2Seq)
- Recurrent Neural Network (RNN)
- Long Short-Term Memory (LSTM)
- ELMo
- Bidirectional Encoder Representations from Transformers (BERT) ... a better model, but less investment than the larger OpenAI organization
- OpenAI Blog | OpenAI
- Text Transfer Learning
- Generated Image
- SynthPub
- Language Models are Unsupervised Multitask Learners | Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever
- Neural Monkey | Jindřich Libovický, Jindřich Helcl, Tomáš Musil Byte Pair Encoding (BPE) enables NMT model translation on open-vocabulary by encoding rare and unknown words as sequences of subword units.
- Language Models are Unsupervised Multitask Learners - GitHub
- Microsoft Releases DialogGPT AI Conversation Model | Anthony Alford - InfoQ - trained on over 147M dialogs
- minGPT | Andrej Karpathy - GitHub
- SambaNova Systems ... Dataflow-as-a-Service GPT
- Facebook-owner Meta opens access to AI large language model | Elizabeth Culliford - Reuters ... Facebook 175-billion-parameter language model - Open Pretrained Transformer (OPT-175B)
Contents
Generative Pre-trained Transformer 4 (GPT-4)
- GPT-4 | OpenAI
- Research Paper | OpenAI
- GPT-4: Facts, Rumors and Expectations about next-gen AI model | Nick Babich - Medium
- How does GPT-4 work and how can you start using it in ChatGPT? | Mohammed Haddad - Aljazeera] ... Launched on March 14, GPT-4 is the successor to GPT-3 and is the technology behind the viral chatbot ChatGPT.
- OpenAI unveils GPT-4 with new capabilities, Microsoft's Bing is already using it
One of ChatGPT-4’s most dazzling new features is the ability to handle not only words, but pictures too, in what is being called “multimodal” technology. A user will have the ability to submit a picture alongside text — both of which ChatGPT-4 will be able to process and discuss. The ability to input video is also on the horizon. - Everything You Need to Know About ChatGPT-4 | Alex Millson - Bloomberg, Time
Generative Pre-trained Transformer 3 (GPT-3 & GPT 3.5)
- Language Models are Few-Shot Learners | T. Brown, B. Mann, N. Ryder, M. Subbiah, J. Kaplan, P. Dhariwal, A. Neelakantan, P. Shyam, G. Sastry, A. Askell, S. Agarwal, A. Herbert-Voss, G. Krueger, T. Henighan, R. Child, A. Ramesh, D. Ziegler, J. Wu, C. Winter, C. Hesse, M. Chen, E. Sigler, M. Litwin, S. Gray, B. Chess, J. Clark, C. Berner, S. McCandlish, A. Radford, I. Sutskever, and D. Amodei - arXiv.org
- GPT-3: Demos, Use-cases, Implications | Simon O'Regan - Towards Data Science
- OpenAI API ...today the API runs models with weights from the GPT-3 family with many speed and throughput improvements.
- GPT-3 by OpenAI – Outlook and Examples | Praveen Govindaraj | Medium
- GPT-3 Creative Fiction | R. Gwern
]
Try...
- Sushant Kumar's micro-site - Replace your 'word' in the following URL to see what GPT-3 generates: https://thoughts.sushant-kumar.com/word
- Serendipity ...an AI powered recommendation engine for anything you want.
- Taglines.ai ... just about every business has a tagline — a short, catchy phrase designed to quickly communicate what it is that they do.
- Simplify.so ...simple, easy-to-understand explanations for everything
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Let's build GPT: from scratch, in code, spelled out | Andrej Karpathy
|
|
GPT Impact to Development
- Development
- https://analyticsindiamag.com/will-the-much-hyped-gpt-3-impact-the-coders/ Will The Much-Hyped GPT-3 Impact The Coders? | Analytics India Magazine]
- With GPT-3, I built a layout generator where you just describe any layout you want, and it generates the JSX code for you. | Sharif Shameem - debuild
|
|
|
|
|
|
Generative Pre-trained Transformer (GPT-2)
- GitHub
- How to Get Started with OpenAIs GPT-2 for Text Generation | Amal Nair - Analytics India Magazine
- GPT-2: It learned on the Internet | Janelle Shane
- Too powerful NLP model (GPT-2): What is Generative Pre-Training | Edward Ma
- GPT-2 A nascent transfer learning method that could eliminate supervised learning some NLP tasks | Ajit Rajasekharan - Medium
- OpenAI Creates Platform for Generating Fake News. Wonderful | Nick Kolakowski - Dice
- InferKit | Adam D King- completes your text.
Coding Train Late Night 2
|
|
r/SubSimulator
Subreddit populated entirely by AI personifications of other subreddits -- all posts and comments are generated automatically using:
results in coherent and realistic simulated content.
GetBadNews
- Get Bad News game - Can you beat my score? Play the fake news game! Drop all pretense of ethics and choose the path that builds your persona as an unscrupulous media magnate. Your task is to get as many followers as you can while