AI & Machine Learning Made Simple Code 19: Starcoder Model to Generate Python Java Code Hugging Face

preview_player
Показать описание
Point of this series of videos is to make AI & Machine Learning easy to understand via live coding.

In this video, I show you how you can use free Starcoder Model to Generate Python/Pascal/Java Code

Transcript:
0:08 Today's topic. In Hugging Face website, by the way, that's the site. That has 352,000 now. It's going to 1,000 more distant overnight.
0:19 352,000 free slash open source AI models that you can play with. Download. Do whatever you want to do with it.
0:28 One of the, say if we sort by most likes, one of the main ones that come up is starcoder. It is supposed to be able to, so in, in, in the left side you will see what's called a model card.
0:41 It tells you all that you want to know about this particular model. The thing to see here is it, you can tell it to run code in 80 plus programming languages, which is pretty darn awesome.
0:53 So we're going to play with that today. Whenever you see this part hosted in inference API, that means you can try your you can try the model out yourself just on the website.
1:06 Nothing to install, nothing to pay, nothing right here. So we will do just that. So what we'll do, we have to look, do a little trick here, right?
1:15 So let me, let's, first let me try a straightforward way and see what happens. So we're going to say, write a Python program that uses, uses a, a while loop, uses a while loop that starts at i equals 1 and ends when i is greater than 100.
1:49 Each iteration, Each iteration should increment i by 3. This will probably not work and I'll tell you in a minute why.
2:05 So let's do that. Compute. Because it's a star coder it did work. So what this is doing you see here is in other text generation models, you have to trick it.
2:17 You have to say, you have to start saying this is a code that does da. So it starts to predict the next word and that's how you decode.
2:25 But because this is a coding model, it understands that it's supposed to give you a code. So. The reason why it stopped because I think the API backend is not that powerful.
2:35 So it generated only five or six next words which is which is part of the code. Then it stops. If I keep hitting compute, it will eventually complete the code.
2:48 So. Let's keep doing that until it finishes. So it looks like it's getting iced. It's repeating itself. Anyway, so you see it did that.
2:59 It did just this. That's just what we told it to do in Python. Now let's say we want to. The code is the same.
3:06 So we don't erase all the text that it generated. And we're going to say write a C++ program. And see what that does.
3:19 Okay, no code yet. Okay, no code yet. Okay, this doesn't work pretty well. Okay, let's stop that. That didn't quite work.
3:34 I know I tried Pascal. So let's try Pascal. It's really old language. Each one. First language I learned programming in.
3:41 Let's see what that does. I don't think it's gonna work for Pascal. Okay, it's not working. So what I'm going to do, I'm going to try a different tag here.
3:51 I'm going to say I'm going to pretend it's a text generation model. So we're going to say the following is a Pascal program that does this.
4:12 That way I'm tricking it to complete the paragraph, complete the next word and so that should hopefully give me a code.
4:20 Let's try that. There you go. So that works. So that is the Pascal code with the same thing. I'm going to stop that here.
4:30 I'm going to release that. I'm going to try and do the same thing for C++ which failed when I told it to do it straight away without tricking it.
4:39 So let's compute that. There you go. That's better. So now that's a C++ program that does that. I'm curious. I don't know this for a fact.
4:47 I'm curious if this will work for a really old language called Fortran. Fortran. Okay. Dang, it does work. Ah, maybe that's the Python.
5:04 They even got confused. So let's try Java. Let's see if that works. Ah, it's left out the, left out the P in the public.
5:20 There we go. It's working. There you go. So, anyway, long story short, StarCoder is a free model you can use either on Colab or on your laptop, whatever, but it could also come in here in Hugging Face Web.
5:38 And just play with it to give you code that you need. Alright, I hope you found this video useful. If you did, please like and subscribe and I'll see you in the next video.
Рекомендации по теме
visit shbcf.ru