hey it's random code here and today I just want to quickly showcase how we can actually utilize llms and run them and connect to them using python as I've L just been playing around with a few small personal projects and I expected that it would be very complex and require some crazy Hardware to actually have it all run locally but we can actually using something called AMA which is kind of like a local program which then allow us to install at least some models like I'm using the the Llama models so that is the open
source models created and provided by Facebook or meta to be more precise what I then found is that it's actually very very simple almost too simple so it it feels a bit magical but what we would simply do is I would go online just download AMA which is kind of like a service running in the background on My Windows desktop here when I have it downloaded I would then find Which models I would like to utilize and right now the newest llama version is llama 3.1 so I just simply go in here and you should
then check for example first that you have a llama installed if you just put a llama it will showcase like commands or you can do or llama do version to check the version you have a llama if we then simply do llama run and then the model name it's going to download it and kind of add it to the list of active models in llama I already have done this and it should take a few minutes so be patient but again very simple download llama ensure it runs download the model we can then simply do
llama list see here that a few days ago I downloaded a model of llama 3.1 and that is actually just it from python having this running in the background it then kind of serves as service providing like API endpoints and using python all I need to install is I have Pip I use pip 3 to install again like the Llama connection tool in my case it's already installed so it's very quick and simple but inside python I'm using a notebook here to showcase the example but we can simply import llama Define our model name and
again looking back at our list we use llama 3.1 I then need to create some kind of like text prompt I then create a stream so we kind of like have a connection to the the model in this case like AMA pass that we're using this model this is the message and we're going to be streaming the result so kind of like if you use chat gbt or something like that you would see that it's kind of like streamed line by line we're using it as a role from a user perspective doesn't matter much but
we then have the content which is going to be all prompt and we can then very simply just have the stream and then utilize stream by kind of like going through each chunk or each line when they're available and have them printed like this and just a simple prompt then asking what color is the sky we can see here that it should then simply give us an answer and to me this is actually just like so impressive and almost C crazy than just simply downloading AMA downloading the model and then simply just being able to
interact with it like this through python very simply and now it allows me to have some kind of like small projects I wanted to try out but I don't really want to go pay for some crazy llm API endpoints or something I just wanted like a small to test the functionality and this then provides at least to me a pretty decent Baseline for some exploration and and testing of all this functionality otherwise I hope you enjoyed this small showcase and enjoyed my fascination of how easy we can actually interact and play with large language models
at this point and if you did please leave a like And subscribe and I wish you all a wonderful day