Code Simulation Challenges for Large Language Models

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: La Malfa, Emanuele, Weinhuber, Christoph, Torre, Orazio, Lin, Fangru, Marro, Samuele, Cohn, Anthony, Shadbolt, Nigel, Wooldridge, Michael
Natura: Preprint
Pubblicazione: 2024
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866917691102593024
author La Malfa, Emanuele
Weinhuber, Christoph
Torre, Orazio
Lin, Fangru
Marro, Samuele
Cohn, Anthony
Shadbolt, Nigel
Wooldridge, Michael
author_facet La Malfa, Emanuele
Weinhuber, Christoph
Torre, Orazio
Lin, Fangru
Marro, Samuele
Cohn, Anthony
Shadbolt, Nigel
Wooldridge, Michael
contents Many reasoning, planning, and problem-solving tasks share an intrinsic algorithmic nature: correctly simulating each step is a sufficient condition to solve them correctly. This work studies to what extent Large Language Models (LLMs) can simulate coding and algorithmic tasks to provide insights into general capabilities in such algorithmic reasoning tasks. We introduce benchmarks for straight-line programs, code that contains critical paths, and approximate and redundant instructions. We further assess the simulation capabilities of LLMs with sorting algorithms and nested loops and show that a routine's computational complexity directly affects an LLM's ability to simulate its execution. While the most powerful LLMs exhibit relatively strong simulation capabilities, the process is fragile, seems to rely heavily on pattern recognition, and is affected by memorisation. We propose a novel off-the-shelf prompting method, Chain of Simulation (CoSm), which instructs LLMs to simulate code execution line by line/follow the computation pattern of compilers. CoSm efficiently helps LLMs reduce memorisation and shallow pattern recognition while improving simulation performance. We consider the success of CoSm in code simulation to be inspirational for other general routine simulation reasoning tasks.
format Preprint
id arxiv_https___arxiv_org_abs_2401_09074
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Code Simulation Challenges for Large Language Models
La Malfa, Emanuele
Weinhuber, Christoph
Torre, Orazio
Lin, Fangru
Marro, Samuele
Cohn, Anthony
Shadbolt, Nigel
Wooldridge, Michael
Machine Learning
Artificial Intelligence
Computation and Language
Programming Languages
Many reasoning, planning, and problem-solving tasks share an intrinsic algorithmic nature: correctly simulating each step is a sufficient condition to solve them correctly. This work studies to what extent Large Language Models (LLMs) can simulate coding and algorithmic tasks to provide insights into general capabilities in such algorithmic reasoning tasks. We introduce benchmarks for straight-line programs, code that contains critical paths, and approximate and redundant instructions. We further assess the simulation capabilities of LLMs with sorting algorithms and nested loops and show that a routine's computational complexity directly affects an LLM's ability to simulate its execution. While the most powerful LLMs exhibit relatively strong simulation capabilities, the process is fragile, seems to rely heavily on pattern recognition, and is affected by memorisation. We propose a novel off-the-shelf prompting method, Chain of Simulation (CoSm), which instructs LLMs to simulate code execution line by line/follow the computation pattern of compilers. CoSm efficiently helps LLMs reduce memorisation and shallow pattern recognition while improving simulation performance. We consider the success of CoSm in code simulation to be inspirational for other general routine simulation reasoning tasks.
title Code Simulation Challenges for Large Language Models
topic Machine Learning
Artificial Intelligence
Computation and Language
Programming Languages
url https://arxiv.org/abs/2401.09074