Ranking that learns from clicks, and keeps its rules

Your search ranking is a formula someone guessed. Let the clicks fix the numbers, without letting them touch the rules.

1 A ranking formula someone guessed

Every store's search has one: four weights picked by gut, plus two rules that must never break: the pinned result goes first, and out-of-stock items never reach the top 10.

Run as a neural net, does this formula rank results in exactly the same order as the JavaScript?

2 Let shoppers in, and watch both models learn

Press play. Shoppers arrive one by one; their clicks are the training data. Watch the left column's four numbers settle while its rules stay green. The right column learns the taste too, but nothing in it knows the rules, and the clicks never teach them.

No shoppers yet. Left: the guessed formula. Right: a generic net, starting from random numbers as they do.

Each shopper sees the list on the left and clicks what they like. After every 25 shoppers, both models take a few learning steps on all the clicks so far.

Your formula, as a Handwired net

Learning moves only these four numbers:

favourite in the top 3: –
  • 📌 pinned result first
  • no out-of-stock in the top 10

    A generic neural net

    Learning moves 65 numbers nobody can read:

    favourite in the top 3: –
    • 📌 pinned result first
    • no out-of-stock in the top 10

      3 What changed in the code

      Let the shoppers in first.

      Reach for Handwired when you already have a formula people understand, rules that must hold exactly, and data that should tune the numbers, not replace the code.

      Shoppers are simulated with a hidden taste (2·match + 1·pop + 4·fresh + 3·rating, hidden from both models), attention that fades down the list, and less interest in out-of-stock items. Both models learn with the same optimizer (Adam), loss (which of the 10 shown results was clicked) and clicks, six steps after every 25 shoppers. The generic model is a 6→8→1 ReLU net given the same six facts, including “pinned” and “in stock”. Pinned and out-of-stock clicks aren't used for training, since the rules decide those. Rates and rule checks are measured live on 200 seeded test searches of 20 results.

      Loading Handwired…