For the complete documentation index, see llms.txt. This page is also available as Markdown.

20.4 Local Deployment of Large Language Models

llama.cpp

llama.cpp is written in C/C++, aiming to achieve large model inference on various hardware with minimal configuration. llama.cpp depends on misc/ggml for the underlying tensor computation library, which is automatically installed when misc/llama-cpp is installed. In a pure CPU environment, if GPU acceleration needs to be disabled, the VULKAN=OFF option can be set in misc/ggml (not in llama-cpp itself).

Installation

  • Install using pkg:

# pkg install llama-cpp
  • Install using Ports:

# cd /usr/ports/misc/llama-cpp/
# make install clean
  • View installation instructions

# pkg info -D llama-cpp

Deploying the Qwen Large Model

GGUF is a file format that stores the information needed to run a model. llama.cpp requires models to be stored in this format.

The Hugging Face platform hosts a large number of GGUF-format large models compatible with llama.cpp. Users can directly search for the keyword "llama gguf".

Qwen is a family of large language models developed by Alibaba Cloud. Assuming the use of Qwen/Qwen3-0.6B-GGUF:

$ llama-cli -hf Qwen/Qwen3-0.6B-GGUF:Q8_0 --jinja --color -ngl 99 -fa -sm row --temp 0.6 --top-k 20 --top-p 0.95 --min-p 0 --presence-penalty 1.5 -c 1024 -n 256 --no-context-shift
Parameter
Description

-hf Qwen/Qwen3-0.6B-GGUF:Q8_0

Specifies the model source and quantization version, using model files from Hugging Face Hub with 8-bit quantized weights

--jinja

Enables Jinja template parsing, allowing variables in prompts

--color

Displays colored output in the terminal, making it easier to distinguish user input from model-generated text

-ngl

Specifies the number of layers to offload to GPU (n-gpu-layers); larger values use more GPU

-fa

Enables Flash Attention, optimizing attention computation, which can improve inference speed and reduce VRAM usage

-sm row

Sets multi-GPU tensor split mode (split mode); row means splitting tensors across different GPUs by row

--temp

Sets the sampling temperature, controlling the randomness of generated text

--top-k

Limits token generation to selecting from the highest-probability candidates, improving text diversity

--top-p

Nucleus sampling strategy, only selecting tokens whose cumulative probability reaches a certain threshold

--min-p

Minimum probability threshold for generating tokens, used to filter low-probability tokens

--presence-penalty

Applies a penalty to repeatedly occurring tokens, reducing repetitive text

-c

Context window length, the number of historical tokens the model can remember during generation

-n

Maximum number of tokens to generate, controlling the total length of generated text in one pass

--no-context-shift

Disables context sliding or moving window, maintaining a fixed context for text generation

For detailed parameter descriptions, refer to the llama.cpp deployment guide in the Qwen official documentation.

The output is as follows:

Type /exit or press Ctrl + C to exit. To use it again, simply run the same command.

The model will be cached at ~/.cache/huggingface/hub.

Ollama

Ollama is a tool for running large language models, primarily written in Go and C.

Installation

  • Install using pkg:

  • Install using Ports:

  • View installation instructions

Service Management

Enable the service and set it to start on boot:

Start the service immediately:

Deploying DeepSeek-R1

Pull the 1.5b parameter DeepSeek-R1 model:

For more large models, see library.

The output of the above command is as follows:

The larger the number of parameters, the larger the model size typically is. The default Ollama storage location is ~/.ollama/models.

Type /bye or press Ctrl + D to exit. To use it again, simply run the same command.

Claude Code

Claude Code is an AI programming assistant and automated programming tool that can read and understand complete codebases, edit files, run commands, and collaborate with development tools. It works in terminal, IDE, desktop application, and browser environments, helping to rapidly develop features, fix bugs, and automate development tasks. Claude Code requires a paid subscription.

Claude Code's source code is primarily written in TypeScript and runs on the Bun runtime.

Installation

  • Install using pkg:

  • Install using Ports:

Using Claude Code

Set the theme here.

Claude Code requires a subscription to use. Please log in to your account:

After logging in:

After completing the subscription, you can start using it. Press Ctrl + C twice to exit the tool.

GitHub Copilot CLI

GitHub Copilot CLI is a closed-source project by GitHub. GitHub offers a free tier (2000 code completions and 50 chat requests per month); exceeding the quota or using advanced features requires a paid subscription.

GitHub Copilot CLI integrates an AI programming assistant into the command-line environment, allowing users to write, debug, and understand code through natural language conversation, and integrate with GitHub workflows.

Installation

  • Install using pkg:

  • Install using Ports:

Using GitHub Copilot CLI

Open https://github.com/login/device in a browser, enter the one-time verification code output by Copilot, and after authorization you can use Copilot.

GitHub Copilot CLI main interface

Press Ctrl + C twice to exit the tool.

Last updated