Skip to main content

Run Llama3 (or any LLM / SLM) on Your MacBook in 2024

Listen:

I'm gonna be real with you: the Cloud and SaaS / PaaS is great... until it isn't. When you're elbow-deep in doing something with the likes of ChatGPT or Gemini or whatever, the last thing you need is your AI assistant starts choking (It seems that upper network connection was reset) because 5G or the local WiFi crapped out or some server halfway across the world is having a meltdown(s).

That's why I'm all about running large language models (LLMs) like Llama3 locally. Yep, right on your trusty MacBook. Sure, the cloud's got its perks, but here's why local is the way to go, especially for me:

  1. Privacy: When you're brainstorming the next big thing, you don't want your ideas floating around on some random server. Keeping your data local means it's yours, and that's a level of control I can get behind.

  2. Offline = Uninterrupted Flow: Whether you're on a plane, at a coffee shop with spotty wifi, or just hate being at the mercy of your internet connection, having an LLM on your local machine means you can brainstorm, draft,and refine ideas anytime, anywhere.

  3. Speed: Local models tend to be faster than cloud-based ones, simply because there's no round trip to a remote server. This makes for a much smoother, more responsive experience. Okay, depends on your hardware, and a MBP M2 with 8Gb RAM isn't the number cruncher et all. But instead to use 8B models, 4B highly tuned are running perfectly fine, like Phi3 (https://huggingface.co/bartowski/Phi-3-mini-4k-instruct-GGUF)

  4. Experimentation: Want to tweak parameters, try out different model versions, or play around with custom prompts? Having a local setup gives you a sandbox to tinker and explore without worrying about cloud costs or throttling.

Alright, Enough Talk. Let's Get This Thing Running

If you're ready to ditch the cloud and take control of your AI, here's the lowdown on how to get Llama 3 up and running on your MacBook:

  1. Ollama is Your Friend: Download the Ollama app for macOS. It's a simple way to manage and run various LLM models locally. Just grab it from their website: wget https://ollama.com/download/Ollama-darwin.zip; unzip Ollama-darwin.zip

  2. Run Llama3: Move ollama.app into Application, start up ollama.app, and allow the command line setup. Open the terminal and run the following command: ollama run llama3; this will download the model if you don't have it already and start it up.

  3. Hugging: Want to play with other models from Hugging Face? No problem. Just download the .gguf file and create a simple model file with the details from the model card on Hugging Face.

    wget https://huggingface.co/TheBloke/CapybaraHermes-2.5-Mistral-7B-GGUF/resolve/main/capybarahermes-2.5-mistral-7b.Q3_K_S.gguf 


    Create the modelfile:

    vi mf-mistral 


    <-- SNIPP

    FROM "./capybarahermes-2.5-mistral-7b.Q3_K_S.gguf "


    PARAMETER stop "<|im_start|>"

    PARAMETER stop "<|im_end|>"


    TEMPLATE """

    <|im_start|>system

    {{ .System }}<|im_end|>

    <|im_start|>user

    {{ .Prompt }}<|im_end|>

    <|im_start|>assistant

    """

    SNAP --> 


    Create your model:

    ollama create h1 -f mf-mistral 

    ollama run h1


    list all installed models:

    ollama list

Pro Tip: Tailor your prompts for product ideation! Instead of generic questions, focus on specific problem areas or target audiences.

Example:

"give me some quotes from steve ballmer"

Ready to Roll?

Running Llama 3 locally on your MacBook is a game-changer for product ideation. You'll have the freedom, speed, and privacy to unleash your creativity and build products that truly matter to your users.


Comments

Popular posts from this blog

Deal with corrupted messages in Apache Kafka

Under some strange circumstances, it can happen that a message in a Kafka topic is corrupted. This often happens when using 3rd party frameworks with Kafka. In addition, Kafka < 0.9 does not have a lock on Log.read() at the consumer read level, but does have a lock on Log.write(). This can lead to a rare race condition as described in KAKFA-2477 [1]. A likely log entry looks like this: ERROR Error processing message, stopping consumer: (kafka.tools.ConsoleConsumer$) kafka.message.InvalidMessageException: Message is corrupt (stored crc = xxxxxxxxxx, computed crc = yyyyyyyyyy Kafka-Tools Kafka stores the offset of each consumer in Zookeeper. To read the offsets, Kafka provides handy tools [2]. But you can also use zkCli.sh, at least to display the consumer and the stored offsets. First we need to find the consumer for a topic (> Kafka 0.9): bin/kafka-consumer-groups.sh --zookeeper management01:2181 --describe --group test Prior to Kafka 0.9, the only way to get this in...

Beyond Ctrl+F - Use LLM's For PDF Analysis

PDFs are everywhere, seemingly indestructible, and present in our daily lives at all thinkable and unthinkable positions. We've all got mountains of them, and even companies shouting about "digital transformation" haven't managed to escape their clutches. Now, I'm a product guy, not a document management guru. But I started thinking: if PDFs are omnipresent in our existence, why not throw some cutting-edge AI at the problem? Maybe Large Language Models (LLMs) and Retrieval Augmented Generation (RAG) could be the answer. Don't get me wrong, PDF search indexes like Solr exist, but they're basically glorified Ctrl+F. They point you to the right file, but don't actually help you understand what's in it. And sure, Microsoft Fabric's got some fancy PDF Q&A stuff, but it's a complex beast with a hefty price tag. That's why I decided to experiment with LLMs and RAG. My idea? An intelligent knowledge base built on top of our existing P...

AI's False Reality: Understanding Hallucination

Artificial Intelligence (AI) has leapfrogged to the poster child of technological innovation, on track to transform industries in a scale similar to the Industrial Revolution of the 1800s. But in this case, as cutting-edge technology, AI presents its own unique challenge, exploiting our human behavior of "love to trust", we as humans face a challenge: AI hallucinations. This phenomenon, where AI models generate outputs that are factually incorrect, misleading, or entirely fabricated, raises complex questions about the reliability and trust of AI models and larger systems. The tendency for AI to hallucinate comes from several interrelated factors. Overfitting – a condition where models become overly specialized to their training data – can lead to confident but wildly inaccurate responses when presented with novel scenarios (Guo et al., 2017). Moreover, biases embedded within datasets shape the models' understanding of the world; if these datasets are flawed or unreprese...