Pidoku
6AI in Go

Archive

This learning material is in the archive. It is not currently maintained and has not been updated with the latest information, so tool versions, prices and dates may be out of date.

AI in Go

Module 69 lessons~9h 15m

Lessons, in order

6.a Go in the AI StackAn AI system has two very different kinds of code. The numerical core — training loops and tensor kernels — runs on GPUs through C++, CUDA and Python, and Go is not the language for it. … 40 min 6.b Tensors and MatmulA tensor is a block of numbers with a shape. In memory it is always the same thing: one flat []float32 plus the shape that says how to interpret it. Element [i][j][k] of a tensor of shape … 1h 5m 6.c A Neural Network from ScratchA neural network is a function built from layers. Each layer multiplies its input by a matrix of weights, adds a bias, and applies a simple non-linear function. Running the layers in order … 1h 10m 6.d A TokenizerA model consumes integers, not text. A tokenizer maps text to a sequence of token IDs and back. Modern LLM tokenizers use byte-pair encoding (BPE): start with the 256 possible bytes as the … 55 min 6.e A Transformer Forward PassA large language model is a function from a sequence of token IDs to a score for every possible next token. Inside, each token is a vector that passes through a stack of identical layers. … 1h 30m 6.f Calling LLMsCalling a language model is an HTTP request with a JSON body and, usually, a streamed response. The mechanics are simple. Doing it well is four things: stream so users see output immediately … 1h 6.g Embeddings and Vector SearchAn embedding is a vector — a few hundred to a few thousand float32s — produced by a model so that texts with similar meaning land close together. Search by meaning then becomes geometry: … 1h 6.h Serving Models from GoA model is expensive to call and cheap to call wider: running sixteen inputs together costs little more than running one. A serving layer exploits that with dynamic batching — hold each … 1h 5m 6.i A Tool-Calling LoopA model can only produce text. It becomes able to do things when your program offers it tools — functions described by a name, a purpose and a JSON schema for their arguments — and runs a … 50 min

About this module

Everything so far, applied. This module builds the core pieces of an AI system in Go using nothing but the standard library: the arithmetic, a network that learns, a tokenizer, a transformer that generates, and the services around them.

None of it is meant to replace PyTorch or a production inference engine. It is meant to make those systems legible — and to show where Go genuinely is the right tool: the clients, servers, schedulers and pipelines around the model.

#LessonThe question it answers
6.aGo in the AI StackWhere does Go fit, and what exists today?
6.bTensors and MatmulHow is a tensor stored, and how fast can pure Go multiply matrices?
6.cA Neural Network from ScratchHow does a network compute, and how does it learn?
6.dA TokenizerHow does text become integers and back?
6.eA Transformer Forward PassWhat does an LLM compute for each token, and what does the KV cache save?
6.fCalling LLMsHow do I call a model API robustly: streaming, retries, structured output?
6.gEmbeddings and Vector SearchHow do I find the nearest vectors among a million?
6.hServing Models from GoHow do I batch requests and apply backpressure in front of a model?
6.iA Tool-Calling LoopWhat is the loop at the heart of an agent?

When you finish you can read an inference engine’s source and recognize every part, and you can build the Go services that surround a model in production.

Where a lesson stops, Inference Engineering continues: its projects build a full engine, continuous batching, a KV-cache manager and a gateway — also in Go.

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in