My tcg-scanner takes a photo of a trading card and finds the matching card in a catalog of 59,913 cards. Until this week I had no idea how often it was right. Every change to the match logic was a guess, so before tuning anything I built a way to measure it.
The setup
The matching works with image embeddings from Voyage. Every catalog card gets a vector, the photo gets a vector, and the nearest vectors are the candidates. A scan is only saved without asking when the result is clear: the distance between first and second place has to be larger than a margin. Otherwise the scan page asks which card it is.
That rule existed before the measurement, with a margin of 0.03. The number was a guess.
The vector import
The catalog first needed vectors. The full import ran in the background for hours and ended with 55,688 of 59,913 cards embedded. I fetched the missing 4,225 one by one, and 2,212 still had no vector after that. I checked 25 of them by hand: all 25 returned a 404 at the image source. No retry fixes an image that doesn’t exist, so those cards stay without a vector for now.
A synthetic photo set
I don’t have hundreds of real photos of cards with known answers. What I do have is the card images themselves. So the eval tool generates photos from them: it takes catalog images and distorts them, in two difficulty levels, “easy” and “medium”. Because every synthetic photo comes from a known card, the correct answer is always known.
The first set had 200 photos. English cards dropped out because of a redirect problem when fetching their images, so this set doesn’t cover them. That’s a gap I keep in mind when I read the numbers.
The first measurement:
| Set | Top-1 | Top-5 |
|---|---|---|
| medium | 78.0% | 93.5% |
| easy | 86.5% | 95.5% |
Two things stood out. The correct card is almost always among the top five, so the embeddings find the right neighborhood. And the gap between top-1 and top-5 is where a second signal could help.
Calibrating the margin
With measured data, the margin stopped being a guess. The calibration lowered it from 0.03 to 0.025, and the README now states the measured hit rates together with the method. That last part matters to me: a number in a README without the way it was produced invites someone to compare it with a different measurement.
Cache the expensive calls
Each measurement run costs 200 Voyage calls per set. When a tool truncated the output of one run, I didn’t pay again: the eval tool caches the embeddings, so I replayed the run from the cache. Repeating an eval should be free, or you start avoiding it.
OCR as a second opinion
Every card has its number printed on it. If I can read that number, the embedding doesn’t need to decide alone. I added Tesseract to read the card number from the photo. It only steps in when the embedding result is unclear.
On the medium set:
| Measurement | Without OCR | With OCR |
|---|---|---|
| Top-1 | 78.5% | 83.0% |
| Saved without asking | 61 of 200 | 88 of 200 |
The baseline in this comparison run was 78.5%, half a point above the first measurement. OCR picked a card 27 times and was right all 27 times. In 111 cases it found nothing usable and stayed quiet, which is what a second opinion should do when it can’t read the text.
On the easy set, top-1 rose from 87.0% to 89.5%. OCR chose a card 32 times, every time the right one, and 114 instead of 82 photos were saved without asking.
Two bugs the numbers exposed
Looking at the failing cases, I found two real bugs in the CardNumberFinder:
- Rarity suffixes blocked every match. Card numbers with a rarity marker like SR or SSP never matched at all.
- A truncated number picked the shorter card. In one run, OCR read
…-073S, which is also the start of…-073SSP. The finder took the shorter card. That was the only wrong OCR pick I saw, and it came from a prefix match that was too eager.
Both fixes are in their own follow-up work, not part of the numbers above. Without the eval set, I’d have seen the 111 “nothing found” cases only as a vague feeling that OCR doesn’t do much.
The LLM second opinion that couldn’t be measured yet
The second idea was a vision model as another opinion for unclear cases, rotating through free models on OpenRouter. Before opening the pull request, I removed Gemini from the default model list. Whether a Gemini key bills you depends on the Google project behind it, and a second opinion that silently costs money is not what I want as a default.
Then the trial run with 30 photos: no model returned a usable answer. Two reasons. Nemotron, one of the free models, doesn’t accept image URLs. And the daily quota for free models on my key was already used up: 1,001 of 1,000 requests. The measurement for the LLM path moved to the next day.
That’s the honest state. The code is merged, its tests pass, and I don’t know yet whether it improves accuracy. It stays behind the same “only for unclear cases” rule as OCR until the numbers say otherwise.
What changed in how I work on it
Three rules I now follow for this scanner:
- No tuning without an eval set. The margin of 0.03 looked reasonable until there was data to check it against. Generating photos from the catalog was enough to get that data.
- Count wrong picks separately from misses. OCR’s “nothing found” in 111 cases is harmless. A single wrong pick saved without asking is not. The
…-073Scase only showed up because I looked at both numbers. - Know what the set doesn’t cover. Synthetic distortion isn’t a phone camera in bad light, and English cards are missing. The numbers tell me which change is better, not how good the scanner is on real photos. That needs my own photos, and that’s the next step.
How do you measure a matcher when you don’t have labeled real-world data yet?