
"Models are born production-ready"
Born is a modern deep learning framework for Go, inspired by Burn (Rust). Build ML models in pure Go and deploy as single binaries - no Python runtime, no complex dependencies.
Pure Go ML with GPU acceleration - no CGO required!
Deploying ML models is hard: - Python runtime required - Complex dependency management - Large Docker images - Slow startup times - Integration friction with Go backends
import "github.com/born-ml/born"
// Models "born" ready for production
model := born.Load("resnet50.born")
prediction := model.Predict(image)
// That's it. No Python. No containers. Just Go.
Benefits: - Single binary deployment - Fast startup (< 100ms) - Small memory footprint - Native Go integration - Cross-platform out of the box
Release() (no GC dependency).onnx (57 operators)models/llama.LoadGGUF() for end-to-end LLaMA inference; verified on TinyLlama 1.1B Q8_0 and Q4_K_M.born format with nn.Save() / nn.Load()nn.SetSeed() for deterministic weight initialization# Clone repository
git clone https://github.com/born-ml/born.git
cd born
# Build
make build
# Or install CLI
make install
Requirements:
- Go 1.26+ (1.26 required for optional SIMD support via GOEXPERIMENT=simd)
- Make (optional, but recommended)
- golangci-lint (for linting)
Build:
make build # Build all binaries
make test # Run tests
make lint # Run linter
make bench # Run benchmarks
Working example included! See examples/mnist/ for complete implementation.
package main
import (
"github.com/born-ml/born/autodiff"
"github.com/born-ml/born/backend/cpu"
"github.com/born-ml/born/nn"
"github.com/born-ml/born/optim"
)
func main() {
// Create backend with autodiff
backend := autodiff.New(cpu.New())
// Define model (784 → 128 → 10)
model := NewMNISTNet(backend)
// Create loss and optimizer
criterion := nn.NewCrossEntropyLoss(backend)
optimizer := optim.NewAdam(model.Parameters(), optim.AdamConfig{
LR: 0.001,
Betas: [2]float32{0.9, 0.999},
}, backend)
// Training loop
for epoch := range 10 {
// Forward pass
logits := model.Forward(batch.ImagesTensor)
loss := criterion.Forward(logits, batch.LabelsTensor)
// Backward pass
optimizer.ZeroGrad()
grads := backend.Backward(loss.Raw())
optimizer.Step(grads)
// Log progress
acc := nn.Accuracy(logits, batch.LabelsTensor)
fmt.Printf("Epoch %d: Loss=%.4f, Accuracy=%.2f%%\n",
epoch, loss.Raw().AsFloat32()[0], acc*100)
}
}
Run it: cd examples/mnist && go run .
package main
import (
"fmt"
"github.com/born-ml/born/backend/cpu"
"github.com/born-ml/born/models/llama"
"github.com/born-ml/born/generate"
"github.com/born-ml/born/tokenizer"
)
func main() {
backend := cpu.New()
// Load LLaMA model from GGUF (Q4_K_M, Q8_0, F16, F32 supported)
model, _ := llama.LoadGGUF("tinyllama-1.1b.Q8_0.gguf", backend)
defer model.Release()
// Load tokenizer
tok, _ := tokenizer.NewTikTokenForModel("gpt-4")
// Create generator with sampling config
gen := generate.NewTextGenerator(model, tok, generate.SamplingConfig{
Temperature: 0.7,
TopP: 0.9,
TopK: 40,
})
// Generate text
result, _ := gen.Generate("Hello, world!", generate.GenerateConfig{
MaxTokens: 100,
})
fmt.Println(result)
// Or use streaming
stream, _ := gen.GenerateStream("Once upon a time", generate.GenerateConfig{
MaxTokens: 50,
Stream: true,
})
for chunk := range stream {
fmt.Print(chunk.Token)
}
}
Verified working: TinyLlama 1.1B Q8_0 and Q4_K_M.
Core Features: - ✅ Tensor operations (Add, MatMul, Reshape, Exp, Sqrt, Cat, etc.) - ✅ 35+ GPU operations (BatchMatMul, Conv2D, MaxPool2D, Comparisons, Reductions) - ✅ 31 type-safe public API operations (MulScalar, Greater, Softmax, Int32, etc.) - ✅ Automatic differentiation with gradient tape - ✅ Neural network modules (Linear, Conv2D, ReLU, SiLU, RMSNorm, Embedding) - ✅ Optimizers (SGD with momentum, Adam with bias correction) - ✅ Losses (CrossEntropyLoss with numerical stability) - ✅ Complete WebGPU backend (zero-CGO, 123x MatMul speedup) - ✅ Transformer primitives (for LLaMA, GPT, Mistral architectures)
Born uses a backend interface for device independence:
type Backend interface {
Add(a, b *RawTensor) *RawTensor
MatMul(a, b *RawTensor) *RawTensor
// ... other operations
}
Available Backends:
| Backend | Status | Description |
|---|---|---|
| CPU | ✅ Available | Pure Go implementation, all operations |
| WebGPU | ✅ Available | Zero-CGO GPU via gogpu/wgpu (pure Go) |
| Vulkan | 📋 Planned | Cross-platform GPU compute (Linux focus) |
| CUDA | 📋 Planned | NVIDIA GPU via zero-CGO |
| Metal | 📋 Planned | Apple GPU (macOS/iOS) |
WebGPU Operation Support 🎉
| Category | Operations | Backend |
|---|---|---|
| Math | Add, Sub, Mul, Div (float32 + int32), Exp, Sqrt, Rsqrt, Log, Cos, Sin | ✅ GPU |
| Matrix | MatMul, BatchMatMul (3D/4D), Transpose, Reshape | ✅ GPU |
| CNN | Conv2D, MaxPool2D | ✅ GPU |
| Activation | ReLU, Sigmoid, Tanh, Softmax | ✅ GPU |
| Scalar | MulScalar, AddScalar, SubScalar, DivScalar | ✅ GPU |
| Reduction | Sum, SumDim, MeanDim, Argmax | ✅ GPU/CPU hybrid |
| Compare | Greater, Lower, GreaterEqual, LowerEqual, Equal, NotEqual | ✅ GPU |
| Boolean | And, Or, Not | ✅ GPU |
| Shape | Cat, Chunk, Unsqueeze, Squeeze, Expand | ✅ CPU (efficient) |
| Selection | Where, Gather, Embedding | ✅ GPU |
| Type | Cast (float32, int32) | ✅ CPU |
Total: 38+ GPU-accelerated operations!
All operations required for LLM inference (Attention, RoPE, LayerNorm, etc.) are fully supported on GPU.
GPU Backend Setup:
The WebGPU backend uses gogpu/wgpu — a pure Go WebGPU implementation. No shared libraries, no DLLs, no CGO. Just go build and it works.
# That's it. No downloads, no system libraries.
go build ./...
Currently supported on Windows (D3D12). Linux (Vulkan) and macOS (Metal) support coming soon — gogpu/wgpu supports all three backends.
Usage:
import (
"github.com/born-ml/born/autodiff"
"github.com/born-ml/born/backend/cpu"
"github.com/born-ml/born/backend/webgpu"
)
// Automatic GPU/CPU selection with graceful fallback
var backend tensor.Backend
if webgpu.IsAvailable() {
gpu, err := webgpu.New()
if err == nil {
backend = autodiff.New(gpu)
defer gpu.Release() // Don't forget to release GPU resources
}
}
if backend == nil {
backend = autodiff.New(cpu.New())
}
Functionality composed via decorators (inspired by Burn):
// Basic backend
base := cpu.New()
// Add autodiff
withAutodiff := autodiff.New(base)
// Add kernel fusion
optimized := fusion.New(withAutodiff)
// Your code works with any backend!
model := createModel(optimized)
type Tensor[T DType, B Backend] struct {
raw *RawTensor
backend B
}
// Compile-time type checking
func (t *Tensor[float32, B]) MatMul(other *Tensor[float32, B]) *Tensor[float32, B]
Core Framework - Tensor API with generics, autodiff, NN modules (Linear, Conv2D, ReLU, etc.) - Optimizers (SGD, Adam), losses (CrossEntropyLoss) - MNIST: 97.44% MLP, 98.18% CNN accuracy
GPU Acceleration - WebGPU backend with 38+ operations (123x MatMul speedup) - Lazy evaluation, command batching (~90s → <5s/step) - CNN support (Conv2D, MaxPool2D, BatchMatMul)
LLM & Transformers - Multi-Head Attention, GQA, KV-Cache (3.94x speedup) - RoPE, ALiBi, RMSNorm, SwiGLU - Tokenizers (TikToken, BPE), text generation with streaming
Model Import & Export
- ONNX import (57 operators)
- GGUF loading (LLaMA, Mistral, DeepSeek)
- Native .born format, SafeTensors export
Quantization (v0.8.0) - GPTQ/AWQ (4x smaller), KV Cache compression, Model Zoo
Production Serving - PagedAttention, Continuous Batching, OpenAI-compatible API
Scale & Stability - Multi-GPU, CPU SIMD (AVX2/Neon), Gradient Checkpointing
v1.0 LTS - API freeze, 3+ years support, production hardening
Full roadmap & changelog: See ROADMAP.md and CHANGELOG.md
Models trained anywhere (PyTorch, TensorFlow) are imported and born production-ready:
Training → Birth → Production
(Burn) (Born) (Run)
PyTorch trains → Born imports → Born deploys
TensorFlow trains → Born imports → Born deploys
Born trains → Born ready → Born serves
go build and you're doneActual Benchmarks (AMD Ryzen 9 5950X, NVIDIA RTX 3080):
| Operation | CPU | GPU | Speedup | |-