Everyone, just give me one minute, it’s taking a little time to load. Okay, we are live now! So first we will recite the Quran, and then we will start the session shortly. Let me share my screen. I seek refuge in Allah from Satan the accursed, in the name of Allah, the Most Gracious, the Most Merciful. Allah......[Recitation continues] Translation: It is Allah who has subjected to you the sea so that ships may sail upon it by His command, and that you may seek of His bounty, and that you may perhaps be grateful. And He has subjected to you whatever is in the heavens and whatever is on the earth-all from Him. Indeed in that are signs for a people who give thought. Allah the Almighty has spoken the truth . JazakAllah, okay everyone! Let’s start the session. So our main agenda for today is different terminologies related to generative AI and how ChatGPT works, we need to understand its process. So we have with us Ma'am Dr. Tayyaba and Miss. So yes, Ma'am Hafsa, over to you! Ma'am Dr. Tayyaba, over to you! You can start. Peace be upon you!...First, let me share my screen. In the name of Allah, the Most Gracious, the Most Merciful. Sir, please tell me if my voice is clear and the screen is shared? Yes Ma'am, your voice is clear and your screen is shared too. Okay, so before starting the session, a brief introduction of myself. I am an electrical engineer by profession, I... ...sometimes. So, what is our session about today? Today's session is about generative AI models. Let’s look at the agenda to see what we are going to study today. Okay, so the first thing is, what are generative AI models? We will look at that first, and how we fine-tune them, we will see that, okay? After that, we will look at what transformers are. Actually, because, transformers, although it is a general term, since I am an electrical engineer, for me, it's those transformers installed on poles that come to mind whenever I hear the word " transformer." But in generative AI, what is a transformer? These are the brains of generative AI; everything is processed here, and whatever input you give to any model, any AI model, it is processed from here and then generates an output for you. Just like a CPU is the brain of any computer, which we call the brain of the computer, that is exactly how transformers are. Okay, since there are mostly students here, which of you have used generative, sorry, ChatGPT or any other chatbot like this? A lot of people have, over 100 members. Okay, so a lot of people know how ChatGPT and models like this, uh, are working, right? So today we will see that what you have seen so far is what its interface is. You give it a prompt and it generates an answer for you, and, uh, you can ask ChatGPT or any AI model about any kind of topic, right? Today we will see how it works, right? In addition to that, we will look at stemming and lemmatization. Okay, these are some terms that might seem difficult to you right now, so you don't need to worry after seeing them; we will discuss everything one by one. Right? For stemming and lemmatization, just understand for now that, for instance, when you travel somewhere, your, most people's approach is to take as little luggage as possible with them so that it is easier for them and their travel expenses are lower. Similarly, when we use a ChatGPT or any model, our effort is to convey our point to it in the minimum amount of text. To make it understand, right? So stemming and lemmatization are reducing that text, okay? After that, let's move on to understanding the input requirements and how we can measure the performance of these chatbots and generative AI models. After that, we will look at what API keys are, right? Since we are going to study this in this lecture and it is an important topic, understand it now, and whenever it is mentioned in future sessions, make sure you understand the concept well, okay? Apart from this, we will also look at what drag and its different techniques and tools are at the end of this session. Okay, right. Who among you has studied artificial intelligence or has at least heard the name of machine learning? Uh? Almost 200. People present here with us know what artificial intelligence and machine learning are, or they have heard the names. Right, even if you have just heard the name, that is enough for now. Well, artificial intelligence is made up of two things: artificial and intelligence, right? We will look at this now. It is a very large domain; a subset of it is machine learning, and a subset of that machine learning is deep learning, and then a subset of that is generative AI. So now let’s see what all these things are. Well, there is natural intelligence, which God has placed in our brains, through which we perform all our daily tasks, study, write, and do our work, right? In the same way, scientists have developed computers artificially so that they can think not about themselves, but think about whatever data is provided to them and make decisions, right? So artificial intelligence is a type of intelligence that mimics human decision-making and the way humans think. Well, uh, For example, I would like to ask you first: if there is a robot that is placing a specific type of object from one place to another, would that be intelligent, or would a robot that can pick up any type of object and place it at any distance be intelligent? First tell me, would the first robot be intelligent? Or the first one, yes! First, tell me, would the first robot be intelligent? How many people say so? Alright, almost 75 percent are saying that the first one would be. Now, let those who say that the second robot, which can pick up and place every kind of object, will be the correct one, please raise their hands. Okay, I get the idea. The second robot will be more intelligent because it will check every time what object is placed in front of it—like a book, a mouse, a pen, a pencil, or a ball—and determine its size and distance. Then, it will move its robotic arm accordingly, calculating exactly how far to reach and how wide to open its claw to easily grab the object and move it from one place to another. So, this second robot will be called an intelligent robot, and because it possesses this robotic intelligence, we will call it an Artificial Intelligence robot. Well, we saw in the previous slide that Machine Learning is a sub-domain of this Artificial Intelligence. So, in Machine Learning, we train machines—meaning computers —using different algorithms so that they develop the capability for prediction and decision-making. Now, looking at the broad spectrum, there are three types of Machine Learning: supervised learning, unsupervised learning, and reinforcement learning. First, let's see what happens in supervised learning. In supervised learning, whatever data we input into the machine, we tell the machine beforehand—for instance, when I input some data, let's suppose I feed pictures of cats or dogs into the model , right? Then I will label them, for example, if I have pictures of cats, I will specify that it is a cat and note its color—whether it is brown, black, or white. Similarly, if I provide pictures of dogs, I will tell the model what the dog's color, size, and breed are, right? And then, when the model tells me, since I have already trained it on all these pictures—it is now trained, right? Now, after training this model, I am asking it, having provided a new picture without labeling it as a dog or cat, to tell me whether it is a dog or a cat. So now, when it has to categorize an input into two... ...two types, the output it generates for me will be called classification, right? Because it classified an input into two things, right. This, and from this we can see that it works on discrete data; it gives us an answer in yes or no, right? It can distinguish colors, like in the cat example I gave, it can distinguish its color. And a classic example of this is spam emails, where it can categorize emails into spam and non-spam folders. Now, apart from this, we have a model called a regression model, which works on continuous data. Right, and it predicts continuous values. Examples of this include housing prices, temperature and weather forecasts for any region, or stock prices; a regression model can predict all of these. After this, we have unsupervised learning. In supervised learning, we were providing labeled data, but in unsupervised learning, we train the model on unlabeled data and the model itself... ...decides where to place that input and how to sort those things. I will give you an example of this right now. So, how many of you have used Google Photos? They know, these...The students know about Google Photos, right. Well, the reason I gave you the Google Photos example is that there is a feature in Google Photos where you can recognize faces; it recognizes facial features, and based on those, it groups similar faces in one place so that whenever, for example, it sees your face in a photo, it creates a separate folder just for your pictures. Okay, so what it's doing here is grouping photos separately; it's performing clustering based on facial features. So, this is how you can understand clustering. And another unsupervised learning model is dimensionality reduction. What it does is take all the data and...Simplifies it by removing the extra information. The model works by deleting that extra information and only storing the critical information it needs to keep. Now, I gave you the Google Photos example, right? Similarly, we can take the photo example; when we compress photos, compression ensures that the essential features of those photos or videos remain, while the rest becomes invisible, right? After that, we have reinforcement learning. Reinforcement means trial and error, right? So what happens in this? Is that you teach the model, and the model learns from your feedback. You all have used ChatGPT here, so you must have noticed that ChatGPT has a feedback feature. You give a thumbs up or a thumbs down to its responses, and based on that, it generates the next response according to your preference. And in the same way , there is another feature on social media; when a social media platform suggests a new post on your feed, there is also a feature where you can mark that post as "not interested" and hide it. Right? So, the input you provided here, The feedback you gave, that you are not interested in this post or didn't like the topic, now what the algorithms running in the background will do is remember your feedback and not suggest similar posts to you next time. Right. Let's move on. Okay, what is next in the hierarchy? Deep learning comes next. Deep learning is a subset of machine learning. Right? Okay, so what is happening in deep learning is that...First, tell me, how does the brain work? Like you know about the brain's neural networks; there are neurons inside the brain that help in decision-making. All of your processes, thinking, and working, are controlled by the brain, and which cells are used in this process? Neurons, which are in the brains, okay. So in deep learning, what we do is create artificial neurons , build their networks, and set their parameters in such a way that they can generate our desired output. Okay? So as the example written here, the facial recognition features in laptops and phones are an example of this. Okay. After that, we have Generative AI, which is a subset of deep learning, the last subset we are studying right now. Until now, what we did was provide data , any kind of data, and asked the model to make predictions or decisions based on it. Okay? But now, Generative AI generates new content that you have never seen before, nor read anywhere. Okay. That is why it is called Generative AI; meaning it is generating new content. It is not just analyzing the data. What can come under this type of content? The best example is ChatGPT , which generates content for you in the form of text, okay. Okay. Apart from this, we have other generative models that perform image and video generation. Okay. Similarly, we have a model called Claude, which is used for code assistance, and there are many other models that we will learn about later. Moving on. Okay, now let's come to LLMs. Who here knows about LLMs? Does anyone know? Okay. Right. LLM is a short form; in it, the first L stands for Large, the second L stands for Language, and the M stands for Model. Okay, meaning Large Language Model. What is this, though? This is a type of model trained on a vast amount of text data, meaning human language data, so it can identify, recognize, and summarize the complexities of human language, and generate new text of a similar nature. Right. Well, the best example of an LLM, which is even older than ChatGPT, is the autocomplete feature on your phones and laptops. Right, you can understand that this is also a similar feature that has been using LLMs, and it predicts what the next word should be after a given word. is. Okay, so far we have seen that an LLM can generate text like human language. Right? We have been using it for a while, but how does this LLM actually work? Since an LLM is a deep learning model, deep learning involves neural networks, and we build it using those neural networks. And in reality, the word we saw in our agenda, " Transformers," is the architecture it utilizes to process the inputs. Right? Well, what are its capabilities? You can generate text with it, meaning you can have it write essays, write stories , and write code. Right? And this task, the coding task, that is, generating code, we will also do in this course. Many writers use it as an assistant to write their essays, stories, and novels . Also, apart from this, there is language translation; whether you want to convert English to Urdu or any other different language into your native language, the language translation feature or capability is also provided by LLMs. And you must have seen on some websites that you have chatbots, meaning some websites are like a food ordering website. Right? There is a feature there where you can talk to a bot. Right? So, that feature appearing there, um, for chatting with a bot, you can ask questions about it, about any particular product, that feature also uses an LLM. Now we will see how it is used through APIs. Okay. ChatGPT, Google Gemini, Claude, and Perplexity are some chat interfaces that we usually interact with in our day-to-day lives. Well, how do we interact with them, how do we generate new content or provide our input? We can input text, we can input images, okay, and like, when I have to present a lecture, I have them create slide decks for me, okay. In this way, you can use all these things. But in this course, we need to see how we will use these LLM APIs—that is, these LLMs—in our solutions, in whatever software solution we build, right? So we will use these LLM APIs, and likewise, we have some specialized models that we will read about later, further along in the course, so how we can use them in our software or websites, we will look into that. So, let's move on to the next slide. Okay, this is the Gemini interface, this is the ChatGPT interface. Okay, so one of the important concepts of this lecture is API. API stands for Application Programming Interfaces. Well, you don't need to be worried about this word or its meaning because I will explain it to you right now. A classic example of this is that, um...You go to a restaurant, so when you go to a restaurant, what happens? You go as a customer, you call the waiter there and place your order with the waiter, you tell them to bring you a certain thing. The waiter goes to the kitchen and tells the chef to prepare that order. The chef prepares the order, and the waiter brings it back and delivers it to you, right? So what is happening here is that as a customer, when you call the waiter, the waiter is your API , okay? You have the API, When you called the waiter, you made an API call , okay? You told the waiter to bring you an order, a specific dish from the menu; that means you told the API to fetch a particular kind of data for you , okay? Now, what will it do? The waiter, or in our case the API, will go to the kitchen. The waiter goes to the kitchen, while the API goes to the server, okay? And you can imagine the server as the kitchen here. Just as a chef prepares food in the kitchen, the server will process your data request, okay? And then the server will bring it back and give it to the API. And your API will return that data request along with the data you asked for. Just like how you order food from a waiter and the waiter delivers the food to your table, okay? That was one real-life analogy. Now let's see how we can utilize this ourselves, in our apps and in our solutions. Well, here I have taken the example of a weather forecast app, if you want to build a weather forecast app or website, okay? What will happen there is that any user will come and let's say they ask for the weather of their city for that day, okay? Then the API, whatever API you have used in your app, will most probably be the meteorological department's services API. Okay? So that API will go to the meteorological department's server and find the data for your particular city from there. Okay? That server will find that data and give it to the API, and the API will bring it back and deliver it to you, meaning that data will be shown on your website, whether it is going to rain that day, or the weather will be sunny or cloudy, accordingly, okay. Another example we can take is, tell me , ride-hailing apps like Uber, Yango, or inDrive, who among you has used them ? So almost all people use those apps, Right? Well, in those ride-hailing apps , you must have seen the map feature being used. Meaning, whenever you open the app, it asks you what your location is and where you want to go, right? So when you enter both those locations, you are shown a map from your current location to your destination, right? The map used there isn't like every ride-hailing service uses its own map; that’s not the case, because mostly these companies use GPS data, right? And by utilizing GPS APIs, like Google Maps, they use those APIs on their sites so they can provide their users the same experience that Google Maps provides. Sir. Since...so, we can take some questions. Sir, are you there? Yes, ma'am, let's take a few questions in the middle, then we'll move on. Okay, sir. Okay, I will call names and unmute; kindly unmute your mic and ask your question. Yes, Ms. Ayesha. Ayesha? If you are speaking, we can't hear you. Yes. Regarding, I think I raised my hand for that, that... Okay, ma'am. Okay, let's take the next one, Adeena Atta. You have been unmuted. Adeena Atta? Okay, Jaweria Zulfiqar? Abbas Khan? I think you guys are unable to unmute. Assalam-o-alaikum, can you hear my voice? Yes. We can hear you. My question is, what is the difference between API and API? Sir, can you clarify? Sir, you used the terms "simple API" and "wait API" in your question. Web API, Web API. Can you spell which one you are referring to? Web, Web, W-E-B, Web. Yeah, yeah. Okay, Web API, okay. Actually! I thought you were making a spelling mistake, okay. Mainly, the main purpose of an API is to make two different applications communicate with each other. Right? Now inside a web API , what you do is enable communication between the front end and the back end. You are building that API yourself, right? Exactly, you are creating a path . Now, the main purpose of this API is to allow different platforms to share a token or a key with you, which we call an API key, through which you will be able to access multiple different models. Right? The main thing is you are connecting to that platform using an API key to access something, okay? What? Clear. Yes. Yes, peace be upon you. Well, I just wanted to say that just like Talha brother explained about web APIs and simple APIs, the person presenting the slides here should explain it in the same way. At least until the basics are understood, how will it work? Just reading the slides is like what is happening in Pakistan's universities, the slides are being read accordingly. I don't think that, out of the 893 participants here, anyone is actually going to benefit from this. So kindly, just as Talha brother explained, please explain it in the same way. Thank you. Sir, okay, I will call names one by one , kindly do not speak in between, okay? Okay, Aman. What? Aman. Sir, please mute everyone's mic, then after that, I will... Peace be upon you, sir. Hello, peace be upon you. And peace be upon you too. Sir, I wanted to ask if we will learn to train ML in this course. Our main focus is to build applications using different models. We will not go into core ML, but we will definitely show you the entire flow of how a model is actually trained, okay? We will do one or two sessions on that. Okay. Sir, I have a... Let's take the next question. Huzaifa. Huzaifa Zaki. Huzaifa Zaki. Hafsa Jawad. Sir, I had a question, I... Sa Jawad. Saira. Sir. Saira. Okay ma'am, let's move a bit further and then take questions again, okay? Okay, sir. Peace be upon you. Hello, peace be upon you, sir. I had a question. Yes. Ah, Muhammad Hafsa, if you are speaking , I think your mic got unmuted, then muted. Okay, sir. Yes. Now, let's look at the problems and advantages we might encounter when accessing an API. First, let's look at the advantages, okay? The first advantage is that your efficiency increases and the speed of your application also improves. This is because when you use pre-built functionality, like the Google Maps example I gave, or if an e-commerce site uses PayPal. PayPal isn't really available in Pakistan, I guess, right now. But if they were using PayPal, that website wouldn't need to develop that functionality, like Google Maps, from scratch. Right? So, the website can be built quickly because you are using pre-built functionality via APIs, and your core focus remains on your business or domain. Right? Additionally , it is cost-effective because building everything from scratch, from zero, is difficult. So, when you use a pre-built module in your site, you don't need to do the groundwork; you just use the system that is already built. Right? So , the cost is greatly reduced. Right? Furthermore, you get interoperability. This is because you can connect different software and different platforms. You don't need everything to be built on the exact same framework. Right? Also, you don't need to spend separately on servers, because when you use a company's or platform's API, the servers they have installed will process the data for you. Right, and? Since GPT and Gemini, etc., are such powerful models, right? So you can use these powerful models, which have been trained on thousands and billions of data points, directly within your own site. First of all, if you try to fetch the data yourself, you cannot get that much data at once; it is very difficult . Right, so how do you? To overcome this drawback, you use pre-built models , and those pre-built models are very powerful because they are designed specifically for this purpose. Now let’s look at its disadvantages. You have to keep your API secure on your site, right, so that...You can avoid malicious activity and hacking, so you need to secure your site. Besides that, another drawback is that if the company or site whose API you are using—like GPT, Gemini, or AWS—goes down, or if there is a server malfunction, that functionality on your website or application might be reduced or discontinued, right? So...If the company that provides that API...If they experience downtime, your site is also affected, and business operations are impacted, right. Also, because communication is happening between servers, your site might get a bit slow , and it requires an internet connection, right. Well, we hadn't studied models until now, so let’s look at the models we will be using most of the time. We have speech-to-text generation models, meaning you dictate whatever you want to say, and it gets converted into text , right. You must have experienced this feature on ChatGPT when you are dictating your prompts. Besides this, there are text-to-text translation models like Google's, object detection models, and image generation text-to-image conversion models where you provide a text prompt describing the type of image you want. For example , when Midjourney went viral a while ago, its key feature was that it would convert your input—meaning your text-based input—into an image, right ? In addition, there are models for classifying ages through faces, known as age detection models. Well, so far we have looked at what kind of models exist and how we can access these models via API. Where will we find these models? Right, so we have a site; there are others, but mostly in this course, we will be using Hugging Face, okay? I will show you its interface. Well, here is its interface. Here you can see that Its models, databases, and datasets are all appearing here. Right? So let's look at its models. First, look here, there is Mistral AI's text-to-speech generation model. And you will find many models here. Besides this, if you need datasets, you can find them here, and since we are in a course, our effort will be to use free models. So you should also go to Hugging Face and log in to your account so that you don't face any trouble later. Well. That was all from my side. The remaining topics will be conducted by our other trainer. So, over to you, Ma'am Tayyaba. But, If there are any questions, I can answer them. Okay, let's just take questions for two to three minutes, then we will hand it over to Ma'am Tayyaba. I will unmute one by one, kindly do not unmute your mics yourselves, I am saying this again . Yes, Hafsa Jawad. Hafsa Jawad. Abbas Khan. Assalam-o-Alaikum sir, I have a question. Sir, will you show us a practical demonstration of what the Ma'am is teaching? And if these slides could be shared in the group, it would be great, because those who joined late can catch up on what they missed, making it easier for them. Okay! I will just add this point. All these slides and recordings that are shared with you, if you check the description of the WhatsApp groups you are added in, there is a link attached to a Google Document or a Google Sheet. So, if you click on that, you will find these slides there as well. And secondly, as far as the practical part is concerned, we will be doing everything practically. Today's session was an introduction to the terminologies, where we are discussing the different terms that will be used during the course. Alright? So, today's session is the main session, and Tuesday, Wednesday, and Thursday will be practice sessions based on today's session. Alright. Clear? All right sir, all right. Okay, let's take the next question. Uh. My question is. Actually sir, the login part they mentioned earlier, can you kindly repeat that? The login part that Madam was explaining, about logging in from our own accounts, can that be repeated, kindly? Yes sir, I will do it. Sir, this is your site, Hugging Face. And since my account is logged in here, if you search on Google, you will find Hugging Face. Let me search for you. Hugging. One minute. Sir, I have opened a new tab, is it visible to you? Yes ma'am, your tab is visible. Okay! So search here, there is a site named Hugging Face. Okay? So. You will go here. Since my account is logged in here, everything is already visible to you. But when you go there—I am trying to show you by logging out—let me check if I can do that. Sir, you have to log out, so. Okay, I will show them the main page, ma'am, if you could stop your screen share for a moment. Okay sir, I will show them. Okay, let me know if my screen is shared with you , please tell me. Please confirm this. Screen is shared. Okay, you just have to go to HuggingFace.co; I have attached the link for you. Right, I have shared this link with you in the chat. And similarly, this link is also added to the Google Doc and Google Sheet. So, if you look over here on the rightmost side, you will see Login and Sign Up. Those who have used it before will use Login, and they will be logged in. Otherwise, you need to come to Sign Up. After clicking Sign Up, these are the same steps as when you create your social media account. You have to enter an email address you use, set a password, and click next. So, a complete video about how you will log in will also be attached, okay, that too in the Google. Yes sir, I can log in, but tell me a bit about Hugging Face, what is it? Basically, in simple words, Hugging Face is like a flea market for models. All the first-time models that have been made free of cost, the open-source ones, you will find them here; just simply come to Models here. Okay. Come to this Models tab. We talked about ChatGPT; you have all used ChatGPT. Now, the ChatGPT that is running nowadays is 5.2. Obviously, ChatGPT 1 came, 2 came, 3 came, and so on, it kept getting updated. Right? So, we search for ChatGPT here. Which ChatGPT models are available here for free? Right, so here people have kept some things stored. Right, these specific names are the ones people have fine-tuned. If you want to do OpenAI, because OpenAI is a company, then you click on OpenAI, and look, there are multiple different free-of-cost models available. GPT-2 is there, OpenAI is on it. What does this mean? Yes. Sir, kindly tell us what is the purpose of this, like what is its real objective, what can we use this Hugging Face website for? We have to pick models from it, we haven't clearly understood it inside. Peace be upon you and God's mercy. I feel like many of the participants don't know the basics of what OpenAI is . And this, Okay, kindly, if you could just be a little patient, I think I am trying to answer and explain it to you all. Right now, it’s just a session on different terminologies; we will use all these things, and there won't be anything that will go right over your heads, okay? We have five weeks in total, within which every single thing is divided into sessions. Right? Yes, in this, Peace be upon you. Need to use the chat. You want to say that when we move to the practical part later, we will teach you this, right? Yes. So that is exactly the point. Okay, sir ! I had a question for you about LLMs, you know, in this era of Large Language Models, right? Can an individual developer fine-tune them on their local system, or is it only a job for big companies? You can fine-tune them, but building from scratch is not possible. Sorry. Sir, I had a question about LLMs, meaning... We can use them on the cloud, but we can't use them on a regular laptop, right? If we fine-tune it locally, would we need the cloud or a supercomputer? No, sir. Sir, one question. Should we move forward? Why are we discussing things that we haven't covered yet? Sir, please, my request to you is to keep questions open only for the host. You will receive questions in text; you should answer those. Instead of stopping the flow in the middle like this. I think we will keep the Friday sessions for Q&A, and otherwise, we will proceed in this typical way. All right? I don't think there is anyone here who is in sixth or seventh grade. Everyone is either a university graduate or a university student, and they are mature enough that everyone should understand things clearly. Kindly make sure we do all these things . All right? I am sharing a document with you so that you can all check on your end when this will be shared, instead of repeating questions again and again. The same thing we need to do . This sheet was shared with you yesterday as well; it's attached in the WhatsApp group and written in the group description, so you can access it from there. If you come here, this is our main document which contains the complete outline for everything we are doing in these six weeks. If we talk about today, look here, we had two main sessions, Right? There is a practice session from eight to ten, and then there is a hackathon.