Ch 6 · Similarity — How AI Finds "Related" Things · AI & LLM Literacy
Topic 6 of 7 in AI & LLMs — How They Actually Work — 2 lessons.
Turning Sentences Into Vectors
How does AI know two sentences are "about the same thing"? It turns text into vectors (lists of numbers) so that similar meanings point in similar directions. The simplest version is bag-of-words: count how often each vocab word appears. Let's build the vectors first.
Cosine Similarity
To compare two vectors we measure the cosine of the angle between them: 1.0 means identical direction (very similar), 0.0 means unrelated. This is the seed of embeddings and AI-powered search.