gd-order-stable-icl-order-sensitive

IN premise — summaries/2026/08/24/shen-2023-icl-not-gd-s3-a-b-in-4-5.md

Created 2026-08-25T02:58:32+00:00

Gradient descent is order-stable because it computes the mean gradient over the full batch (zero permutation sensitivity), while ICL in decoder-only Transformers is order-sensitive because each token prediction depends only on preceding tokens, making output inherently dependent on demonstration order.

Summary

There is a key asymmetry between how models learn from data. When you train a model by averaging over a batch of examples, shuffling the order of those examples makes no difference to the result, so the process is robust to arrangement. But when a model simply reads through demonstrations and generates a response one token at a time, the order of those demonstrations directly shapes what it predicts next, meaning a simple reordering can change the output. In practice, this means in-context prompts are fragile to rearrangement in a way that traditional training is not.