llama.cpp

llama.cpp is a C++ implementation focused on running transformer models efficiently on consumer hardware with minimal dependencies. It emphasizes CPU inference optimization and quantization techniques to enable local model execution across diverse platforms including mobile and edge devices.

Prerequisites

  1. Sufficient RAM (refer to Hardware Prerequisites)

  2. A Hugging Face account

Deployment

  1. Setup a python virtual environment. In this guide, we'll use uv .

curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.local/bin/env

uv venv
source .venv/bin/activate
  1. Clone the llama.cpp repo

git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
  1. Build and Install Dependencies

cmake .
make -j8
uv pip install -r requirements.txt --prerelease=allow --index-strategy unsafe-best-match
  1. Install Hugging Face and Login

  1. Download the model size you want to run

    1. The larger the model, the more memory it will require and the slower it will run

    2. model_name:The exact name of the model you want to deploy, like trinity-nano-6b. This tells the system which model to download from Hugging Face.

    3. model_quant:Indicates the quantization format of the model, such as bf16, q4_0, or q8_0. Choose based on your hardware; lower-bit formats run faster and use less memory but may reduce accuracy slightly.

  1. Host the model

  1. Run Inference using the Chat Completions endpoint.

Ensure you replace Your.IP.Address with the IP address of the instance you're hosting the model on

Last updated