a project by Cheng Lou · explained

When would you want your JavaScript to learn?

When you have code people trust, rules that must stay exact, and data that should tune the numbers. Handwired runs that code as a neural net, exactly, so it can learn. Try the most common case right here.

your ranking code runs as a Handwired net

  • pinned result on top ✓
  • out-of-stock in top 10 0
  • shoppers' favourite in top 3 –

0 clicks logged

results for “wireless headphones” · or click one yourself

    Shoppers are simulated with a hidden taste (2·match + 1·pop + 4·fresh + 3·rating, hidden from both models), attention that fades with position (1 / (1 + 0.35 × position)), and less interest in out-of-stock items. Rates are measured live on seeded test lists of 20 results each. Full walkthrough, including the generic model that breaks the rules →

    When would you use this?

    New to the idea? The beginner lesson (a cat deciding how hard to jump) explains it from scratch in three minutes.

    Handwired is an open-source project by Cheng Lou that turns regular JavaScript code into a neural net: no training, exact, yet fully differentiable, and runnable in a browser without a GPU. This site is an independent, hands-on guide with live demos that run the real Handwired runtime.

    What is Handwired?

    Handwired is a way to write a program as a fixed list of 32-bit float operations — weighted sums, products with a ReLU, and a few exact helpers — so the program is a neural network. Its weights are written by hand (hence the name) instead of learned, which is why it is exact. Because it only uses differentiable primitives, you can still compute gradients through it and train its numbers later.

    The canonical example from the Handwired homepage:

    // your code
    const result = a > 4 ? 10 : 12
    
    // turns into (relu(x) is Math.max(0, x))
    const above4 = relu(a - 4) - relu(a - 5)
    const result = above4 * 10 + (1 - above4) * 12
    

    For any integer a, both versions return the same number. Try it live →

    What can you do with it?

    Live demos on this site

    Where do I start?

    Read Why Handwired for the idea, Concepts for how conditionals become ReLUs and why the result is both exact and differentiable, then Getting started to run it yourself. Common questions are answered in the FAQ.