Article
Midjourney engineer open-sources Handwired: no training required—program rules are written directly into a neural network
Beating AI news: Midjourney engineer Cheng Lou has open-sourced Handwired, providing a new way to build neural networks.
GPT Large models such as need to be trained on vast amounts of data to determine their internal weights.Handwired instead directly sets weights according to JavaScript's computational rules. Neural networks essentially consist of layer upon layer of mathematical operations, and weights are the numerical coefficients within them. Once program rules have been written, the corresponding computational structure can be constructed directly, eliminating the training process.
For example, code specifies that if an integer is greater than 4, it returns 10, otherwise it returns 12。Handwired uses ReLU and multiplication to construct a numerical switch representing true or false, replacing the original if-else conditional. Loops and state updates can likewise be broken down into similar numerical operations.
Cheng Lou used this approach to create a miniature browser desktop, with 130 layers of computation and 9909 weights handling window dragging, resizing, animation, and photo layout. The entire process requires no training; ordinary CPU can run it, while the browser still renders the interface.
For implementing these functions alone, writing JavaScript directly would be more convenient. But Handwired enables fixed program rules and trainable parameters to share a single computational structure. The program can continue to execute according to its rules, while parts requiring adjustment can modify weights through backpropagation based on output error.
The photo-layout demonstration uses this feature. Users roughly sketch the desired photo positions, and the system continuously trains a small network with only 244 weights, bringing photos as close as possible to target positions and automatically aligning their edges. Fixed interaction rules operate as usual, while layout parameters learn in real time.
Cheng Lou also proposed connecting such fixed-rule modules to nanoGPT. Today, large models can also call external programs for precise calculations, but external code generally cannot directly participate in a model's backpropagation.
If program rules are written as compatible computational graphs, models may be able to use both predetermined rules and capabilities acquired through training, and even jointly optimize their trainable components.
This remains an early experiment.Handwired cannot yet automatically convert arbitrary JavaScript, and developers must manually construct computational graphs; some conditional statements also cannot directly yield useful gradients.