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 happens often by using 3rd party frameworks together with Kafka. Additionally, Kafka < 0.9 has no lock at Log.read() at the consumer read level, but has a lock on Log.write(). This can cause a rare race condition, as described in KAKFA-2477 [1]. Probably a log entry looks like: 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 every consumer in Zookeeper. To read out the offsets, Kafka provides handy tools [2]. But also zkCli.sh can be used, 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 possibility to get this inform

Hive query shows ERROR "too many counters"

A hive job face the odd " Too many counters:"  like Ended Job = job_xxxxxx with exception 'org.apache.hadoop.mapreduce.counters.LimitExceededException(Too many counters: 201 max=200)' FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MapRedTask Intercepting System.exit(1) These happens when operators are used in queries ( Hive Operators ). Hive creates 4 counters per operator, max upto 1000, plus a few additional counters like file read/write, partitions and tables. Hence the number of counter required is going to be dependent upon the query.  To avoid such exception, configure " mapreduce.job.counters.max " in mapreduce-site.xml to a value above 1000. Hive will fail when he is hitting the 1k counts, but other MR jobs not. A number around 1120 should be a good choice. Using " EXPLAIN EXTENDED " and " grep -ri operators | wc -l " print out the used numbers of operators. Use this value to tweak the MR s

GPT & GenAI for Startup Storytelling

OpenAI and Bard   are the most used GenAI tools today; the first one has a massive Microsoft investment, and the other one is an experiment from Google. But did you know that you can also use them to optimize and hack your startup?  For startups, creating pitch scripts, sales emails, and elevator pitches with generative AI (GenAI) can help you not only save time but also validate your marketing and wording. Curious? Here are a few prompt hacks for startups to create,improve, and validate buyer personas, your startup's mission/vision statements, and unique selling proposition (USP) definitions. First Step: Introduce yourself and your startup Introduce yourself, your startup, your website, your idea, your position, and in a few words what you are doing to the chatbot: Prompt : I'm NAME and our startup NAME, with website URL, is doing WHATEVER. With PRODUCT NAME, we aim to change or disrupt INDUSTRY. Bard is able to pull information from your website. I'm not sure if ChatGPT