How townsendmerino/goinfer works
goinfer is a Go runtime for local open-weight language models, offered as a library, chat binary, and OpenAI/Anthropic-compatible server. Its main workflow is to accept a prompt or API request, resolve and load model assets, run inference, and return generated output; optional paths add schema-constrained output, multimodal inputs, embeddings, and tool use. The graph also shows model acquisition and CLI utilities. Several subsystem links are supported only by README statements or SOURCE INDEX references; unsampled implementations and their internal call paths are not inferred.
Main entry points: serveapp/main.go HTTP server · modelload.go Model loading · chatapp/main.go Chat CLI · session.go Model decoder
Components 20
User entrypoints
- Chat CLI
internal/chatapp/main.go - HTTP server
internal/serveapp/main.go - In-process API
server/server.go
Model runtime
- Model decoder
decoder/session.go - CUDA backend
cuda/resident.go - Metal embeddings
metal/embeddinggemma2.go
Model assets
- Model loading
internal/modelload/modelload.go - Load configuration
internal/loadflags/loadflags.go - Pull commands
internal/pullcmd/pull.go - Checkpoint retrieval
pull/pull.go - Prequantization
internal/prequant/prequant.go - Hardware fit checks
internal/fitcmd/fit.go
Serving features
- Decision CLI
internal/decidecmd/decidecmd.go - Label scoring
internal/decide/decide.go - In-process transport
internal/inproc/transport.go
Output and modalities
- Schema constraints
constrain/schema.go - Chat tool formats
chat/tools.go - Multimodal processing
multimodal/load.go - Embedding model
embeddinggemma2/model.go
Other components
- User or client
Connections 28
- User or client → Chat CLI: prompts
internal/chatapp/main.go - User or client → HTTP server: sends requests
- Chat CLI → Model loading: loads model
internal/chatapp/main.go - Chat CLI → Model decoder: generates with
internal/chatapp/main.go - Chat CLI → Schema constraints: supports schema output
internal/chatapp/main.go - Chat CLI → Pull commands: dispatches pull
internal/chatapp/main.go - Chat CLI → Hardware fit checks: dispatches fit
internal/chatapp/main.go - HTTP server → Model loading: loads models
internal/serveapp/main.go - HTTP server → Load configuration: registers options
internal/serveapp/main.go - HTTP server → Pull commands: dispatches pull
internal/serveapp/main.go - HTTP server → Model decoder: serves inference
internal/serveapp/main.go - HTTP server → Label scoring: offers label scoring
internal/serveapp/main.go - HTTP server → Multimodal processing: supports modalities
internal/serveapp/main.go - HTTP server → Embedding model: serves embeddings
internal/serveapp/main.go - In-process API → HTTP server: wraps handler
server/server.go - In-process API → In-process transport: uses transport
server/server.go - Model loading → Model decoder: loads into
internal/modelload/modelload.go - Model loading → Checkpoint retrieval: resolves assets
internal/modelload/modelload.go - Model loading → Prequantization: uses bundles
internal/modelload/modelload.go - Load configuration → Model decoder: configures
internal/loadflags/loadflags.go - Pull commands → Checkpoint retrieval: fetches checkpoints
internal/pullcmd/pull.go - Decision CLI → Label scoring: runs scoring
internal/decidecmd/decidecmd.go - Decision CLI → Model loading: loads model
internal/decidecmd/decidecmd.go - Hardware fit checks → Model loading: loads model
internal/fitcmd/fit.go - Hardware fit checks → Prequantization: uses quantization
internal/fitcmd/fit.go - Model decoder → Schema constraints: supports constrained decode
decoder/session.go - CUDA backend → Model decoder: registers backend
- Metal embeddings → Embedding model: implements acceleration
metal/embeddinggemma2.go