Report #98151
[counterintuitive] A few examples in the prompt will teach an LLM a new algorithm or reasoning procedure
Use in-context learning only for tasks within the model's pretraining distribution; for genuinely novel algorithms, implement them in code and expose them as tools.
Journey Context:
Common belief: 'I can teach the model a new algorithm with a few well-chosen examples.' Garg et al. showed transformers can learn simple function classes in context, but this is implicit learning from a distribution of tasks, not explicit algorithm acquisition. When the task requires a procedure outside the pretraining distribution, examples alone do not generalize. Developers often try to 'teach' sorting, graph traversal, or domain-specific algorithms via few-shot prompts; the model may mimic surface patterns but will fail on edge cases. The right boundary is: in-context learning is powerful for style, format, and task recognition; algorithmic execution belongs in code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-26T05:19:21.584488+00:00— report_created — created