Building Web Chatbots with LLM: Chapter 19
Key Takeaways
Building a web chatbot with LLM using Weights & Biases, Gradio, and Longchain, with a conversational QA chain and Vector store.
Full Transcript
[Music] we should be ready now to build our simple web application which will allow weights andb users to ask questions from our bot let's get started in the config P we Define our configuration including the weights and biases project the job type if you work in a team then we set the team which becomes the weights and bies entity and we also Define where do we pull our Vector store from and where do we pull our prom template from and in this case we are using weight Andis artifacts that we created in the previous video we can also set the model that we want to use uh to run our application we will be also using several functions defined in the chain. pi file specifically we want to load our Vector store and again we will pull the vector store from weight Andes artifacts where we uploaded it after um ingesting documents we also want to load our chain and here specifically we will use the conversational QA chain from longchain uh we will be using the chat open AI model and we can choose between 3.5 turbo and GPT 4 uh in this case we Define in the settings GP uh chat GPT uh which is a 3.5 turbo model and we Define the parameters which again we pull from the config file and then we return this conversational retrieval chain which is a utility defined in L chain and we will pass it on to our application so that uh so that we can respond to user questions by calling this chain and finally we have the get answer function which uses our chain along with the user question to provide back a response so let's go back to our application in this case we are using a simple gradio user interface uh which we will expose as a web application we Define this chat class which will become our interface H that persists our Vector store and our chain in between user calls here we need the configuration and we need the weight run which uh is used to pull our artifacts including the vector store and the chain what we call this uh chat interface uh what happens in the background is in case um the vector store or the chain are not loaded we load them uh we save them in that uh chat object and then we use the get answer function to create a response and append it to the history then we use gradio blocks to Define our user interface specifically we have a text box for the user question we have another text box to specify open AI API key if we want to our if we want to expose it to our users and we don't want to share our open AI API key in this case I have set this as an environment variable so I don't need to provide it but in case you want to expose uh your application on the web and you don't necessarily want to sponsor um the open AI API calls then you can request the users to provide their own key uh we're also storing the state uh we have uh our uh chatbot object and then whenever a user submits a question we call our chat object um along with the default configuration and we pass the question along with a state and receive back the answer that we can uh expose in our user interface so let's run this application now and see how it looks um in our browser again we're using weights and biases to pull our Vector store and our documents and the application is running on the local uh URL so let's uh click this link and we can see our Q&A B uh exposed um via our browser uh we can deploy this uh we can deploy deploy our application for example or on hugging face spaces or on replit there are multiple ways we will not go into the details of deployment in this course but I encourage you to check out the additional links we provide uh below this video to see the different deployment options that you may use let's add try to ask our uh chatbot query just to verify that it's working properly and now we can see the answer uh we can see that to share a report with team members there's a list of steps we can follow including saving the report clicking the share button and so on uh it could be correct but this looks in fact a bit different from what we've seen in the previous um videos when we uh when we explored a similar query and we implemented our retrieval chain and maybe it would be interesting to see what happened behind the scenes and how this uh chain was actually run what was fed uh what was retrieved from our Vector store which documents were fed into the prompt and to do that we can use a weights and biases Tracer so let's take a look there all right so when we go into weights and biases uh remember we set our environment variable L chain W be tracing to true and that means that all of the queries and responses are streamed into weights and bies and we can analyze it there and see what went well or what might have potentially gone wrong in this case we can see the question that we asked in our web interface how do I share a report with my team members and there is also the answer that we also saw in the user interface and we can also see the trace timeline the sequence of um of function calls that uh ultimately resulted in our generation we can see the conversational retrieval chain that we Define in L chain which in turn calls the stuff document chains with a bunch of input documents uh from L chain and then if we go drill down into the llm chain and ultimately the open AI uh we can see uh the prompt here which includes all of the documents that were stuffed into this um into the template and if we scroll through this list of documents we can see um first like the system part of the template uh we uh should be able to see uh different documents which were retrieved from the vector store um and if we scroll through uh through this we can uh hopefully find a document that talks about about collaboration and sharing qu and bies reports and it tells us that once you have saved the report you can select the share button to collaborate draft copy of the report is created when you select the edit button draft reports out to save and we can see like this is actually what influenced um the answer uh of our llm chain so by using weight invis Tracer you can debug you can understand what happened behind the scenes what is the sequence of API calls uh that was done to produce the answer and in this case we found in the prompt the document that was used to generate this output uh this way you can uh do error analysis if some of the responses are potentially flued as unhelpful by your users you can see and drill down what happened maybe uh the correct document was not retrieved for a given query and we need to improve something on the document search and retrieval site maybe the model didn't perform so well and didn't find the right answer within the prompt and maybe we can steer that for example by better prompt engineering or changing to a more powerful model maybe we should switch from GPT 3.5 to GPT 4 or anthropy clo or a coher command model there are many options available and by doing this experimentation we can improve our application and this will be the topic of the next module where we will uh develop a deliberate process of experimenting improving our application and evaluating our results see you then
Original Description
🤖 Explore web chatbots with LLM - Join Darek Kleczek in creating a user-friendly LLM-powered chatbot web application.
🧑🏾🎓 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
*Episode Description*
In this chapter of “Building LLM-Powered Apps”, the free course from Weights & Biases, we step into the world of web application development. Led by Darek Kleczek, Machine Learning Engineer at W&B, this session focuses on creating a simple, user-friendly web application that enables users to interact with an LLM-powered chatbot.
🌟 Chapter Highlights
-Creating a User Interface: Learn how to build a simple and intuitive user interface for your LLM-powered chatbot using the Gradio library.
-Configuring the Application: Explore the essential components of the configuration file, including project settings and model selection.
-Loading Vector Store and Chains: Understand the process of loading vector stores and conversational QA chains from Weights & Biases artifacts into your application.
-Implementing Chat Functionality: Dive into the technicalities of -implementing a chat interface that responds to user queries using the LLM.
-Interactive Web Application Demo: Follow along as we demonstrate the application's capabilities live in a browser environment.
🎓 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: Stay tuned for our upcoming chapter, where we focus on enhancing and optimizing LLM applications.
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
0. What is machine learning?
Weights & Biases
1. Build Your First Machine Learning Model
Weights & Biases
Intro to ML: Course Overview
Weights & Biases
2. Multi-Layer Perceptrons
Weights & Biases
3. Convolutional Neural Networks
Weights & Biases
Weights & Biases at OpenAI
Weights & Biases
Why Experiment Tracking is Crucial to OpenAI
Weights & Biases
4. Autoencoders
Weights & Biases
5. Sentiment Analysis
Weights & Biases
6. Recurrent Neural Networks [RNNs]
Weights & Biases
7. Text Generation using LSTMs and GRUs
Weights & Biases
8. Text Classification Using Convolutional Neural Networks
Weights & Biases
9. Hybrid LSTMs [Long Short-Term Memory]
Weights & Biases
Toyota Research Institute on Experiment Tracking with Weights & Biases
Weights & Biases
Weights and Biases - Developer Tools for Deep Learning
Weights & Biases
Introducing Weights & Biases
Weights & Biases
10. Seq2Seq Models
Weights & Biases
11. Transfer Learning for Domain-Specific Image Classification with Small Datasets
Weights & Biases
12. One-shot learning for teaching neural networks to classify objects never seen before
Weights & Biases
13. Speech Recognition with Convolutional Neural Networks in Keras/TensorFlow
Weights & Biases
14. Data Augmentation | Keras
Weights & Biases
15. Batch Size and Learning Rate in CNNs
Weights & Biases
Applied Deep Learning Fellowship Overview and Project Selection with Josh Tobin (2019)
Weights & Biases
Grading Rubric for AI Applications with Sergey Karayev (2019)
Weights & Biases
16. Video Frame Prediction using CNNs and LSTMs (2019)
Weights & Biases
Image to LaTeX - Applied Deep Learning Fellowship (2019)
Weights & Biases
17. Build and Deploy an Emotion Classifier (2019)
Weights & Biases
Applied Deep Learning - Data Management with Josh Tobin (2019)
Weights & Biases
Snorkel: Programming Training Data with Paroma Varma of Stanford University (2019)
Weights & Biases
Applied Deep Learning - Troubleshooting and Debugging with Josh Tobin (2019)
Weights & Biases
Troubleshooting and Iterating ML Models with Lee Redden (2019)
Weights & Biases
Designing a Machine Learning Project with Neal Khosla (2019)
Weights & Biases
Lukas Beiwald on ML Tools and Experiment Management (2019)
Weights & Biases
Building Machine Learning Teams with Josh Tobin (2019)
Weights & Biases
Pieter Abeel on Potential Deep Learning Research Directions (2019)
Weights & Biases
Testing and Deployment of Deep Learning Models with Josh Tobin (2019)
Weights & Biases
Five Lessons for Team-Oriented Research with Peter Welder (2019)
Weights & Biases
Applied Deep Learning - Rosanne Liu on AI Research (2019)
Weights & Biases
Making the Mid-career Leap from Urban Design to Deep Learning/Data Science
Weights & Biases
Organizing ML projects — W&B walkthrough (2020)
Weights & Biases
Brandon Rohrer — Machine Learning in Production for Robots
Weights & Biases
Nicolas Koumchatzky — Machine Learning in Production for Self-Driving Cars
Weights & Biases
My experiments with Reinforcement Learning with Jariullah Safi
Weights & Biases
Applications of Machine Learning to COVID-19 Research with Isaac Godfried
Weights & Biases
Testing Machine Learning Models with Eric Schles
Weights & Biases
How Linear Algebra is not like Algebra with Charles Frye
Weights & Biases
Predicting Protein Structures using Deep Learning with Jonathan King
Weights & Biases
Rachael Tatman — Conversational AI and Linguistics
Weights & Biases
Reformer by Han Lee
Weights & Biases
Sequence Models with Pujaa Rajan
Weights & Biases
GitHub Actions & Machine Learning Workflows with Hamel Husain
Weights & Biases
Look Mom, No Indices! Vector Calculus with the Fréchet Derivative by Charles Frye
Weights & Biases
Jack Clark — Building Trustworthy AI Systems
Weights & Biases
Surprising Utility of Surprise: Why ML Uses Negative Log Probabilities - Charles Frye
Weights & Biases
Track your machine learning experiments locally, with W&B Local - Chris Van Pelt
Weights & Biases
Antipatterns in open source research code with Jariullah Safi
Weights & Biases
Attention for time series forecasting & COVID predictions - Isaac Godfried
Weights & Biases
Made with ML - Goku Mohandas
Weights & Biases
Angela & Danielle — Designing ML Models for Millions of Consumer Robots
Weights & Biases
Deep Learning Salon by Weights & Biases
Weights & Biases
More on: LLM Engineering
View skill →Related Reads
📰
📰
📰
📰
Guardrails AI: preventing LLM hallucinations and enforcing output structure
Dev.to AI
I Built a Dead-Simple API Gateway for My Local LLMs in 50 Lines of Python
Dev.to AI
Build with Open-Weight LLMs: A Developer's Guide to API Integration
Dev.to AI
How to Add Real-Time Web Search to LlamaIndex Agents
Dev.to · Cecilia Hill
🎓
Tutor Explanation
DeepCamp AI