Field notes from working through example 01 of Ardan Labs’ Ultimate AI course by Bill Kennedy and Florin Pățan (Apache 2.0). My fork: PratikDhanave/ai-training. Thank you Bill and Florin for teaching this material — the patterns in this post are derived from the course; the production reflections at the end are mine.
What the example teaches
The very first concept. Words are encoded as numeric vectors. Vectors that point in similar directions represent similar meanings. Cosine similarity measures how aligned two vectors are: 1.0 = identical direction, 0.0 = orthogonal, -1.0 = opposite.
What it looks like
// Hand-crafted 4-dim vectors
cat := []float64{0.9, 0.8, 0.1, 0.0} // animal, mammal, vehicle, finance
dog := []float64{0.85, 0.9, 0.05, 0.0}
car := []float64{0.0, 0.0, 1.0, 0.1}
simCatDog := cosine(cat, dog) // ~0.99
simCatCar := cosine(cat, car) // ~0.06
func cosine(a, b []float64) float64 {
var dot, na, nb float64
for i := range a {
dot += a[i] * b[i]
na += a[i] * a[i]
nb += b[i] * b[i]
}
return dot / (math.Sqrt(na) * math.Sqrt(nb))
}
What I learned
The hand-crafted demo is the right starting point. Going straight to “OpenAI’s embedding model produces 1536 dimensions and trust it” loses the intuition. Doing the math by hand on 4 dimensions makes the rest of the course (and every embedding-based system after) make sense.
Once you see why cosine works, you never forget. Vectors pointing in the same direction = similar meaning. Everything in retrieval, classification, recommendation is a variation of this.
Production connection
Every conversation I have about RAG, recommendation, or classification starts with this picture. It’s the foundation. The lesson holds true across every model, every framework, every year.
Credit & reference. This post is field notes on example 01 from Ardan Labs’ Ultimate AI by Bill Kennedy + Florin Pățan, licensed Apache 2.0. The original example: cmd/examples/example01-vectors/. My fork with notes: PratikDhanave/ai-training. Highly recommend the course for anyone building AI applications in Go — the material is rigorous and the Kronk + yzma + llama.cpp pipeline gives you hardware-accelerated local inference end-to-end. Thank you, Bill and Florin.