atlas

Research map / Large language models / Language, safety and interpretability

What Makes In-context Learning Effective for Mathematical Reasoning

ICML 2025 · Large language models › Language, safety and interpretability · approach: In-context learning analysis

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Theoretically bounds how in-context demonstrations affect LLM math reasoning loss, then proposes LMS3, a demonstration selection method balancing LLM-oriented semantic similarity and inference stability with a rejection mechanism that falls back to zero-shot.

Problem

Few-shot demonstrations can hurt LLM mathematical reasoning and their effect is unreliable; existing work lacks precise theory on when demonstrations help.

Approach

Derives via a linearized attention/influence-function analysis that demonstrations reduce test loss when they are semantically close (measured in the inference LLM's representation space) and the LLM is stable on them; selects demonstrations by the product of similarity and stability, and rejects demonstrations entirely when similarity ranks poorly.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Use LMS3-selected one-shot demonstrations instead of zero-shot promptingLlama2-13B · MAWPSanswer accuracy: 0.835± 0.009 -> 0.854∗± 0.008Helped
Use LMS3-selected one-shot demonstrations instead of zero-shot promptingLlama2-13B · GSM8Kanswer accuracy: 0.414± 0.004 -> 0.447∗± 0.014Helped
Use LMS3-selected one-shot demonstrations instead of zero-shot promptingLlama2-13B · MATHanswer accuracy: 0.096± 0.005 -> 0.124∗± 0.003Helped
Use LMS3-selected one-shot demonstrations instead of zero-shot promptingLlama3-8B · MAWPSanswer accuracy: 0.951± 0.004 -> 0.966± 0.010Helped
Use LMS3-selected one-shot demonstrations instead of zero-shot promptingLlama3-8B · GSM8Kanswer accuracy: 0.820± 0.016 -> 0.837∗± 0.011Helped
Use LMS3-selected one-shot demonstrations instead of zero-shot promptingLlama3-8B · MATHanswer accuracy: 0.324± 0.022 -> 0.353∗± 0.002Helped
Apply LMS3-selected demonstrations to ChatGPTChatGPT · GSM8Kanswer accuracy: 0.800 -> 0.862Helped
Apply LMS3-selected demonstrations to GPT-4GPT-4 · MATHanswer accuracy: 0.758 -> 0.752Hurt
Add the demonstration rejection mechanism to LMS3 rather than retaining demonstrations at λ = 100% (ablation)LMS3 · one-shot reasoning on MAWPS, GSM8K, and MATHanswer accuracyHelped
Add the rejection mechanism to baseline demonstration selectors (ablation)Llama3-8B demonstration selection · MAWPS, GSM8K, and MATHanswer accuracy: 0.920 -> 0.932Helped

Surprising findings

Limitations

Experimental setup

Datasets: MAWPS GSM8K MATH CommonsenseQA

Benchmarks: MAWPS GSM8K MATH CommonsenseQA

Metrics: answer accuracy

Baselines: Random Best-validate TF-IDF BM25 T5 BGEM3 OpenAI embedding SPELL Influence IDS

Builds on: influence functions (Koh & Liang) linear attention as meta-gradient (Dai et al.) InfICL SPELL IDS

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy