---
title: "How does AI search find text that means the same thing?"
description: "A word search misses a reworded question. Give each text a list of numbers and rank by the angle between lists: the closest texts mean the same."
topic: "AI systems"
chapter: "how-ai-answers"
order: 35
minutes: { plain: 8, deep: 17 }
prerequisites: ["Reading short Python functions", "Adding and multiplying lists of numbers"]
seo_title: "How does AI search find text with the same meaning?"
date: 2026-12-02
---
# How does AI search find text that means the same thing?

A help page has nine short answers. A customer asks "Can I get my money back?" The answer is "Cancel within five days and we repay you in full.", but it shares no word with the question, and 8 of the 9 sentences share none. A search that matches words puts "Get back to the login page and sign in again." first, because it shares "get" and "back". A search by meaning puts the repay sentence first, with a closeness of 1.000. The trick is to turn every text into a short list of numbers, so that texts about the same thing get lists that point the same way, and then to find the stored lists closest to the question's list. In a toy with four numbers per text you will see it work, and see where it fails: a code such as E4410 has no meaning to match, and a speed-up that looks in fewer places can miss the best answer.

## In one minute

Think of a map of the topics in a help centre. Money is one direction, accounts another, delivery a third, opening hours a fourth. Every sentence is an arrow from the middle of the map, pointing toward the topics it talks about. A sentence about refunds points straight along "money". A sentence about a card points along money with a small lean toward accounts. A customer's question gets an arrow the same way.

To search, you do not compare words. You compare where the arrows point. Two arrows that point the same way score 1, however long they are, and two that have nothing in common score 0. The answer is the stored sentence whose arrow points most nearly the way the question's does. "Money back" and "repay" are different words, but they point the same way, so they match.

A word search is like the index at the back of a book: it finds a word only when that exact word is there. That makes it the right tool for an order number and the wrong tool for a reworded question. The map has a gap of its own. Something with no direction on the map, such as an error code, does not point anywhere, so pointing cannot find it. Good search uses both. A real system learns its map from a huge pile of text and has hundreds of directions with no names. The map here has four, named and set by hand, so you can follow every number.

## Explore the numbers

[Open the widget](https://spicyshark.co/learn/how-ai-search-finds-similar-text/widget.html). It opens on "Can I get my money back?" searched by words only. Each row is one of the nine sentences. A longer bar is a better match, and the text on the right says why. Press Meaning and the rows reorder: the repay sentence comes first. Then try the other questions. "Where is my order?" shares no word with any sentence, yet meaning finds the parcel sentence. "Code E4410" does the opposite: meaning has nothing to rank, and words find the error sentence. Meaning, one cell is the speed-up from step 5 of How it works. Press it on "Can I pay for delivery?" and see which sentences it never looks at. Open More settings to see the question as a list of numbers. Every number is picked by hand to show the mechanism; a real system learns its numbers.

## How it works

### The picture, step by step

The help-centre map, one step at a time. The next part shows the line of code behind each step, and the part after that runs the steps on real sentences.

![The question "Can I pay for delivery?" is an arrow leaning between the money axis and the delivery axis. The pay-extra sentence is a close arrow with cosine 0.962. The parcel sentence lies along the delivery axis with cosine 0.743, and the repay sentence along the money axis with cosine 0.669.](https://spicyshark.co/learn/how-ai-search-finds-similar-text/figs/angle.svg)

*Figure 1. The question and three stored sentences, drawn in two of the four topics. The green arrow is the closest to the question. The number beside each sentence is its closeness to the question.*

1. **Give each word a few numbers.** The toy has four directions: money, account, delivery and hours. Each word it knows gets one number per direction, for how much it points that way. "refund" is all money: (1, 0, 0, 0). "card" is mostly money with a little account: (0.8, 0.1, 0, 0). A word the toy has no numbers for, like "E4410", points nowhere. (A real system learns its directions and numbers from a huge amount of text. Here they are set by hand.)
2. **Give each text one arrow.** Add up the numbers of its words, direction by direction, then scale the result so the arrow has length 1. Scaling keeps a long text from winning just for being long. The question gets its arrow the same way. (Engineers call this list of numbers an embedding.)
3. **Measure the angle between two arrows.** Multiply the matching numbers of the two lists and add them up, which is called the dot product, then divide by the two lengths. The answer is 1 for arrows that point the same way and 0 for arrows with nothing in common. It is called the cosine, because it is the cosine of the angle between the arrows. When both arrows have length 1, nothing is left to divide by, and the dot product alone is the score.
4. **Score every stored text and keep the best.** The stored arrows are made once, ahead of time. For each question, score the question's arrow against every stored arrow, sort from best to worst and keep the top few. This is called nearest-neighbour search: the nearest stored arrow is the best match.
5. **For a huge store, look in fewer places.** Scoring everything costs the number of texts times the numbers in each list, for every question. So big systems sort the arrows into groups, called cells, ahead of time, and score only the cells nearest the question. That is faster, and sometimes it misses the true best.

### Each step in code

One real line of the lesson's code does each step. The files are in `code/`, and the line numbers are those of this lesson's files.

| Step | The code line | What it does |
|---|---|---|
| 1. Numbers for a word | `embed_search.py:15`<br>`"refund": (1.0, 0.0, 0.0, 0.0),` | The table `WORD_VECTORS` holds one list of four numbers per word, in the order of `TOPICS` (money, account, delivery, hours). A word missing from the table is skipped in step 2, by the `.get(w, ())` on line 109. |
| 2. One arrow per text | `embed_search.py:112`<br>`return tuple(x / size for x in total) if size else tuple(total)` | Line 110 adds each known word's list into `total`, and line 111 sets `size` to the length of `total`. This line divides every number by `size`, so the new length is 1. If no word is known, `size` is 0 and the list stays all zeros. |
| 3. The angle | `embed_search.py:102`<br>`return dot(a, b) / (length(a) * length(b))` | `dot` multiplies matching numbers and adds them. `length` is the square root of the sum of the squares. Lines 100 and 101 return 0.0 for an all-zero list, which would otherwise divide by zero. |
| 4. Score all, keep the best | `embed_search.py:118`<br>`return sorted(scored, key=lambda pair: (-pair[1], pair[0]))[:k]` | `scored` (line 117) holds `(index, cosine)` for every stored list. This line sorts the best first, and on a tie the earlier sentence first, then keeps the first `k`. |
| 5. Look in fewer places | `embed_search.py:145`<br>`order = sorted(range(len(query_vector)), key=lambda c: (-query_vector[c], c))[:probes]` | In the toy a cell is a topic: a stored list belongs to the topic where its largest number sits (`cell_of`, lines 135 to 137). This line picks the `probes` topics the question leans on most. Line 146 collects the sentences in those cells, and `cell_search` (line 149) scores only those. |

### A real run

`show_numbers.py` runs the steps on the nine sentences. It calls the same functions as the table and only prints what they return. Run it from the lesson's folder:

```bash
cd code && uv run --no-project python show_numbers.py
```

```text
1. Words only. Question: "Can I get my money back?"
   content words: get, money, back
   2 shared  Get back to the login page and sign in again.  (get, back)
   0 shared  Cancel within five days and we repay you in full.  (none)
   0 shared  A refund reaches your card in five days.  (none)
   sentences sharing no word with the question: 8 of 9

2. Meaning. Same question, closest 4 sentences (cosine):
   1.000  Cancel within five days and we repay you in full.
   0.998  A refund reaches your card in five days.
   0.970  Error E4410 means your payment failed.
   0.835  Pay extra for fast delivery with your card.

3. One comparison by hand: the question and the refund sentence
   topics: money, account, delivery, hours
   question words the toy knows: money -> (1.000, 0.000, 0.000, 0.000)
   sentence words the toy knows: refund, card -> (0.998, 0.055, 0.000, 0.000)
   sentence before scaling: (1.800, 0.100, 0.000, 0.000) length 1.803
   dot = 0.998, lengths = 1.0 and 1.0, cosine = 0.998

4. Length does not change the cosine
   dot = 5.0, cosine = 1.0
   sharing nothing: cosine = 0.0

5. Every question: best sentence by words, best by meaning
   Can I get my money back?
      words   2 shared: Get back to the login page and sign in again.
      meaning 1.000: Cancel within five days and we repay you in full.
   I lost my password
      words   1 shared: Forgot your password? We can send a new one.
      meaning 0.998: Get back to the login page and sign in again.
   When are you open?
      words   1 shared: The shop is open from nine to five.
      meaning 1.000: Opening times are nine to five on weekdays.
   Where is my order?
      words   no shared word
      meaning 0.976: Your parcel ships within two days.
   Code E4410
      words   1 shared: Error E4410 means your payment failed.
      meaning 0.000, nothing to rank
   Can I pay for delivery?
      words   2 shared: Pay extra for fast delivery with your card.
      meaning 0.962: Pay extra for fast delivery with your card.

6. A question with no word the toy knows
   vector: (0.000, 0.000, 0.000, 0.000)  cosines: [0.0]

7. How many multiplications one question costs (documents x list length)
           9 x   4 =          36
       1,000 x 768 =     768,000
   1,000,000 x 768 = 768,000,000

8. Looking only in the closest cell(s). Question: Can I pay for delivery?
   all 9: best is Pay extra for fast delivery with your card. at 0.962
   1 cell : compared 1, best is Your parcel ships within two days. at 0.743
   2 cells: compared 5, best is Pay extra for fast delivery with your card. at 0.962
```

Read it against the five steps.

- **Steps 1 and 2, the question.** "money" is the only word of the question the toy has numbers for, so the question's list is (1.000, 0.000, 0.000, 0.000): all money. "get" and "back" have no numbers, but the word search in section 1 counts them anyway.
- **Steps 2 and 3, by hand.** The refund sentence has two known words, "refund" and "card", which add up to (1.800, 0.100, 0.000, 0.000), a list of length 1.803. Dividing by 1.803 gives (0.998, 0.055, 0.000, 0.000), a list of length 1. The dot product with the question's list is 1.000 x 0.998 + 0.000 x 0.055, which is 0.998. Both lengths are 1, so the cosine is 0.998 too.
- **Words against meaning.** In section 1 the content words of the question are get, money and back. Only the login sentence has any of them, 2 shared, so it ranks first. The other 8 sentences share nothing, including the one that answers. In section 2 the repay sentence comes first with 1.000, because "repay" and "money" have the same list, then the refund sentence with 0.998. Figure 2 shows both searches as bars.
- **Close is not the same as correct.** Third by meaning, at 0.970, is "Error E4410 means your payment failed." It is about money, so it points nearly the way the question does, but it does not answer it. A score says how alike two arrows are, not whether a text answers the question.
- **Length (section 4).** The list (1, 0, 0, 0) and the same list five times as long, (5, 0, 0, 0), have a dot product of 5.0 and a cosine of 1.0. The dot product grows with length and the cosine does not. Lists that share no direction score 0.0.
- **The six questions (section 5).** Each search finds a sensible sentence for some questions and misses for others. For "When are you open?", words find the shop sentence through "open" and meaning finds the opening-times sentence at 1.000. That sentence says "Opening", and this word search does not cut "Opening" back to "open". Both are sensible. "Where is my order?" shares no word with any sentence, and meaning finds the parcel sentence at 0.976. For "I lost my password", words find the forgot-password sentence and meaning finds the login sentence, which shares no word with the question. Both are sensible.
- **The unknown code (section 6).** "Code E4410" has no word the toy has numbers for, so its list is all zeros, and the only cosine any sentence gets is 0.0. Meaning cannot choose between the nine sentences, while the word search in section 5 finds the error sentence.
- **The cost (section 7).** With stored lists of length 1, a score is a dot product: one multiplication per number. Comparing the question with 9 sentences of 4 numbers is 9 x 4 = 36 multiplications. For 1,000 texts of 768 numbers it is 768,000, and for 1,000,000 texts it is 768,000,000, for every question.
- **The speed-up (section 8).** The question "Can I pay for delivery?" leans more toward delivery than toward money (Figure 1), so one cell means looking only in the delivery cell. It holds 1 sentence, the parcel one, at 0.743, while the best of all 9 scores 0.962. Two cells compare 5 sentences and find the best again. That is the trade: fewer comparisons, and sometimes the best is missed.

![For the question "Can I get my money back?", two columns of bars over the nine sentences. By shared words, only the login sentence has a bar, with 2 shared words. By cosine, the repay sentence is longest at 1.000, then the refund sentence at 0.998 and the payment error sentence at 0.970.](https://spicyshark.co/learn/how-ai-search-finds-similar-text/figs/ranking.svg)

*Figure 2. Sections 1 and 2 of the run as bars, one row per sentence. Green marks the top match of each search.*

The sentences, scores and lists are a toy. A real system makes hundreds of numbers per text, and learns them instead of having them picked by hand.

## Your turn

The toy has no numbers for "cash", so a question that uses it gets an all-zero list. Teach it the word.

1. In `code/embed_search.py`, add the line `"cash": (1.0, 0.0, 0.0, 0.0),` inside `WORD_VECTORS`, next to the other money words.
2. From the `code` folder run `uv run --no-project python embed_search.py "Can I get my cash back?"` before and after the change.

Look at the three scores before the change. Then look at which sentences come first after it, and at whether the third one answers the question.

<details>
<summary>What you should see</summary>

Before the change:

```text
question: Can I get my cash back?
  0.000  Cancel within five days and we repay you in full.
  0.000  A refund reaches your card in five days.
  0.000  Forgot your password? We can send a new one.
```

After the change:

```text
question: Can I get my cash back?
  1.000  Cancel within five days and we repay you in full.
  0.998  A refund reaches your card in five days.
  0.970  Error E4410 means your payment failed.
```

Before, no word of the question had numbers, so all nine cosines were 0.0 and the first three sentences came out in list order. After, "cash" has the same list as "money", so the question gets the same top three as "Can I get my money back?" in the run above. The third is the error message again: close in meaning, not an answer.

</details>

## What this means when you build

- **Use both searches.** Meaning finds a reworded question and words find an exact string. In the toy, "Where is my order?" is found only by meaning, and "Code E4410" only by words. Real systems often run both and merge the two rankings, which is called hybrid search.
- **Make questions and texts the same way.** Two lists can be compared only if the same embedding model made both, with the same count of numbers. The fourth number of one model means nothing next to the fourth of another. When you change models, make every stored list again.
- **Read a score as "alike", not "right".** The third hit for the money question scores 0.970 and is an error message. Choose how many results to keep, and a cutoff, by trying real questions, as in [How do I check my AI's answers with a small test set?](https://spicyshark.co/learn/check-ai-answers-with-a-test-set/). Do not copy a cutoff from another system: scores from different models are on different scales.
- **Embed short passages, not whole pages.** One list for a long page is a blend of all its topics, like the arrow of the "Pay extra" sentence in Figure 1, which points between money and delivery. A question about one topic then points only part of the way toward it. Split long documents into short passages first.
- **Count the scan.** Brute force costs texts times numbers per list for every question: 768,000 multiplications for 1,000 texts and 768,000,000 for 1,000,000. The first needs no shortcut. The second is where approximate search pays off. Storing the lists also takes memory in proportion.
- **Measure what the shortcut misses.** A speed-up can skip the best text, as one cell does for "Can I pay for delivery?": the parcel sentence at 0.743 instead of the best at 0.962. Run the full scan on real questions, count how often the shortcut returns the same top result, and search more cells until that is high enough.

## Go deeper

*Optional. This part is for readers who write Python. The code is in the `code/` folder next to this lesson. From inside that folder, `uv run --no-project python show_numbers.py` prints the numbers above, and `uv run --no-project --with pytest python -m pytest -q -p no:cacheprovider` runs the tests (the widget tests also need Node.js). The scripts run on plain `python3` too.*

### The formula

```text
cosine(a, b) = (a1 x b1 + a2 x b2 + ...) / (length(a) x length(b))
length(a)    = square root of (a1 x a1 + a2 x a2 + ...)
```

Draw two lists as arrows from the same point. Their dot product equals length(a) times length(b) times the cosine of the angle between them, so dividing by the two lengths leaves the cosine. When every number is 0 or more, as in the toy, the score runs from 0 to 1. Real lists can point apart and score below 0.

If both lists have length 1, the cosine is the dot product, and the squared straight-line distance between them is 2 minus 2 times the cosine. So the closest list by distance is also the best by cosine, which is why a search can be described either way. `embed` scales every list to length 1 for this reason: it makes the score cheap.

### The code

The word search is a set of shared words after dropping filler words:

```python
def words(text):
    return re.findall(r"[a-z0-9]+", text.lower())


def content_words(text):
    return [w for w in words(text) if w not in STOP_WORDS]


def shared_words(query, doc):
    """The content words that the question and the document have in common, in the question's order."""
    doc_words = set(content_words(doc))
    seen = []
    for w in content_words(query):
        if w in doc_words and w not in seen:
            seen.append(w)
    return seen
```

`words` lowercases and splits on anything that is not a letter or digit, which is why "E4410" is one word. It never cuts "Opening" back to "open".

The text-to-list step adds the lists of the known words and scales the sum to length 1:

```python
def embed(text):
    """Add up the lists of the words the toy knows, then scale the result to length 1."""
    total = [0.0] * len(TOPICS)
    for w in words(text):
        for i, x in enumerate(WORD_VECTORS.get(w, ())):
            total[i] += x
    size = length(total)
    return tuple(x / size for x in total) if size else tuple(total)
```

`WORD_VECTORS.get(w, ())` returns an empty tuple for an unknown word, so the inner loop adds nothing. If no word is known, `size` is 0, and the all-zero list comes back unscaled instead of dividing by zero.

The score and the ranking:

```python
def length(v):
    return math.sqrt(sum(x * x for x in v))


def dot(a, b):
    return sum(x * y for x, y in zip(a, b))


def cosine(a, b):
    """1 when two lists point the same way, 0 when they share nothing, whatever their lengths."""
    if length(a) == 0 or length(b) == 0:
        return 0.0
    return dot(a, b) / (length(a) * length(b))
```

```python
def nearest(query_vector, vectors, k):
    """Score every stored vector against the question and keep the k best: (index, cosine), best first."""
    scored = [(i, cosine(query_vector, v)) for i, v in enumerate(vectors)]
    return sorted(scored, key=lambda pair: (-pair[1], pair[0]))[:k]
```

`cosine` divides by both lengths so it works on any two lists. For stored lists that are already length 1, a real system skips the division and the square roots and computes only the dot product. The toy keeps the division so the same function can compare the lists of length 5 and 1 in section 4 of the run.

The cell shortcut:

```python
def cell_of(v):
    """A toy cell: the topic where the list is largest."""
    return max(range(len(v)), key=lambda i: v[i])


def cells_checked(query_vector, vectors, probes):
    """The indexes in the `probes` cells whose topic the question leans on most, cell by cell."""
    cells = {}
    for i, v in enumerate(vectors):
        cells.setdefault(cell_of(v), []).append(i)
    order = sorted(range(len(query_vector)), key=lambda c: (-query_vector[c], c))[:probes]
    return [i for c in order for i in cells.get(c, [])]


def cell_search(query_vector, vectors, probes):
    """Compare the question only with the vectors in those cells. Returns (best index, how many were compared)."""
    scanned = cells_checked(query_vector, vectors, probes)
    best = max(scanned, key=lambda i: (cosine(query_vector, vectors[i]), -i)) if scanned else None
    return best, len(scanned)
```

`probes` is how many cells to search. In section 8 of the run, 1 probe compares 1 sentence and 2 probes compare 5. Searching all four cells is the full scan, which a test checks.

### What the code costs

Each stored list needs one multiplication per number to score against the question, so a full scan costs texts times numbers: 9 x 4 = 36 for the toy, 768,000 for 1,000 texts of 768 numbers, and 768,000,000 for 1,000,000. The cost grows in step with the store, and with the length of each list.

A cell search pays for the cells it looks in. The toy builds its cells inside `cells_checked` on every call, to stay short. A real system builds them once, when it stores the lists, by grouping lists that lie close together, and keeps a short list of cell centres to find the nearest cells to a question. Some systems use a different shortcut, linking each list to its near neighbours and walking from list to list toward the question. Both give up the guarantee of the full scan for speed, and the number of cells or steps is the knob.

### What the toy leaves out, in detail

- **The numbers are picked by hand.** A real embedding model learns its numbers from text, and it reads the whole text, so a word can get different numbers in two sentences ("bank" of a river and a bank account) and word order matters. The toy only adds up fixed word lists, so "refund card" and "card refund" give the same list.
- **Four named directions.** A real list has hundreds of numbers, and no single one means "money". Only the angle between whole lists carries meaning.
- **An unknown word is a cliff.** In the toy it adds nothing. A real model cuts text into pieces first (see [What is a token, and why is AI priced per token?](https://spicyshark.co/learn/what-is-a-token/)), so it always gives some list, but codes and rare names are usually where it is weakest, and where word search is strongest.
- **The word search is simpler than a real one.** It has no stemming, so "open" does not match "Opening", and it counts every shared word equally. Real word search can cut words back to a stem and give rare words more weight. It still cannot connect "money" to "repay".
- **Scores have no common scale.** 0.970 means "alike for this toy". The same number from another model means something else.
- **A different meaning of the word.** The token table inside a model is also called its embeddings, and it is a different thing from the list of numbers for a whole text.
- **Stored lists are made once.** `rank_meaning` makes the stored lists again on every call, to keep the code short.

### Proof it works

`test_embed_search.py` pins the toy to the lesson. One table holds the six questions of section 5: for each, the sentence a word search puts first with its count of shared words, and the sentence meaning puts first with its cosine. Other tests check that a cosine ignores length, that every known sentence gets a list of length 1, that the squared distance between two lists of length 1 equals 2 minus 2 times their cosine, that a sum ignores word order, that "Code E4410" gets an all-zero list, and that one cell compares 1 sentence and misses the best while two cells compare 5 and find it. Four more tests read this page. The output block in A real run must equal what `show_numbers.py` prints, and each line number cited in the table and in the text must point at the line it names. Each Python block above must appear word for word in `embed_search.py`. The two outputs in Your turn must equal what the script prints before and after the edit, which the test makes on a copy. The figures must equal what `make_figs.py` draws, with every decimal of their alt text drawn in them.

`test_widget.py` checks the page. A script that runs the widget's own JavaScript in Node must agree with the Python toy to 1e-12 on every list and score, and exactly on every order and list of shared words. A second script presses every question in every mode and compares what the page shows with the toy's ranking.

You can also check one number with a calculator. Section 3 of the run shows the refund sentence before scaling, (1.800, 0.100, 0.000, 0.000). Its length is the square root of 1.800 x 1.800 + 0.100 x 0.100, which is 1.803, and 1.800 divided by 1.803 is 0.998.

### Where this is used in practice

Meaning search is the lookup step behind a chatbot that answers from your own documents: the question is turned into a list, the closest stored passages are found, and they are placed in the prompt so the model can answer from them. It also finds duplicate support tickets, similar products and related articles. Published work covers each step of this lesson: how lists for words are learned from text, how passages for question answering are found with lists instead of words, and how approximate indexes keep the search fast on very large stores. The papers are in Further reading.

## Skills this lesson builds

- Explain why a search on words misses a reworded question and a search on meaning does not.
- Say what an embedding is, and work out the cosine of two short lists by hand.
- Explain why lists are scaled to length 1 and what the cosine ignores.
- Write nearest-neighbour search in plain Python and count its cost: texts times numbers per list.
- Say what an approximate search gives up, and when to keep a word search beside meaning search.

**Portfolio project:** take a small set of short help sentences from a product you know, and a handful of questions that reword them. Pick four to six topics and give numbers to the words you need. Build both searches, and for each question report the best sentence by words and by meaning, and whether each is right. Add a few questions with codes or names and show which search finds them. Publish the table and a note on what you would change to use a real embedding model.

## Check yourself

1. In your own words, why does a word search not find "Cancel within five days and we repay you in full." for "Can I get my money back?", and how does meaning search find it?
   <details><summary>Answer</summary>The two share no word. The toy gives "money" and "repay" the same list, (1, 0, 0, 0), so the arrows point the same way and the cosine is 1.000. The word search puts the login sentence first instead, because it shares "get" and "back".</details>
2. A text's list before scaling is (1.800, 0.100, 0.000, 0.000). What is its length, and what does scaling give?
   <details><summary>Answer</summary>The length is the square root of 1.800 x 1.800 + 0.100 x 0.100, which is 1.803. Dividing each number by it gives (0.998, 0.055, 0.000, 0.000), a list of length 1.</details>
3. A list (1, 0, 0, 0) is compared with (5, 0, 0, 0). What are the dot product and the cosine, and which one would rank a long text above a short one for no good reason?
   <details><summary>Answer</summary>The dot product is 5.0 and the cosine is 1.0. The dot product grows with length, so it would favour a long text. The cosine divides the length out, and scaling every list to length 1 does the same.</details>
4. "Code E4410" gets 0.000 from every sentence by meaning. Why, and what finds the right sentence?
   <details><summary>Answer</summary>The toy has numbers for no word of it, so its list is all zeros and every cosine is 0.0. A word search finds the sentence "Error E4410 means your payment failed." because it shares E4410. That is why a system keeps both searches.</details>
5. A store has 1,000,000 texts with 768 numbers each. How many multiplications does one full scan take, and how many for 1,000 texts? What does the one-cell shortcut give up in the toy?
   <details><summary>Answer</summary>1,000,000 x 768 is 768,000,000, and 1,000 x 768 is 768,000. In the toy, one cell compares 1 of 9 sentences and returns the parcel sentence at 0.743, missing the best one at 0.962. Two cells compare 5 sentences and find it again.</details>

## Further reading

Web pages were read on 2026-12-02; they change.

**Gentle**
- [Cosine similarity](https://en.wikipedia.org/wiki/Cosine_similarity) (encyclopedia article)
- [Word embedding](https://en.wikipedia.org/wiki/Word_embedding) (encyclopedia article)
- [Nearest neighbor search](https://en.wikipedia.org/wiki/Nearest_neighbor_search) (encyclopedia article)
- [Okapi BM25](https://en.wikipedia.org/wiki/Okapi_BM25) (encyclopedia article on a common word-matching ranking)

**Deep**
- [Efficient Estimation of Word Representations in Vector Space](https://arxiv.org/abs/1301.3781) (paper, 2013)
- [Dense Passage Retrieval for Open-Domain Question Answering](https://arxiv.org/abs/2004.04906) (paper, 2020)
- [Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs](https://arxiv.org/abs/1603.09320) (paper, 2016)
- [Billion-scale similarity search with GPUs](https://arxiv.org/abs/1702.08734) (paper, 2017)
