SiLU and the SwiGLU feed-forward layer
Implement a SwiGLU feed-forward network with intermediate expansion.
What’s going wrong
Original LLM Architecture lab. Implement the missing behavior in solve(data) and keep the supplied JSON interface. Use Python’s standard library.
Input x is a batch of input rows of width D; gate and up are D×F matrices, and down is F×O. Compute SiLU(x·gate) elementwise, multiply with x·up, then project through down. SiLU(z) is z times a stable sigmoid. Return the batch of output rows.
Small, well-formed JSON inputs and standard-library Python arithmetic. Keep full precision during computation. The supplied output wrapper rounds results to six decimal places.
Expected behavior
Implement a SwiGLU feed-forward network with intermediate expansion.
Reproduction
{"x":[[1,2]],"gate":[[1,0,2],[0,1,-1]],"up":[[0,2,1],[1,0,1]],"down":[[1,0],[0,1],[2,1]]}[[1.462117,3.523188]]
{"x":[[1]],"gate":[[0]],"up":[[5]],"down":[[9]]}[[0]]
{"x":[[1]],"gate":[[-1000]],"up":[[2]],"down":[[1]]}[[0]]
Before you begin
- Python functions, lists and dictionaries
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
Read the report, then sign in to start your investigation.