Deep Dive into LLM Sampling Techniques: Chapter 7

Weights & Biases · Intermediate ·🧠 Large Language Models ·2y ago

Key Takeaways

Delves into LLM sampling techniques, including temperature and top-p techniques, with real model demonstrations

Full Transcript

[Music] okay now that we understand how tokens work let's move on to sampling we discussed different sampling methods and the first one we'll experiment with is temperature we can provide temperature as a as a parameter to open AI completion function uh we use this to generate um to generate a response to some text so in this case we will use our text D Vinci 003 model our prompt is going to be say something about weights and biases and then we will also limit the output to 50 tokens and we will set temperature as a as a hyper parameter and then return the text out of the the API response so let's uh run this function and then let's generate text for different temperature values ranging from zero to two and the intuition is like temperature zero is is gritty the coding it should sample the most probable tokens in a sequence and in this case the model says that weights and biases is an amazing tool for tracking and analyzing machine learning experiments it provides powerful visualizations and insights into model performance enabling data scientists to quickly identify areas of improvement and optimize their models I'm quite happy with this generation it feels like um the model knows um the the the value proposition of weights and biases and we can see how this changes as we as we increase temperature parameter and you can see now we're getting different Generations so with temperature one uh weight Andes is a powerful tool for managing and monitoring machine learning projects it provides real-time insights into the performance of your models and presents a wide range of visualizations to ensure that data is is easy to interpret again quite happy with this generation what happens if we further increase the temperature so with temperature value two um the model says uh weights and biases is an awesome analytics and visualization platform designed specifically for everything from model interviews to share neural Nets um and you can see like here actually this uh becomes a bit gibberish and and it probably is too high of a value of a temp which means that tokens with low probabilities get sampled and this results in text which isn't really uh that meaningful so here um probably temperature like between zero and one is something that we want to go to go for uh using this model we also discussed the top P sampling which is another sampling method uh open AI um encourage us to pick one of those two parameters and not play with both um so let's now try to to experiment with top P sampling parameter and again we use the same model we'll use the same prompt and now we'll uh generate text with different top values and again we'll go with a range from 0 01 to one in the case of the the lowest uh value of top p uh we will pick tokens with the uh with the highest probability and and we can see that we are hitting rate limit errors on the open AI um API so we're going to wait a moment and in the next um in the next section uh I will show you how to how to handle these errors these errors more gracefully with back off uh for now let's wait uh and when the rate limit uh stops hitting us we'll continue with this uh section okay it looks like the we were able to run the API now and we can see the different generations for different top P values and again with the lowest value of top P we are sampling a high probability text and we can read about weights and biases that it is an amazing tool for tracking and visualizing machine learning experiments it helps to keep track of all uh the different experiments you run and provides powerful visualizations to help you understand the results and again I'm quite happy with this result uh probably the uh 01 uh value is quite good as well now what happens if we increase top p uh so let's read for top P equals 1 weights and bies is an AI experimentation platform that helps teams understand track and collaborate on their machine learning projects it provides powerful visualizations realtime alerts and integrated workflows um and again this text is quite good and the reason is probably that we are still using the temperature parameter in the background so the the rare tokens are uh the the tokens with low probability are are very unlikely uh to be selected uh but again like this is probably a bit more diverse so experimenting with top P values is a different way of making sure that uh the model uh generates diverse and interesting um text on the other hand if you want to go for minimal risk and making sure like the highest probability taxt is generated then decreasing uh Tope or decreasing temperature might be a good a good choice

Original Description

🤖 Dive into Advanced LLM Sampling in Chapter 7: Explore Temperature & Top P Techniques. Experience real model demonstrations and troubleshooting tips. 🧑🏾‍🎓 *Full course with certification and class materials available free at http://wandb.me/building-llm-powered-apps* 🏆 *Daily swag draw* and grand prize Airpods draw from Dec 1 and 31, 2023. Details at http://wandb.me/llm-apps-contest 🗣️ Join the course conversation on our Discord channel at http://wandb.me/course-discord 🏫 This is chapter 7 of 27 in the Building LLM-Powered Apps course. *Episode Description* Dive into the world of Large Language Models (LLMs) with Weights & Biases in this chapter of our free online course, "Building LLM-Powered Apps." Join our expert, Darek Kleczek, as he explains the nuances of sampling methods in LLMs. 🌟 *Chapter Highlights* -Understanding Sampling in LLMs: Uncover the significance of sampling methods in generating text with LLMs. -Temperature and Top P Sampling: Learn about two critical sampling techniques – temperature and top P – and how they influence text generation. -Practical Demonstrations: See these sampling methods with real examples using GPT. Understand how different settings impact the output. -Troubleshooting Tips: Gain insights into handling API limit errors and other common challenges in LLM applications. 🎓 *Enroll for Free:* Join us on this educational journey to master the art of building LLM-powered applications. Enroll at http://wandb.me/building-llm-powered-apps. 👉 *Next Chapter Sneak Peek:* Be sure to watch our upcoming chapter, where we'll delve into building a baseline LLM application, covering key aspects like application architecture and more.
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Weights & Biases · Weights & Biases · 0 of 60

← Previous Next →
1 0. What is machine learning?
0. What is machine learning?
Weights & Biases
2 1. Build Your First Machine Learning Model
1. Build Your First Machine Learning Model
Weights & Biases
3 Intro to ML: Course Overview
Intro to ML: Course Overview
Weights & Biases
4 2. Multi-Layer Perceptrons
2. Multi-Layer Perceptrons
Weights & Biases
5 3. Convolutional Neural Networks
3. Convolutional Neural Networks
Weights & Biases
6 Weights & Biases at OpenAI
Weights & Biases at OpenAI
Weights & Biases
7 Why Experiment Tracking is Crucial to OpenAI
Why Experiment Tracking is Crucial to OpenAI
Weights & Biases
8 4. Autoencoders
4. Autoencoders
Weights & Biases
9 5. Sentiment Analysis
5. Sentiment Analysis
Weights & Biases
10 6. Recurrent Neural Networks [RNNs]
6. Recurrent Neural Networks [RNNs]
Weights & Biases
11 7. Text Generation using LSTMs and GRUs
7. Text Generation using LSTMs and GRUs
Weights & Biases
12 8. Text Classification Using Convolutional Neural Networks
8. Text Classification Using Convolutional Neural Networks
Weights & Biases
13 9. Hybrid LSTMs [Long Short-Term Memory]
9. Hybrid LSTMs [Long Short-Term Memory]
Weights & Biases
14 Toyota Research Institute on Experiment Tracking with Weights & Biases
Toyota Research Institute on Experiment Tracking with Weights & Biases
Weights & Biases
15 Weights and Biases - Developer Tools for Deep Learning
Weights and Biases - Developer Tools for Deep Learning
Weights & Biases
16 Introducing Weights & Biases
Introducing Weights & Biases
Weights & Biases
17 10. Seq2Seq Models
10. Seq2Seq Models
Weights & Biases
18 11. Transfer Learning for Domain-Specific Image Classification with Small Datasets
11. Transfer Learning for Domain-Specific Image Classification with Small Datasets
Weights & Biases
19 12. One-shot learning for teaching neural networks to classify objects never seen before
12. One-shot learning for teaching neural networks to classify objects never seen before
Weights & Biases
20 13. Speech Recognition with Convolutional Neural Networks in Keras/TensorFlow
13. Speech Recognition with Convolutional Neural Networks in Keras/TensorFlow
Weights & Biases
21 14. Data Augmentation | Keras
14. Data Augmentation | Keras
Weights & Biases
22 15. Batch Size and Learning Rate in CNNs
15. Batch Size and Learning Rate in CNNs
Weights & Biases
23 Applied Deep Learning Fellowship Overview and Project Selection with Josh Tobin (2019)
Applied Deep Learning Fellowship Overview and Project Selection with Josh Tobin (2019)
Weights & Biases
24 Grading Rubric for AI Applications with Sergey Karayev  (2019)
Grading Rubric for AI Applications with Sergey Karayev (2019)
Weights & Biases
25 16. Video Frame Prediction using CNNs and LSTMs (2019)
16. Video Frame Prediction using CNNs and LSTMs (2019)
Weights & Biases
26 Image to LaTeX - Applied Deep Learning Fellowship (2019)
Image to LaTeX - Applied Deep Learning Fellowship (2019)
Weights & Biases
27 17.  Build and Deploy an Emotion Classifier (2019)
17. Build and Deploy an Emotion Classifier (2019)
Weights & Biases
28 Applied Deep Learning - Data Management with Josh Tobin (2019)
Applied Deep Learning - Data Management with Josh Tobin (2019)
Weights & Biases
29 Snorkel: Programming Training Data with Paroma Varma of Stanford University (2019)
Snorkel: Programming Training Data with Paroma Varma of Stanford University (2019)
Weights & Biases
30 Applied Deep Learning - Troubleshooting and Debugging with Josh Tobin (2019)
Applied Deep Learning - Troubleshooting and Debugging with Josh Tobin (2019)
Weights & Biases
31 Troubleshooting and Iterating ML Models with Lee Redden (2019)
Troubleshooting and Iterating ML Models with Lee Redden (2019)
Weights & Biases
32 Designing a Machine Learning Project with Neal Khosla (2019)
Designing a Machine Learning Project with Neal Khosla (2019)
Weights & Biases
33 Lukas Beiwald on ML Tools and Experiment Management (2019)
Lukas Beiwald on ML Tools and Experiment Management (2019)
Weights & Biases
34 Building Machine Learning Teams with Josh Tobin (2019)
Building Machine Learning Teams with Josh Tobin (2019)
Weights & Biases
35 Pieter Abeel on Potential Deep Learning Research Directions  (2019)
Pieter Abeel on Potential Deep Learning Research Directions (2019)
Weights & Biases
36 Testing and Deployment of Deep Learning Models with Josh Tobin (2019)
Testing and Deployment of Deep Learning Models with Josh Tobin (2019)
Weights & Biases
37 Five Lessons for Team-Oriented Research with Peter Welder (2019)
Five Lessons for Team-Oriented Research with Peter Welder (2019)
Weights & Biases
38 Applied Deep Learning - Rosanne Liu on AI Research (2019)
Applied Deep Learning - Rosanne Liu on AI Research (2019)
Weights & Biases
39 Making the Mid-career Leap from Urban Design to Deep Learning/Data Science
Making the Mid-career Leap from Urban Design to Deep Learning/Data Science
Weights & Biases
40 Organizing ML projects — W&B walkthrough (2020)
Organizing ML projects — W&B walkthrough (2020)
Weights & Biases
41 Brandon Rohrer — Machine Learning in Production for Robots
Brandon Rohrer — Machine Learning in Production for Robots
Weights & Biases
42 Nicolas Koumchatzky — Machine Learning in Production for Self-Driving Cars
Nicolas Koumchatzky — Machine Learning in Production for Self-Driving Cars
Weights & Biases
43 My experiments with Reinforcement Learning with Jariullah Safi
My experiments with Reinforcement Learning with Jariullah Safi
Weights & Biases
44 Applications of Machine Learning to COVID-19 Research with Isaac Godfried
Applications of Machine Learning to COVID-19 Research with Isaac Godfried
Weights & Biases
45 Testing Machine Learning Models with Eric Schles
Testing Machine Learning Models with Eric Schles
Weights & Biases
46 How Linear Algebra is not like Algebra with Charles Frye
How Linear Algebra is not like Algebra with Charles Frye
Weights & Biases
47 Predicting Protein Structures using Deep Learning with Jonathan King
Predicting Protein Structures using Deep Learning with Jonathan King
Weights & Biases
48 Rachael Tatman — Conversational AI and Linguistics
Rachael Tatman — Conversational AI and Linguistics
Weights & Biases
49 Reformer by Han Lee
Reformer by Han Lee
Weights & Biases
50 Sequence Models with Pujaa Rajan
Sequence Models with Pujaa Rajan
Weights & Biases
51 GitHub Actions & Machine Learning Workflows with Hamel Husain
GitHub Actions & Machine Learning Workflows with Hamel Husain
Weights & Biases
52 Look Mom, No Indices! Vector Calculus with the Fréchet Derivative by Charles Frye
Look Mom, No Indices! Vector Calculus with the Fréchet Derivative by Charles Frye
Weights & Biases
53 Jack Clark — Building Trustworthy AI Systems
Jack Clark — Building Trustworthy AI Systems
Weights & Biases
54 Surprising Utility of Surprise: Why ML Uses Negative Log Probabilities - Charles Frye
Surprising Utility of Surprise: Why ML Uses Negative Log Probabilities - Charles Frye
Weights & Biases
55 Track your machine learning experiments locally, with W&B Local - Chris Van Pelt
Track your machine learning experiments locally, with W&B Local - Chris Van Pelt
Weights & Biases
56 Antipatterns in open source research code with Jariullah Safi
Antipatterns in open source research code with Jariullah Safi
Weights & Biases
57 Attention for time series forecasting & COVID predictions - Isaac Godfried
Attention for time series forecasting & COVID predictions - Isaac Godfried
Weights & Biases
58 Made with ML - Goku Mohandas
Made with ML - Goku Mohandas
Weights & Biases
59 Angela & Danielle — Designing ML Models for Millions of Consumer Robots
Angela & Danielle — Designing ML Models for Millions of Consumer Robots
Weights & Biases
60 Deep Learning Salon by Weights & Biases
Deep Learning Salon by Weights & Biases
Weights & Biases

Related Reads

📰
Mixture of Experts (MoE) Explained
Learn about Mixture of Experts (MoE), a breakthrough AI architecture that enables models to scale efficiently while reducing inference costs
Dev.to AI
📰
Building a RAG Chatbot with FastAPI and ChromaDB (that runs locally, no API key)
Learn to build a RAG chatbot using FastAPI and ChromaDB that runs locally without an API key, enabling personalized document-based question answering
Dev.to · deaw.ai
📰
Your 5-Line LLM Script Was Great. Then Reality Showed Up.
Learn to move beyond simple 5-line LLM scripts and tackle real-world complexities in LLM project development
Medium · LLM
📰
AI without illusions: Appendices
Learn to use generative AI with professional discipline and without illusions, using reference materials and checklists
Medium · AI
Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →