← All Base Form Math projects
BM-01NOT STARTEDBASE FORM · LINEAR ALGEBRAMATHPYTHON

Note finder

Type a question and get your most similar notes from a folder of Markdown files. Every note becomes a word-count vector; similarity is the angle between vectors.

EST.4 h
REWARD+100 XP
AFTERoriginal

ML-ARENA BENCHMARKS

YOUR NUMBER VS THE INDUSTRY'S
METRICINDUSTRYMINE
top-5 matches for 20 queries
GOAL · identical top-5 lists
sklearn cosine_similarity—
no results yet
YOUR RESULTS

Your recorded results appear here.

Brief

You will build a small search tool for your own notes. Type a question, and it prints the five notes that are most similar. No search engine, no machine learning library. Just vectors and one formula.

A vector here is a list of numbers, one per word you know about. A note that says "python" three times and "matrix" once becomes a vector with a 3 in the "python" slot and a 1 in the "matrix" slot. Stack every note's vector as one row and you have a 2-D array: rows are notes, columns are words. NumPy calls this an array of shape (notes, words), and this is your first tensor: a block of numbers with a shape.

To compare two notes, measure the angle between their vectors. The dot product a⋅b=∑iaibia \cdot b = \sum_i a_i b_i is big when both notes use the same words. Divide by both lengths and you get the cosine similarity:

cos⁡θ=a⋅b∥a∥ ∥b∥,∥a∥=∑iai2\cos\theta = \frac{a \cdot b}{\|a\|\,\|b\|}, \qquad \|a\| = \sqrt{\textstyle\sum_i a_i^2}

It is 1 when two notes point the same way and 0 when they share no words. A long note and a short note on the same topic still score high, because only the direction counts, not the length.

VISUALFig. 1
count of "python" count of "matrix" θ A (3, 1) B (6, 2) query (1, 3) cos(A, B) = 1.0: same direction, B is just a longer note cos(A, query) = 6 / 10 = 0.6
Two words, three vectors. A and B point the same way, so their cosine is 1 even though B is twice as long. Why it's here: See why the angle, not the raw count, decides which notes match.
HINT · OBJECTIVE 3
Stuck? Hints stay hidden until you ask.
HINT · OBJECTIVE 5
Stuck? Hints stay hidden until you ask.

DATA · your own notes, or any folder of .md files

Objectives

0 / 5 CLEARED

Read-only. Log in to update progress.

VICTORY CONDITIONS

  1. All 20 queries give exactly the same top-5 lists as sklearn cosine_similarity, recorded with `python tools/mlarena.py record BM-01 "20/20 identical"`.
  2. Similarity uses only your own NumPy code (no sklearn, no np.dot or @) and every normalised note vector has length 1 within 1e-12.
  3. A command-line tool that takes a question and prints the 5 closest notes with their scores.

Side quests

Drop very common words like "the" and "and" (a stop-word list) and see which queries change their answers.
Weight each word by how rare it is across notes (TF-IDF) and compare results with plain counts.

Terms in plain words

Vector
An ordered list of numbers. Here, one number per word in the vocabulary, counting how often that word appears in a note.
Dot product
Multiply two vectors entry by entry and add up the results. It is large when both vectors are big in the same places.
Norm
The length of a vector, the square root of the sum of its squared entries.
Cosine similarity
The dot product divided by both lengths. It is the cosine of the angle between two vectors, so it ignores how long a note is.
Array shape and broadcasting
A 2-D NumPy array has a shape like (notes, words). Broadcasting lets you divide every row by its own norm in one line, without a loop.