Machine learning models are rapidly becoming more capable; how can we make use of these powerful new tools in our Go applications? For top-of-the-line commercial LLMs like ChatGPT, Gemini or Claude, the models are exposed as language agnostic REST APIs. We can hand-craft HTTP requests or use client libraries (SDKs …
Go 1.23 shipped with a new major feature: ranging over functions (also known as "iterators"), per this proposal. This feature is nicely covered in the official Go blog post from August. This article is a rewrite of my older post that described this feature when it was still in …
When learning the basics of quantum computing, the Bloch sphere comes early on as a visualization technique of quantum states. It shows the state of a single qubit as a point on this sphere: This post explains how the Bloch sphere works and also why it works. Mapping 4 dimensions …
In this quick post I'll dispel a common confusion in the basic math of complex numbers. It's often useful to calculate the norm-square (also known as absolute square) of a complex number z. This norm-square is denoted |z|^2. One could naively expect that: \[|z|^2=zz\] However, that's false …
Recently I've had to compile Go to WebAssembly to run in the browser in a couple of small projects (#1, #2), and in general spent some time looking at WebAssembly. I find WebAssembly to be an exciting technology, both for the web and for other uses (e.g. with WASI …
This is Part 4 in a series of posts describing the Raft distributed consensus algorithm and its complete implementation in Go. Here is a list of posts in the series: Part 0: Introduction Part 1: Elections Part 2: Commands and log replication Part 3: Persistence and optimizations Part 4: Key …
Linearizability is a strong consistency model in concurrent and distributed systems. From the paper introducing it [1]: Linearizability provides the illusion that each operation applied by concurrent processes takes effect instantaneously at some point between its invocation and its response. On first reading (and probably on the second and third …
"A City on Mars" By Kelly and Zach Weinersmith - actual discussion of building settlements on Mars occupies maybe 1% of this book. The authors have an uncanny talent of focusing on all the least interesting aspects of space exploration; whatever little is dedicated to science and engineering is fairly shallow …
I've been really enjoying following Simon Willison's blog posts recently. Simon shows other programmers the way LLMs will be used for code assistance in the future, and posts full interactions with LLMs to build small tools or parts of larger applications. A recent post caught my attention; here Simon got …
The Euler formula states that for any real x: \[e^{ix}=cos(x)+i sin(x)\] Where i is the imaginary unit. This formula is extremely important in many branches of mathematics and engineering, but at first glance it's puzzling. What does a complex exponent even mean, and how can …
Earlier this year I wrote a post about implementing BPE tokenization in Go, which made it possible to reproduce OpenAI's tokenizer. Today I want to mention a new project I've been hacking on recently: go-sentencepiece - a pure Go implementation of the SentencePiece tokenizer that's used for Google AI's models like …
One of Go's advantages is being able to produce statically-linked binaries [1]. This doesn't mean that Go always produces such binaries by default, however; in some scenarios it requires extra work to make this happen. Specifics here are OS-dependent; here we focus on Unix systems. Basics - hello world This post …
A Maclaurin series is a power series - a polynomial with carefully selected coefficients and an infinite number of terms - used to approximate arbitrary functions with some conditions (e.g. differentiability). The Maclaurin series does this for input values close to 0, and is a special case of the Taylor series …