I am building a similarity search engine that tells me whether two Substack or Medium stories are related. I went through hundreds of iterations, polishing and improving it. Each new version of my software is better than last week’s.
Wait.
Is it, really?
I realize I could not objectively measure the improvement. So I built a method for ranking the similarity engines. Using a simple trick, it works without need of human-generated ground truth labels. How is this possible? That’s the first part of this story. You can reuse the idea, too.
I tested it, and the first results were absurd: TF-IDF, a keyword method from 1972, beat the modern sentence-transformer models. It took me two weeks to find out why, and that’s the second part of this story.
Then, once I fixed it… you shall see. Read on.
Who wrote similar?
Last spring I wrote about a tool I built to answer a question every writer has: who wrote something similar? In short: Medium and Substack are both poor at identifying kindred authors, so I built my own finder. It scrapes blog posts, turns them into embedding vectors using a local sentence-transformer model, and ranks candidates by good old cosine similarity (to use the tool, see the bottom of the story).

Since then the spider has discovered and scored a few thousand blogs, and the ranking algorithm evolved several times. The next step was moving the embeddings into a proper vector database and a RAG pipeline, which opens several opportunities for more intelligent discovery (more on where that led in I Tried to Replace Claude With Jev, and Kept Both).
That is where I stopped, because of a question I could not answer. I looked back: every version of this tool felt better than the last. The evolution so far was:
simple Google keyword search
TF-IDF, an old lexical method that reads all the words and phrases of a text, but gives most weight to the rare words specific to it
a sentence-transformer with MiniLM embeddings (all-MiniLM-L6-v2): a small, fast, distilled model with 384 dimensions and 6 layers
a sentence-transformer with mpnet embeddings (all-mpnet-base-v2): a medium-depth model with 768 dimensions and 12 layers
Each time I looked at the results and thought: yes, better. But “felt better” is not a measurement. Before moving to a more complex architecture, I need metrics: a stable way to tell me whether the results improve or degrade.
A subtle link
What should a good rating tell? For instance, it should identify subtleties that link two stories and objectively rate them as similar, even if they use very different vocab. Here is an example of what I mean by a subtle link between two stories (sticking to the area I research most: travel blogs).
A poetic piece, The Third Column of Sicilia, published on the Nomadic Mind travel blog, speaks of the Mediterranean legend of Colapesce, interwoven with the meetings and conversations the author has in Sicily. Implicitly, the story explores a deeper subject: a traveller’s dilemma, whether to keep exploring or to anchor in one place.

A different blog, Post-Nomad, has a story, Why you should stay in place, in which the author, looking back on his own experience, challenges the popular digital nomad paradigm, arguing against a lifestyle of no commitment.

Both stories explore the same problem, from two very different angles. Compare them with TF-IDF and the method fails spectacularly: they share almost no vocabulary, so the algorithm ranks them as unrelated. But they are related, and quite strongly, by the core question both authors try to answer. That relation lies in the deeper layers of meaning. Even a human reader will see it only after a careful reading; quickly scanning the two stories, you won’t get it.
This example defines the challenge of this project: I want a similarity search that detects such subtle connections. To understand that my similarity search improves, I want a “measuring stick”. How to build it?
No labels, please
To check whether the machine ranks correctly you need to know what correct is, which means labels, provided by humans. People are hopeless at absolute scores, but reliable at comparisons. So a typical ranking harness is built out of triples: an anchor post, a positive (a post that should be ranked similar), and a negative (one that should be ranked less similar). Those triples need to be labelled by a human. The standard alternatives (precision@k, nDCG, a Bradley-Terry ranking) all need human verdicts too.
Makes sense. Except that someone, probably me, would have to read a few hundred posts and patiently label them into triples… Way too lazy for that.
Should I employ LLM-as-judge, instead of a human ranker? This I considered but decided to avoid if possible. A judge model is a box I cannot version, cannot fully test, and cannot debug. Its answers are not deterministic and it drifts when the vendor updates it. Maybe I am old-fashioned, but I do not like to replace everything with an LLM if I do not have to. Can we do better, meaning simpler?
Then I stumbled across a trick that avoids labelling anything. Take a post from blog X, a second post from the same blog X, and a third from a random blog Y. The two posts from X should be closer to each other than to the stranger, because they have the same author. The author will naturally write stories similar to each other, created by the same brain, same experience, same world view, and same human emotions. No human judgment needed: the label comes from a fact already in the data, namely who wrote it (machine learning calls this weak supervision). Could this method work?
I was initially suspicious. A simple counterexample: if Jack wrote a story about Kuala Lumpur and another about Paris, and Sandra wrote about Paris too, the two Parisian stories could be closer. But at large scale, the statistics might hold anyway. Jack’s personality is revealed by his recurring topics, style, humour, interests. With one pair of stories we may fail, but across 100 of Jack’s stories and 100 of Sandra’s, the links between the two authors should stay shallow, while the deeper connections form two tight-knit clusters.
So I decided to give it a try.
Being old school, I like to visualise data before moving on. I froze 101 blogs, 1,571 posts, and projected every post into two dimensions. Each blog is a star: a hub at the average position of its posts, with a thin line to each one. Colour is the blog’s coherence: how tightly its posts cluster around its centre.

You see at a glance which blogs are disciplined and which wander (btw, all blogs are published in English except the blob in the upper right corner which is far because it is in Spanish). My worry was partly confirmed, but I understood better. Some blogs are coherent (an example marked with a green marker on the zoom below); others produce mutually dissimilar stories which, on the projection, sit closer to other blogs than to their own (an example marked with a red marker).

In general though, I found the visualization quite promising. It showed that the data wasn’t a horrible mess: just the opposite, several blogs seemed thematically coherent. Not all of them, but that’s okay: with a sample large enough, the result should average out.
I decided to proceed with the ultimate similarity ranker built on the simplified principle: “same author writes similar stories”. I saw it wasn’t perfect, but it was potentially good enough, required no human labeller to produce the ground truth and, unlike LLM-as-judge, its decisions could be tracked to the source and debugged.
I also computed a coherence number for every blog. This was my way to decide which stories were “easy positives”, where similarity was potentially easy to establish, and which were “hard positives”, because they belonged to authors who wrote on a variety of topics.
First attempt: full failure
So I deployed this benchmark to rank the similarity search algorithms my project had used so far. Along the way I fixed one obvious bug: sentence-transformers read only the first 256 to 384 tokens of a text (roughly 200 to 290 words), while my median post has 1,013 words. So I split each post into overlapping chunks of about 150 words, embedded each chunk, and averaged the vectors. (Newer long-context embedding models, such as BGE-M3 or nomic-embed with 8,192 tokens, would read a whole post at once; they are next on my list.) Here are the results:
It did not make sense. My newest methods were ranked weakest. Mpnet, the stronger and larger model, sat below TF-IDF, the barebones method from 1972.
A second opinion: the LLM judge agrees
I did not understand. I put all of it aside and tested a different ranking method: the LLM judge I had hoped to avoid (compare: Ragas or DeepEval). To save on tokens, I asked the judge only about the triples where two methods disagreed. A cheap model (Gemini Flash) reads the articles and answers the question: which of these two would resonate with the same reader? Here are the results.

Now I was really surprised. Again, the keyword method from 1972 was beating the semantic architecture my whole project is built on, and the beating survived an independent second opinion.
Breakthrough: the data leak
Then, at six on Friday evening, when I was ready to call it a day, the revelation came. How come every method scores around 90% accuracy on a task I expected to be hard?
Was I feeding the algorithms something that gave away the answer?
I was.
The text being scored, scraped from Substack, was polluted with implicit metadata: subscribe buttons rendered as text, “Thanks for reading So-and-so”, author bylines with dates and paid or free tags, paywall tails, app promos. Every one of those carries the blog’s or the author’s name, post after post. How many blogs were polluted? Most of them:
More than three posts in four carried subscription boilerplate. Two blogs in three gave away their own identity in most of their posts.
So the methods were not comparing nuanced writing, but the authors’ footer templates. And that is perfect food for TF-IDF, which counts words…
In simple terms: all the methods compared two articles by the cosine similarity of their vectors, but TF-IDF was cheating, using a convenient shortcut: the same blog name, repeated in both posts.
I cleaned the set, masking the direct blog identities in the text, and ran it again. Now we’re talking:
Accuracy on same-blog triples, leaky vs clean text
full set hardest quarter
method leaky clean leaky clean
TF-IDF 94.3% 81.3% 93.5% 60.4%
MiniLM 90.7% 85.9% 87.4% 73.4%
MiniLM, unchunked 88.2% 85.4% 85.5% 76.0%
mpnet 90.3% 87.6% 85.1% 75.5%
mpnet, unchunked 89.2% 87.9% 83.0% 77.7%
2,280 triples. 95% confidence intervals on clean
text: about ±1.5 points (full set), ±4 (hardest)The ranking inverts. On clean text, every embedding model beats TF-IDF, on the full set and on the hardest quarter (the blogs that are internally least topic-coherent, marked with light color in the initial UMAP diagram), and McNemar’s test says it is not noise (p < 0.0001 for each). On the hardest quarter TF-IDF collapses from first to last, from 93.5% to 60.4%. This matters for hybrid search, the default in today's RAG stacks, which blends a keyword score (BM25, a close cousin of TF-IDF) with embeddings.
What is somewhat surprising is that chunking improved neither mpnet nor MiniLM (chunked vs unchunked mpnet: p = 0.77 on the full set, p = 0.14 on the hardest quarter). I have a few theories for this, still to be researched. My main suspect: averaging the chunks blurs the author's voice. Things to try: late chunking or contextual retrieval, as they keep the context in each chunk.
What I learned, and what could still be wrong
The measuring stick works. That was the whole point of the exercise: a way to rank the algorithms that search for similar blog posts, without human or AI-generated labels. It is still barebones, but it works. The core idea: stories from the same author should be ranked similar, and that’s our ground truth - but those stories must first be carefully stripped of their metadata.
The progression of my similarity search methodology is real. The new models find deeper similarities significantly better than the old TF-IDF. And now I can introduce all the goodness of the RAG architecture, knowing that I will be able to measure whether it pushes me forward or backward.
The LLM judge is not needed. Neither is a human labeller. Like I wanted.
Now the lessons. If you evaluate a search, RAG or recommendation system:
Look at the text your models actually see, not the text you think they see. Scraped content carries footers, bylines and boilerplate that can give the answer away. It is the retrieval version of benchmark contamination, the leak that makes LLMs look smarter on tests than they are.
When an old baseline beats your modern model, suspect a leak before you celebrate or despair.
Compare methods on the same questions with cruel statistics such as McNemar’s, not by their averages. This, again, saves you from celebrating too quickly.
Now the caveat. The conclusions could still revert. Because look what I did: I was unhappy with a result, I went looking, and I found a method that showed what I wanted to see. That is dangerously close to p-hacking. To rule it out, the result has to survive data it has never seen: blogs scraped after the cleaning rules were written, and a small, human-labelled sample of hard triples.
And the original goal is still far. The subtle link between the Colapesce story and the Post-Nomad piece I opened with is well beyond the methods I’ve implemented. The next ideas are a cross-encoder reranker, which reads both stories together, and ColBERT-style late interaction, which compares them word by word instead of as one averaged vector. That gives me direction and motivation to continue the adventure.
If you have built an evaluation for a semantic search, how did you get your ground truth? Tell me in the comments.
PS. To use the tool: A minimal, stripped-down version of the code is at github.com/altanova/who-wrote-similar. It does not have most of the stuff I built; the main tool has grown complex and is not available publicly. I am thinking of organizing a small cohort of beta testers who could get early access and tell me what they think. If you want to be part of this team, contact me in private.

First published on Medium.




