Check out a free preview of the full Build an AI-Powered Fullstack Next.js App, v3 course

The "LLMs & Prompts" Lesson is part of the full, Build an AI-Powered Fullstack Next.js App, v3 course featured in this preview video. Here's what you'd learn in this lesson:

Scott introduces Large Language Models (LLMs). One of the most popular LLMs is GPT, created by OpenAI. Prompts and the Langchain framework are also introduced in this lesson.


Transcript from the "LLMs & Prompts" Lesson

>> So let's just hop into it. So what I'm gonna do is I'm gonna make a new file in the utils folder. I'm gonna call it AI. So there's a lot I can talk about with the AI stuff. So I'm gonna give a primer on some of the technologies that we'll be using.

I'll give a demo of how to do a very basic example of some of these technologies and then we'll actually implement what we just talked about, that way you have some context of what what is going on. Okay, anyone here knows what an LLM is? All right, anyone wanna explain that?

>> Just like a basic level language learning model. It's like a. It's like an algorithm. It's heuristics, trains itself on datasets and learns, selects best responses. So it needs some sort of input to actually work on, and then it also needs input to shape how it weights its responses.

>> Yeah, that's pretty accurate. So LLM stands for large language model. But what you just said also makes sense too. But yeah, everything else, pretty accurate. So there was this whitepaper that came out not too long ago called Transformers. Well, it was on a topic of something called Transformers.

The best way I can describe Transformers is it's a different architecture for neural networks. If you don't know what a neural network is, that's totally fine. It's actually a really great exercise to go through and build one yourself. It sounds scary, but it's actually not. You can go watch YouTube video on building your own neural network from scratch in JavaScript, and it's a really good example.

But basically, a neural network is like our best guess of how our brains work and then converted that to code. It's something that can take in inputs and then, through training, can do some type of prediction on and output, right? In this case, these neural networks that are inside these LLMs can take in something like a prompt, like an input, like you said, and then output something that sounds, not even truthy, something that sounds like a human would say it.

And that's because these neural networks are trained on the entire Internet, at least the one that we're gonna be using. It's literally trained on the entire Internet. So everything that is publicly available on the Internet, it has seen, so it can make plausible predictions based off what it thinks the next word might be.

So Transformers, that is a different type of neural network architecture that allows the neural network to basically observe an entire sentence versus before they could only look at the previous word to predict the next word. Now you can look at the entire input to predict the next word, and it's somewhat recursive, and that allows it to be way better at predicting things.

And that's kinda the new advancement that was created that's enabled all this stuff with generative AI, right? It's really just that paper called Transformers, and I think the paper is called Attention Is All You Need. Attention is All, or something like that.
>> That's it, yeah.
>> Yeah, Attention Is All You Need, yep.

So if you read this, yeah, if you read that whitepaper, you'll either probably be really confused, which I was a million times. I actually fed the whitepaper to the AI and asked it questions like, can you explain this to me? So, yeah, highly recommend checking that out. But anyway, I wanted to give you that primer.

I think it's just giving you enough that if you wanna look that up and learn more about it, you can look it up. Okay, so now that you know LLM is, some of the bigger ones out there are the one created by, you probably heard of this one, created by OpenAI, and it's called GPT.

So GPT stands for, The T in GPT stands for transformer, so it's a generative pre-trained transformer. That's literally all it is, it's actually quite powerful. I don't know why I'm just putting it down like that. But yeah, we're gonna be using GPT which is a hosted LLM. We don't have to, bringing that down to our computer, if you wanted to run an LLM on your machine, you would need a GPU, basically.

Most Macs could probably run a decent LLM, the problem is you're not gonna get something as big and powerful as GPT on your machine. But there are tons of other open source LLMs out there that are single-purposely built to do specific things. GPT is kinda like the Walmart of LLM, so it kinda just does everything.

And it's massive, it's huge. But if you want arts and crafts, you could go to Walmart, but you could go to arts and crafts store that's a little smaller and has the thing you specifically need. So, there's tons of these coming out. This is the one that we're gonna use.

It's just an API. You don't need to know anything about it other than how to make an API call. Okay, now the other thing is, I don't know if you had any experience with AI, but you have to interface with a prompt, right? And a prompt is basically, you can think of it as a command or an ask or a question, but it also comes down to trying to understand the limitations of something like GPT and what it can and cannot do.

And you have to figure out how to steer it in a direction to get the results that you want. And that's a whole job on its own. It's prompt engineering, something that I recommend everyone at least taking a course on if you're technical. So, we will be talking about some of that.

And then the last thing, so we can finally get into the code, is something called LangChain. So, we'll be using this a lot. So LangChain is, it's pretty much the number one framework right now for using AI or LLMs. It's like an SDK for LLMs, basically. It's mostly built in Python, we won't be using a Python version because they also have a JavaScript version, and that is pretty much in feature parody with the Python version, at least for what we need.

There are like some things that are in Python that aren't in the JavaScript version. But it's like really advanced bleeding edge stuff. So we don't really care about it. We'll be using this. It's And basically the LangChain, like I said, it's just an SDK, it interface with pretty much every LLM.

We'll be using an interface with OpenAI. It's a quite sophisticated product. You can do some pretty interesting stuff, as you'll soon find out. And yeah, any questions on all that stuff? And that was so high level. This was basically like standing on the USS, the International Space Station, and looking down at a penny.

That's how high level this was. So [LAUGH] I glanced over a lot of stuff, but I just wanted to make sure you have that.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now