                           What Makes In-context Learning Effective for Mathematical Reasoning

                         Llama2-13B     Llama3-8B                   References
          zero-shot         0.428          0.628
           Random           0.415          0.625                    Achiam, J., Adler, S., Agarwal, S., Ahmad, L., Akkaya,
         Best-validate      0.375          0.605                      I., et al. Gpt-4 technical report. arXiv preprint
           TF-IDF           0.368          0.617                      arXiv:2303.08774, 2023.
            BM25            0.383          0.627
              T5            0.419          0.617
           BGEM3            0.377          0.589                    An, S., Lin, Z., Fu, Q., Chen, B., Zheng, N., Lou, J.-G., and
           OpenAI           0.393          0.607                      Zhang, D. How do in-context examples affect composi-
           SPELL            0.409          0.637                      tional generalization? In Proceedings of the 61st Annual
          Influence         0.374          0.605                      Meeting of the Association for Computational Linguistics
             IDS            0.408          0.640
                                                                     (Volume 1: Long Papers), pp. 11027–11052, 2023.
         LMS3 (ours)        0.444          0.650

    Table 5. Performance of CommonsenseQA benchmark.                Asai, A., Wu, Z., Wang, Y., Sil, A., and Hajishirzi, H. Self-
                                                                      rag: Learning to retrieve, generate, and critique through
                                                                      self-reflection. In The Twelfth International Conference
                                                                      on Learning Representations, 2024.
6. Conclusion                                                       Besta, M., Blach, N., Kubicek, A., et al. Graph of thoughts:
In this paper, we theoretically analyzed how demonstra-               Solving elaborate problems with large language models.
tions affected LLMs’ mathematical reasoning performance.              In AAAI, volume 38, pp. 17682–17690, 2024.
On this basis, we proposed a LMS3 method that balanced
LLM-oriented semantic similarity and inference stability of         Brown, T., Mann, B., Ryder, N., Subbiah, M., Kaplan, J. D.,
demonstrations, and introduced a demonstration rejection              et al. Language models are few-shot learners. Advances
mechanism to filter out negative situations. Experiments              in neural information processing systems, 33:1877–1901,
showed that our method was the only one to consistently               2020.
improve the reasoning accuracy of LLMs, and our demon-
strations exhibited strong generalization ability and inter-        Chang, T.-Y. and Jia, R. Data curation alone can stabilize
pretability. In the future, we will extend our method to more         in-context learning. In Proceedings of the 61st Annual
NLP tasks and apply our theory to broader scenarios. Please           Meeting of the Association for Computational Linguistics
refer to Appendix E for more discussions and details.                (Volume 1: Long Papers), pp. 8123–8144, 2023.

                                                                    Chen, J., Lin, H., Han, X., and Sun, L. Benchmarking large
Impact Statement                                                      language models in retrieval-augmented generation. In
                                                                      Proceedings of the AAAI Conference on Artificial Intelli-
This work provides valuable insights into the underlying
                                                                      gence, volume 38, pp. 17754–17762, 2024a.
mechanisms of LLMs. By theoretically analyzing how in-
context demonstrations affect LLM performance, we offer             Chen, J., Xiao, S., Zhang, P., et al. Bge m3-embedding:
a deeper understanding of LLM behavior, which paves the               Multi-lingual, multi-functionality, multi-granularity text
way for more effective optimizations in the future. This              embeddings through self-knowledge distillation. arXiv
could lead to reduced costs and improved efficiency in de-            preprint arXiv:2402.03216, 2024b.
ploying LLMs for reasoning tasks. Additionally, our LMS3
method has practical implications for improving the relia-          Chen, W., Ma, X., Wang, X., and Cohen, W. W. Program
bility and relevance of LLM outputs in various applications,          of thoughts prompting: Disentangling computation from
especially in decision-making fields that rely on complex             reasoning for numerical reasoning tasks. Transactions on
reasoning and data-driven insights.                                   Machine Learning Research, 2023.

Acknowledgement                                                     Cobbe, K., Kosaraju, V., Bavarian, M., Chen, M., Jun, H.,
                                                                      Kaiser, L., Plappert, M., Tworek, J., Hilton, J., Nakano,
This research was partially supported by the Na-                      R., et al. Training verifiers to solve math word problems.
tional Natural Science Foundation of China (Grants                    arXiv preprint arXiv:2110.14168, 2021.
No.62477044), Anhui Provincial Natural Science Foun-
dation (No. 2308085QF229), the Fundamental Research                 Dai, D., Sun, Y., Dong, L., Hao, Y., Ma, S., Sui, Z., and
Funds for the Central Universities (No.WK2150110038).                Wei, F. Why can gpt learn in-context? language models
Zhenya Huang gratefully acknowledges the support of the               secretly perform gradient descent as meta-optimizers. In
Young Elite Scientists Sponsorship Program by CAST (No.              Findings of the Association for Computational Linguis-
2024QNRC001).                                                         tics: ACL 2023, pp. 4005–4019, 2023.

                                                                9
