How magomedcoder/gogguf works
GoGGUF is a Go library and HTTP service for loading GGUF language models and running inference, with a CLI and a Vue chat UI. The main path is model file → GGUF reader and weights → tokenizer/model runtime → generation or embeddings → CLI or HTTP response. The README documents chat templates, supported model families, quantized operations and CUDA offload. Some implementation details are unsampled; edges based on those capabilities cite the README rather than implying inspected call paths.
Main entry points: engine.go Inference engine · detect.go Model selection · store.go Weight store · backend.go GPU backend
Components 26
Model ingestion
- GGUF reader
pkg/format/reader.go - Weight store
pkg/weights/store.go - Tokenizer
pkg/tokenizer/tokenizer.go
Inference engine
- Model selection
pkg/model/detect.go - Qwen3 model
pkg/model/qwen3/model.go - Mistral model
pkg/model/mistral/model.go - DeepSeek model
pkg/model/deepseek/model.go - DeepSeek2 model
pkg/model/deepseek2/model.go - Other model families
pkg/model/llama/model.go - Inference engine
pkg/runtime/engine.go - Inference context
pkg/runtime/context.go - Generation session
pkg/runtime/session.go - Tensor operations
pkg/ops/ops.go
User interfaces
- CLI commands
cmd/gogguf/run.go - HTTP API
server/server.go - Web chat UI
web-ui/src/components/ChatView.vue
Compute backends
- GPU backend
pkg/gpu/backend.go - Multi-GPU
pkg/gpu/multi.go - CUDA backend
pkg/gpu/cuda/backend.go - CUDA driver
pkg/gpu/cuda/driver.c - CPU backend
pkg/gpu/cpu.go
Chat and sampling
- Sampling chain
pkg/sampler/chain.go - Chat templates
pkg/chat/template.go
Other components
- User
- GGUF file
- HTTP client
Connections 37
- User → CLI commands: runs commands
README.md - User → Web chat UI: chats through
README.md - User → HTTP client: sends requests
README.md - GGUF file → GGUF reader: parsed by
README.md - GGUF reader → Weight store: supplies tensors
pkg/weights/store.go - GGUF reader → Tokenizer: provides metadata
pkg/tokenizer/tokenizer.go - Inference engine → GGUF reader: opens model
pkg/runtime/engine.go - Inference engine → Model selection: loads model
pkg/runtime/engine.go - Inference engine → Tokenizer: creates tokenizer
pkg/runtime/engine.go - Model selection → Qwen3 model: selects family
- Model selection → Mistral model: selects family
- Model selection → DeepSeek model: selects family
- Model selection → DeepSeek2 model: selects family
- Model selection → Other model families: selects family
- Qwen3 model → Weight store: reads weights
pkg/model/qwen3/model.go - Mistral model → Weight store: reads weights
pkg/model/mistral/model.go - DeepSeek model → Weight store: reads weights
pkg/model/deepseek/model.go - DeepSeek2 model → Weight store: reads weights
pkg/model/deepseek2/model.go - Qwen3 model → Tensor operations: computes with
pkg/model/qwen3/model.go - Mistral model → Tensor operations: computes with
pkg/model/mistral/model.go - DeepSeek model → Tensor operations: computes with
pkg/model/deepseek/model.go - DeepSeek2 model → Tensor operations: computes with
pkg/model/deepseek2/model.go - Inference engine → Inference context: creates context
pkg/runtime/context.go - Inference context → Generation session: starts generation
pkg/runtime/session.go - Generation session → Sampling chain: chooses tokens
pkg/runtime/session.go - Generation session → Tokenizer: encodes and decodes
pkg/runtime/session.go - Inference context → Inference engine: uses model
pkg/runtime/context.go - CLI commands → Inference engine: loads and runs
cmd/gogguf/run.go - CLI commands → Chat templates: formats chat
cmd/gogguf/run.go - HTTP API → Inference engine: serves inference
server/server.go - HTTP client → HTTP API: calls endpoints
README.md - Web chat UI → HTTP API: calls API
- Inference engine → GPU backend: opens backend
pkg/runtime/engine.go - GPU backend → Multi-GPU: may dispatch
- GPU backend → CUDA backend: may dispatch
- CUDA backend → CUDA driver: uses driver
pkg/gpu/cuda/driver.c - GPU backend → CPU backend: uses CPU path