Skip to main content
Goose supports local inference using llama.cpp, enabling offline usage, data privacy, and cost savings. This guide covers setup, configuration, and optimization.

Overview

Local inference allows you to:
  • Run offline: No internet required once models are downloaded
  • Preserve privacy: Data never leaves your machine
  • Eliminate API costs: No per-token charges
  • Customize models: Use fine-tuned or specialized models
  • Control resources: Manage GPU/CPU usage precisely

Quick Start

1. Install Prerequisites

macOS/Linux:
GPU Acceleration (Optional):

2. Download a Model

Goose supports GGUF format models from Hugging Face:
Models are stored in ~/.cache/goose/models/.

3. Configure Goose

4. Run Goose

Goose will automatically:
  1. Load the model into memory
  2. Allocate GPU/CPU resources
  3. Initialize the inference engine

Supported Models

Goose works with any GGUF model, but these are recommended:

Coding Models

General Purpose

Model sizes are approximate. Quantized versions (Q4, Q5, Q6) reduce memory usage at the cost of slight accuracy loss.

Quantization Levels

GGUF models come in various quantization levels: Example: Download specific quantization:

Configuration

Model Settings

Configure in ~/.config/goose/config.yaml:

Environment Variables

Memory Management

Goose automatically estimates memory requirements and adjusts context size.

Memory Estimation

From crates/goose/src/providers/local_inference/inference_engine.rs:

Memory Requirements

Typical requirements for Q5_K_M quantization:
If your prompt exceeds available memory, Goose will return an error: “Prompt exceeds estimated memory capacity”. Reduce context size or use a smaller model.

Performance Tuning

GPU Acceleration

Check GPU usage:
Optimize GPU layers:

CPU Optimization

Flash Attention

Enable for 2-3x faster inference on supported hardware:
Requires:
  • CUDA compute capability ≥ 7.0 (RTX 20 series+)
  • Metal (macOS M1+)
  • ROCm 5.0+

Tool Support

Local models support tool calling through two modes:

Native Tools (Preferred)

Models trained with native tool calling (e.g., Qwen 2.5):

Emulated Tools

For models without native support, Goose emulates tool calling:
Native tool calling is more reliable. Choose models like Qwen 2.5, Mistral, or Llama 3.1 for best results.

Sampling Strategies

Temperature Sampling (Default)

Balanced creativity and coherence:

Greedy Sampling

Always select most likely token (deterministic):

Mirostat v2

Adaptive sampling for consistent perplexity:

Troubleshooting

Model won’t load

Out of Memory (OOM)

Slow generation

Poor quality responses

Advanced: Custom Model Registry

Define custom models in ~/.config/goose/local_models.yaml:
Use it:

Implementation Details

Source Code

  • Engine: crates/goose/src/providers/local_inference/inference_engine.rs
  • Model registry: crates/goose/src/providers/local_inference/local_model_registry.rs
  • Native tools: crates/goose/src/providers/local_inference/inference_native_tools.rs
  • Emulated tools: crates/goose/src/providers/local_inference/inference_emulated_tools.rs
  • Hugging Face models: crates/goose/src/providers/local_inference/hf_models.rs

llama.cpp Integration

Goose uses the llama-cpp-2 Rust bindings:

Resources