liveBook · Manning

Chapter 11: Deploying an LLM on a Raspberry Pi: How low can you go?

What you will learn in chapter 11 of LLMs in Production

The chapter introduces a hands-on project to run a locally accessible LLM service on a Raspberry Pi, using its limitations to teach practical deployment lessons.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduces a hands-on project to run a locally accessible LLM service on a Raspberry Pi, using its limitations to teach practical deployment lessons.

Key terms: Raspberry Pi, LLM Service, GGUF, quantizing, drop-in replacement, OpenAI GPT model, production-only project, possible and useful, limitations, scale up

11.1 Setting up your Raspberry Pi

Introduces the Raspberry Pi LLM server project, its hardware requirements, practical caveat, and setup-to-serving path.

Key terms: Raspberry Pi 5 8 GB, MicroSD, power supply, ethernet cable, operating system (OS), packages and libraries, LLM server, home network, single-board computer

11.1.1 Pi Imager

The section walks through using Pi Imager to put a lightweight OS on a microSD card and configure the Pi for network and SSH access before its first boot.

Key terms: Pi Imager, Raspberry Pi OS Lite 64-bit, Raspberry Pi OS (Other), microSD, storage device, image, OS customizations, hostname, Wi-Fi, ethernet

11.1.2 Connecting to Pi

Shows how to find a Raspberry Pi’s network address and connect to its terminal from a laptop using SSH, without keeping a monitor and keyboard attached.

Key terms: IP address, router, ifconfig, ip a, inet, ipconfig, arp -a, nslookup, SSH, username

11.1.3 Software installations and updates

This section prepares a connected Raspberry Pi to run an LLM by installing dependencies, building llama.cpp, and downloading the model files.

Key terms: git, pip, llama.cpp, git commit, virtual environment, requirements, C++, Make, CMake, Llava-v1.6-Mistral-7B

11.2 Preparing the model

This section prepares a downloaded model for Raspberry Pi serving by converting it to GGUF, quantizing it to fit the device, and offering ways past common setup problems.

Key terms: safetensor, tokenizer, GGUF, convert.py, .gguf checkpoint, quantization, q4_K_M, 7B parameter model, llama.cpp, make clean

11.3 Serving the model

This section shows how to access a llama.cpp model on a Raspberry Pi and uses the slow but quick-to-build deployment to illustrate the value of a rapid proof of concept.

Key terms: llama.cpp, Pi’s IP address, API key, local network, OpenAI’s Python bindings, base_url, gpt-3.5-turbo, built-in minimal GUI, port 8080, five tokens per second

11.4 Improvements

This section shifts from a guided Raspberry Pi walkthrough to ways readers can adapt the project for themselves.

Key terms: guided assistance, different model, different tooling

11.4.1 Using a better interface

The section suggests improving the Raspberry Pi LLM project’s user experience by trying interfaces and servers beyond llama.cpp.

Key terms: llama.cpp, compiling, quantizing, serving, frontend, KoboldCpp, SillyTavern, customization, frontend and server

11.4.2 Changing quantization

This section explains how to choose a llama.cpp quantization format when a Raspberry Pi or other hardware cannot comfortably run the model used earlier in the project.

Key terms: llama.cpp, quantization formats, q4_K_M, perplexity, 4 or 6 GB Pi, 7B, 1B, 3B, Q2_k, Q3_K_S

11.4.3 Adding multimodality

The section adds image input to a LLaVA model served on a Raspberry Pi, shows how to query it, and explains why the result is impractically slow.

Key terms: LLaVA, multimodal projection file, vision portion, .gguf, --MMPROJ, mmproj.gguf, OpenAI API, encode_image, messages, Raspberry Pi

11.4.4 Serving the model on Google Colab

The section shows how to move the Raspberry Pi prototype to Google Colab for testing and combine llama.cpp Python bindings, an OpenAI-compatible API, and LangChain for an extensible RAG deployment.

Key terms: Google Colab, Jupyter, free tier, GPU, llama.cpp Python bindings, OpenAI API, LangChain, ChatOpenAI, GPT-3.5-turbo, sentence transformer

11.5 Summary

The summary recaps the setup, memory, performance, and serving tradeoffs involved in deploying an LLM on a Raspberry Pi.

Concepts explained in this chapter

← Chapter 10: Creating a coding copilot project: Integrating an LLM service into VS Code with RAG Chapter 12: Production, an ever-changing landscape: Things are just getting started →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.