Matching a Reader’s Interests to Guide Descriptions
Guide descriptions give us evidence even before a guide has been opened. Represent topics explicitly and compare them with a reader’s interests.
12 sections · 4 questions · 2 coding challenges
The arrow keys move between sections too.
Using the Description of an Item
BOTIE
Our guides use two hand-labelled topic coordinates so the comparison is inspectable. Real systems may use terms or learned embeddings, but the coordinate meaning and similarity assumptions still matter.
Sources for this history
Can a New Guide Be Useful Before Anyone Has Read It?
A new guide about soil moisture has no opens, so popularity puts it last. Yet it might be exactly what a reader asking about irrigation needs.
We can compare what the guide covers with what the reader wants. First we need matching topic coordinates, then a similarity rule whose treatment of length we understand.
The profile and description coordinates are supplied illustrative features.
Step 1 of 3
Use the same coordinates
Both vectors order topics as irrigation then lighting.
| Representation | Topic coordinate 1 | Topic coordinate 2 |
|---|---|---|
| Reader | 1 | 0 |
| Guide A | 3 | 0 |
| Guide B | 0 | 2 |
Reader
- Topic coordinate 1
- 1
- Topic coordinate 2
- 0
Guide A
- Topic coordinate 1
- 3
- Topic coordinate 2
- 0
Guide B
- Topic coordinate 1
- 0
- Topic coordinate 2
- 2
Step 2 of 3
Remove length when it is irrelevant
Cosine compares direction by normalising both vector lengths.
| Representation | Topic coordinate 1 | Topic coordinate 2 |
|---|---|---|
| Normalised A | 1 | 0 |
| Normalised B | 0 | 1 |
Normalised A
- Topic coordinate 1
- 1
- Topic coordinate 2
- 0
Normalised B
- Topic coordinate 1
- 0
- Topic coordinate 2
- 1
Step 3 of 3
Compare topic direction
The irrigation guide points along the reader’s interest.
| Guide | Cosine scores |
|---|---|
| Guide A | 1 |
| Guide B | 0 |
Guide A
- Cosine scores
- 1
Guide B
- Cosine scores
- 0
A shared feature description makes an interest comparison possible
Normalising removes length so direction drives this comparison.
Does the guide describe what this reader is interested in?
Compare the profile and guide by direction. Scale a description without changing its proportions and check whether that alone makes the guide a better match.
BOTIE
Cosine similarity between reader and guide
1
Follow the operations
1. Reader topic vector
- 01
- 10
2. Guide topic vector
- 03
- 10
3. Dot product
3
4. Vector length
1
5. Vector length
3
6. Multiply
3
7. Divide
1
8. Result
1
Requires nonzero vectors with matching feature meanings. A score is not a calibrated probability.
1. Make Coordinates Comparable
The guide and reader vectors need matching coordinates. If one position means irrigation in the guide but lighting in the profile, multiplying those entries compares unrelated quantities. Use the same feature preparation and order for both.
We could build the reader profile from an explicit request or average the vectors of guides they liked. That average is a modelling choice. Someone interested in two distinct subjects may be poorly described by a point between them.
Start with labelled topic features before introducing opaque learned coordinates.
2. Choose Whether Magnitude Should Matter
A dot product rewards alignment and length. Cosine divides by both vector norms so multiplying one vector by a positive constant leaves the score unchanged.
This is helpful if magnitude reflects document length rather than relevance. It is less appropriate if magnitude intentionally expresses confidence or strength that the task needs to retain.
Cosine(a,b) = dot(a,b) / (norm(a) × norm(b))
Reader = [1,0]; guide = [3,0]
Cosine = 3 / (1 × 3) = 1A zero vector has no direction; define a fallback instead of dividing by zero.
3. Score Before Selecting
For a catalogue matrix with one guide per row, normalise each row and multiply by a normalised reader vector. The output has one score per guide. Sort those scores only after availability and exclusion rules are clear.
A high similarity is a model score, not a probability that the reader will enjoy the guide. Its numerical scale depends on the representation.
The NumPy example exposes row norms rather than hiding normalisation inside a recommendation call.
A longer description need not be a different direction
The reader and guide use the same two content features. Compare the guide with a version whose coordinates are both ten times larger.
import numpy as np
reader = np.array([1., 1.])
guide = np.array([2., 2.])
for description in [guide, 10 * guide]:
similarity = (reader @ description) / (np.linalg.norm(reader) * np.linalg.norm(description))
print(f'{similarity:.3f}')1.000
1.000Both descriptions point in the reader's direction, so scaling alone does not improve the cosine match. Practice compares several genuinely different directions.
4. Check What the Description Leaves Out
Content-based ranking can recommend a new item from its features, but cannot use a feature that was never recorded. It may also repeatedly suggest near-duplicates and fail to introduce a reader to useful unfamiliar subjects.
Evaluate on later interactions and inspect diversity and coverage alongside relevance. Cold-start readers still need an initial request or another fallback.
The workshop compares two nonzero vectors. The next lesson uses patterns shared across readers.
5. Build a Profile from the Guides a Reader Chose
A reader profile can average feature vectors from previously chosen guides. It then describes the topics represented in that history. Give recent or explicit positive choices different weights only when that weighting is part of the declared model.
Normalise before cosine comparison and handle zero-length vectors explicitly. A reader with no usable history needs a fallback or stated preferences, not a division by zero.
Compare two candidate topics with a history profile
Coordinates represent irrigation and image processing. The two previous guides both concern irrigation.
import numpy as np
history = np.array([[1.,0.],[.8,.2]])
profile = history.mean(axis=0)
candidates = np.array([[1.,0.],[0.,1.]])
score = candidates@profile/(np.linalg.norm(candidates, axis=1)*np.linalg.norm(profile))
print(np.round(score, 4).tolist())[0.9939, 0.1104]The representation favours another irrigation guide. It does not know whether the reader wants to repeat the topic or learn something new.
6. Matching Topics Does Not Establish the Right Difficulty
Two guides may have similar topic vectors while one assumes mathematics the reader has not encountered. Add explicit constraints or features for prerequisites, format and difficulty when those affect usefulness.
Inspect failures caused by missing metadata separately from failures of the similarity rule. A more elaborate similarity cannot recover a distinction absent from every coordinate. Preserve a path for new guides whose features exist before any interaction history does.
Check yourself
Questions on Parts 1 to 6
Question 1 of 4
What is cosine similarity?
Use the information below.
Reader [1,0], guide [3,0].Try it with Botie
Build with Botie
Write and run Python