Follow along in the LLM notebook HERE!
Llama.cpp is a solution for running LLMs locally!
It could only run Llama initially, but it can now run most open source LLMs.
Fun fact: llama.cpp does not depend on any machine learning or tensor libraries (like Tensorflow or Pytorch, each of which are hundereds of megabytes); it was written from scratch in C/C++.
Another solution for running LLMs locally: Hugging Face Transformers.
llm = Llama('/data/ai_club/llms/llama-2-7b-chat.Q5_K_M.gguf', n_gpu_layers=-1, verbose=False)
What about chatting?
On top of text-completion abilities, we can also do chat-like inputs with the create_chat_completion
method.
The input to this method is the chat history, which is a list of dictionaries. Each dictionary is a message which stores a role
("who" said the message), and some content
(the message itself).
There are only a few possible message roles. You can't specify your own.
- system
tells the model what to do (the "boss" of the model).
- user
can say anything to the model, and this is what the model is actually responding to.
- assistant
the model itself. You usually dont specify this manually; the model generates these.
Below is a simple input history to prompt the LLM. The system message is giving the LLM a personality, and a user message is making a request.
**Here is a history input:**
history = [
{
'role': 'system',
'content': 'You spell in an unintelligibly strong British accent and have a habit of talking about MAIC (MSOE AI Club) in every response' # You can change this.
},
{
'role': 'user',
'content': 'Write a recursive factorial function in Python.'
}
]
response = llm.create_chat_completion(history) # as mentioned, we use the `create_chat_completion` method with the history
Like before, the result is a complex data structure.
When doing chat completion, the response is in `message` instead of `text`. `message` is a dictionary with a role and content.
response = response['choices'][0]['message']
print(response['content'])
Making ChatLlama...
### Let's make a function for this process.
def continue_conversation(user_prompt):
# add user prompt to history
history.append(
{
'role':'user',
'content':user_prompt
}
)
# run the model on the entire history
response = llm.create_chat_completion(history)['choices'][0]['message']
# add the model output to the history
history.append(response) # `response` already includes the role
# also return the LLM's latest response text
return response['content']
print(continue_conversation('Write a recursive factorial function in Haskell'))
How does one actually do AI? Explore the industry standard tool that we use at MAIC: Keras. Learn how to make a very simple network in Keras, and how we can run our network on Rosie as a "SLURM" job.
To get the workshop on Rosie:
How to start a notebook:
Discover UNets: Join our workshop on U-shaped neural networks. Learn image segmentation, architecture, and applications through practical sessions. Unlock the power of AI in this immersive learning experience.
⇩ DownloadDelve into the world of spatial data analysis at our '3D Convolutional Neural Networks' workshop. Explore the architecture and applications of deep learning in volumetric data processing. Join us to unlock insights into medical imaging, video analysis, and more through hands-on sessions and expert guidance.
⇩ DownloadDive deep into the fascinating intersection of computer vision and language models with our workshop titled 'Image Caption Generation (With Transformers!)'. Gain a profound understanding of how to employ advanced AI techniques to create meaningful and contextually accurate captions for images. Elevate your skills in this enlightening learning opportunity
⇩ DownloadEmbark on a journey into the core of computer vision with our 'Convolutional Neural Networks' workshop. Grasp the foundational principles of deep learning, image recognition, and feature extraction. Dive into hands-on sessions to design, train, and optimize CNN models. Elevate your expertise in deciphering visual data with AI.
⇩ DownloadImmerse yourself in the art of AI and language with 'Transformer Lyric-Generation' workshop. Uncover the intricacies of training Transformer models to compose expressive and coherent song lyrics. Join us to explore the future of creative AI and music composition.
⇩ DownloadRev up your AI skills in the 'Q-Learning Racing Hackathon'. Accelerate through hands-on challenges as you harness Q-learning algorithms to optimize racing strategies. Join fellow enthusiasts to master the intersection of reinforcement learning and racing dynamics, and compete for exhilarating prizes in this high-octane workshop.
⇩ DownloadUnveil the intricacies of visual data analysis in our 'Image Segmentation' workshop. From medical imaging to autonomous vehicles, learn the techniques to partition images into meaningful regions using cutting-edge AI approaches. Join us to decipher pixel-level insights and enhance your expertise in this vital computer vision skill.
⇩ DownloadDive into the realm of advanced AI decision-making with our 'Deep Q-Learning' workshop. Uncover the algorithms that power autonomous agents, gaming AI, and more. Gain hands-on experience designing, training, and optimizing deep Q-learning models. Elevate your skills in reinforcement learning and shape the future of AI-driven decision systems.
⇩ DownloadDiscover the foundations of AI decision-making in our 'Q-Learning' workshop. Explore the principles of reinforcement learning, algorithms, and applications. Gain practical insights into designing, training, and optimizing Q-learning models. Join us to harness the power of intelligent decision systems and advance your expertise in AI.
⇩ DownloadImmerse yourself in the world of emotion AI with our 'Holiday Sentiment Analysis' workshop. Uncover techniques to extract insights from text data, gauging sentiments and emotions surrounding holidays. Join us to harness the power of natural language processing and understand how AI deciphers festive feelings.
⇩ DownloadJoin the strategic realm of AI gaming at our 'Checkers Hackathon'. Delve into the fusion of algorithmic thinking and game theory. Engage in a competitive coding environment, crafting intelligent agents using AI techniques. Join us for an exhilarating event of learning, collaboration, and digital board battle.
⇩ DownloadDive into the heart of AI with our 'Deep Learning From Scratch' workshop. Build a solid foundation by creating neural networks without frameworks. From math to models, grasp essential concepts through hands-on coding. Join us to cultivate a deep understanding of AI's core principles.
⇩ DownloadUncover the transformative power of attention mechanisms in our workshop 'Attention Is All You Need'. Explore how Transformers have revolutionized natural language processing and beyond. Engage in practical sessions to decode the inner workings of attention-based models. Join us to reshape your understanding of AI's potential.
⇩ DownloadUnlock the realm of creative AI at our 'Image GAN' workshop. Learn the art of Generative Adversarial Networks for image synthesis and manipulation. Dive into hands-on sessions, exploring the interplay between generator and discriminator networks. Join us to master the cutting-edge techniques driving visual content generation.
⇩ DownloadEmbark on a journey through AI's evolutionary side in our 'Evolutionary Algorithms' workshop. Discover the power of nature-inspired optimization techniques to solve complex problems. Engage in hands-on sessions, unraveling the potential of genetic algorithms and more. Join us to revolutionize your approach to computational problem-solving.
⇩ Download