← AI ChannelInside AIChapter 28 / 255日本語

Volume 1 / Part 3 Mechanics — What Happens Inside / Chapter 28

Close in Meaning Means Close in Coordinates

About 7 min read

Last time, we saw that words turn into numerical coordinates called vectors. But what does it actually mean for two coordinates to be "close"? This time we'll use a tool called cosine similarity to see why AI feels that 'dog' and 'cat' are near each other, while 'dog' and 'accounting' are far apart. It's a way of measuring distance that's a little different from reading a map.

So What Does "Close" Actually Mean?

In the last article, we explained that words get converted into numerical coordinates through a process called embedding. The word "dog" ends up sitting at some specific point in that coordinate space. The real question is: how does AI measure the "closeness" between those points?

In everyday life, when we say something is "close," we usually picture distance. The train station nearest your office, the corner store nearest your home. But in the world of AI, there's a measurement that looks not just at distance, but at direction.

Think of it like comparing which way two arrows are pointing. Even if they're different lengths, if they point in the same direction, we call them similar. This idea is the foundation of cosine similarity, which we'll dig into next.

When you search for "shops nearby" on a map app, straight-line distance does the job. But language doesn't work that way. A short, offhand remark and a long, detailed explanation can point at the exact same idea. You need a way of measuring that doesn't get fooled by length.

Remember this

The idea that close coordinates mean close meaning is really the heart of what embeddings are all about.

Measuring Direction — The Intuition Behind Cosine Similarity

Cosine similarity is a number that captures how much two vectors point in the same direction. The math itself isn't hard, but what matters here is understanding what it looks at — and what it deliberately ignores.

The value ranges from -1 to 1. A 1 means the directions match perfectly, 0 means they're perpendicular and unrelated, and -1 means they point in exactly opposite directions. Picture a compass needle: does it point the same way as another needle, or the exact opposite way?

What's interesting is that it ignores the size, or length, of the vectors entirely. It doesn't care whether a sentence is long or short — only whether its direction is similar. That's exactly why it's used as a tool for measuring "semantic similarity" regardless of sentence length.

Picture the hour hand and minute hand of a clock. They're completely different lengths, but when they point at the same time, they form the same angle. Cosine similarity cares only about that angle — it has no interest in the length of the hands.

Try checking this yourself sometime. If a short sentence and a long paragraph are actually talking about the same thing, cosine similarity should return a value that's genuinely close.

"Dog" and "Cat" Are Close; "Dog" and "Accounting" Are Far

In embedding space, "dog" and "cat" are both words that tend to show up in the context of pets and animals. Because of that, their coordinates tend to point in similar directions, and cosine similarity between them tends to come out high.

"Dog" and "accounting," on the other hand, almost never show up in the same context. Topics like walks and barking rarely overlap with topics like balance sheets and invoices. So their coordinates point in different directions, and the common explanation is that cosine similarity between them comes out low.

This dog/cat/accounting example isn't backed by an official published number — it's just an illustration meant to build intuition. The actual values depend heavily on which embedding model you use and what data it was trained on.

That said, the underlying idea — that semantic relationships between words can be expressed as arithmetic on coordinates — comes straight from a real paper: the 2013 word2vec paper by Mikolov and colleagues (arXiv:1301.3781). It contains the now-famous example: take "king," subtract "man," add "woman," and you land close to "queen." Relationships between words literally show up as arithmetic on coordinates.

The idea behind that paper is often summarized as: words that appear in similar contexts tend to carry similar meanings. "Dog" and "cat" both frequently show up in phrases like "keep a ___" or "the ___ makes a sound." Because they share those contexts, they end up clustered close together in coordinate space too.

Similar, But Not the Same

Here's a point worth clearing up, because it's easy to misread. A high cosine similarity does not mean two words or sentences mean exactly the same thing.

This metric only measures how close the angle, or direction, of two vectors is. Oracle's official database documentation defines cosine similarity the same way: it looks only at direction and ignores magnitude. It doesn't guarantee the kind of depth of meaning a human would perceive.

For example, the same word can carry different meanings depending on context. Does "bank" mean a financial institution, or the edge of a river? Measuring angle alone can sometimes miss these finer shades of nuance.

If you have a way to test embeddings yourself, try comparing "I deposited money at the bank" with "I sat on the river bank." Both sentences contain the same word "bank," but the overall direction of the sentence vectors might end up farther apart than you'd expect. The trick to working with this metric is not assuming two things "must be close" before you actually check.

In short, similarity isn't a stamp of perfect semantic agreement — it's a clue about whether two things are behaving in a statistically similar way. Keeping that in the back of your mind lets you hold AI's "these are similar" judgments at just the right distance.

A Use Case: Vector Search

This same cosine similarity can be applied directly to search. Convert a huge pile of documents into vectors ahead of time and store them. Then convert a query into a vector too, and look for documents whose direction is closest to the query's. That's the basic idea behind vector search.

Its strength is finding documents that are semantically similar even when the keywords don't match exactly. Search for "how often should you walk a dog" and you might get a hit on a document about "exercise needs for shiba inus," even though the wording is completely different.

In 2020, a paper by Lewis and colleagues, with affiliations including Facebook AI Research (arXiv:2005.11401), proposed combining knowledge stored inside a language model itself — so-called parametric memory — with searchable external documents, or non-parametric memory. The idea: when the model doesn't know something, let it search external documents to fill the gap.

Picture an office sitting on a mountain of internal manuals and meeting minutes. A keyword search for "meeting decisions" won't find a document that phrases things differently. Vector search, relying on semantic similarity, can pick up phrases like "the conclusion the team reached" even when the wording doesn't match at all.

This way of combining retrieval and generation became the foundation for a technique that would later get a huge amount of attention. The idea of "close coordinates" we've covered today is actually the doorway into that bigger story.

Try It Yourself

Sometimes seeing actual numbers with your own eyes sinks in more than any explanation. If you have access to a library or service that handles embeddings, try converting the words "dog," "cat," and "accounting" into vectors, and calculate the cosine similarity between each pair.

No setup? That's fine too. Just picture it in your head: an "island" where pet-related words cluster together, and a separate "island" far away where money and number words live. "Dog" and "cat" live next door to each other on the same island, while "accounting" sits on a distant island of its own.

This small experiment, or even just the mental picture, sets you up for the next chapter. Once you've got a feel for what "close coordinates" really means, it'll be much easier to understand an even deeper mechanism: how AI decides what to pay attention to within a sentence.

Remember this

Running the numbers yourself turns the fuzzy idea of "close" into something concrete.

FAQ

What's the difference between cosine similarity and Euclidean distance?

Euclidean distance measures the straight-line distance between two points, while cosine similarity only looks at the direction, or angle, of two vectors and ignores their size. Cosine similarity gets used when you want to compare meaning without being thrown off by sentence length.

If cosine similarity is high, does that mean two things mean exactly the same thing?

No. Cosine similarity is just a number representing how close two angles are — it doesn't guarantee the kind of meaning-match a human would perceive. It's safer to treat it as a clue that two things behave in statistically similar ways.

How is vector search different from regular keyword search?

Keyword search looks for matching words. Vector search converts text into vectors and finds documents with high semantic similarity, often using cosine similarity. That makes it good at finding related content even when the wording is completely different.

Once you've got a handle on coordinate closeness, the next natural question is: what does AI focus on within a sentence? Next time, we'll dig into Attention, the mechanism AI uses to decide where to look within a sentence.

Primary sources

This article organizes general knowledge based on our experience and public sources. Product specs, prices, and regulations reflect the time of writing (October 6, 2026) and may change.