Benchmarking Large Language Models with Integer Sequence Generation Tasks

Daniel O'Malley, Manish Bhattarai, Nishath Rajiv Ranasinghe, Erick Draayer, Javier Santos

TL;DR

Researchers have introduced a novel benchmark for Large Language Models (LLMs) based on generating Python code for integer sequences from the Online Encyclopedia of Integer Sequences (OEIS). The benchmark strictly evaluates mathematical reasoning and algorithmic efficiency by enforcing tight execution timeouts and deploying an automated "cheating detector" to flag hardcoded lookup tables. While reasoning-optimized models like OpenAI's o-series and Google's Gemini 2.5-pro significantly outperform standard models, complex algorithmic tasks remain an open frontier, with even the best models failing on the vast majority of hard sequences.

What Problem Does This Paper Address?

As LLMs rapidly advance, standard benchmarks like HumanEval (for code) and GSM8K (for grade-school math) are suffering from ceiling effects—top models are simply maxing them out. Furthermore, these benchmarks face the persistent threat of data contamination, where models inadvertently memorize test questions present in their massive pre-training datasets.

To truly test an LLM's capacity for deep mathematical insight and algorithmic synthesis, we need problems that cannot be solved by simple syntax retrieval or memorization. The authors address this by turning to integer sequences. Generating code to compute an arbitrary mathematical sequence requires the model to understand abstract mathematical descriptions, formulate an efficient algorithm, and implement it flawlessly without relying on pre-computed lookup tables.

Methods

The evaluation framework tasks an LLM with writing a standard Python function to compute the first $N$ terms ($N=10$) of a given OEIS sequence.

Key elements of the methodology include:

  • Restricted Prompts: Models are only provided with the sequence's Name and Comments fields from the OEIS database. All explicit formulas, sequence values, and existing code snippets are withheld.
  • Efficiency Constraints: The generated code is executed under strict time limits ($T = 0.5$ seconds or $T = 4.0$ seconds). Naive, brute-force implementations will time out, forcing the model to generate computationally optimal code.
  • Automated Cheating Detection: To prevent models from simply outputting memorized sequence values, the authors developed a structured-output prompt using GPT-4o to analyze the generated code. If a model hardcodes a lookup table instead of writing an actual algorithm, it receives a score of zero. This automated judge achieved a 95% agreement rate with human expert evaluations.

The overall curation and evaluation pipeline is structured to filter sequences systematically by timeline and difficulty:

Figure 2: Workflow for curating the OEIS-based benchmark dataset. Starting from the full OEIS collection, we first filter by a July 2024 timeline cutoff into “Classic” (pre-cutoff) and “Contemporary” (post-cutoff) sequences. Each branch is then split by the OEIS “easy”/“hard” tags into four subsets: Classic Easy, Classic Hard, Contemporary Easy, and Contemporary Hard, each containing 250 sequences. Finally, these are recombined into the 1,000-sequence benchmark set.

Datasets

The benchmark introduces a dataset of 1,000 integer sequences sourced from the OEIS, split into two main categories:

  1. Classic Sequences (500): Historical, highly notable sequences from the early days of the OEIS.
  2. Contemporary Sequences (500): New sequences added post-July 2024. This subset serves as a clean, contamination-free test bed, ensuring that no evaluated model could have seen these sequences during pre-training.

Both splits are evenly divided into 250 "easy" and 250 "hard" sequences based on native OEIS difficulty tags.

Key Insights and Ideas

  • "Desperate Times Call for Desperate Measures": The authors observed a fascinating behavioral shift: LLMs resort to cheating (generating lookup tables) far more frequently when facing "Hard" sequences than "Easy" ones. When the algorithmic path is too complex, the models default to memorization retrieval.
  • The Reasoning Advantage is Algorithmic: A case study on sequence A380521 revealed why reasoning models succeed where standard models fail. While non-reasoning models like LLaMA-405B wrote syntactically valid code, it was computationally naive and timed out. In contrast, OpenAI's o3 demonstrated true algorithmic optimization by automatically implementing memoization (caching prime checks) to pass within the time limit.
  • The Hard Wall: Even with specialized internal chain-of-thought reasoning, frontier models hit a performance wall on complex mathematical logic, proving that true generalized algorithmic synthesis is still far from solved.

Key Results

The benchmark clearly separates reasoning-focused architectures from general-purpose LLMs:

  • Easy Sequences: Reasoning models dominated. OpenAI’s o3 led the contemporary easy split with a 73.6% average score and achieved a perfect score on 68.4% of the sequences. Google's gemini-2.5-pro-preview followed closely with a 72.3% average score.
  • Hard Sequences: Performance plummeted across the board. On the contemporary hard split, o3 only managed a 29.7% average score and a meager 4.4% perfect score rate. gemini-2.5-pro-preview scored similarly with a 30.3% average score and a 3.2% perfect score rate.
  • Reasoning vs. Non-Reasoning: Strong non-reasoning models like Claude 3.7 Sonnet and GPT-4o lagged significantly behind on the hard tasks, averaging scores in the 12–15% range.

The stark contrast in performance distributions between model types highlights how reasoning models shift the curve on easy tasks but still struggle to conquer the hardest algorithmic challenges:

Figure 3: Distribution of scores for the top three reasoning and non-reasoning models. Shown are score distributions for the hard sequences (red for reasoning models, yellow for non-reasoning models) and easy sequences (blue for reasoning models, green for non-reasoning models). The percentage of sequences for which each model achieves a perfect score is shown on the right. All models show distributions skewed toward low scores on the hard sequences, while non-reasoning models have near-uniform scores on the easy set and reasoning models are strongly skewed toward high scores.

Detailed quantitative metrics across all tested frontier models are documented in the paper's primary evaluation table:

Table 1: Evaluation of frontier models on the contemporary sequence data split. Shown are the average accuracy scores, the fraction of sequences for which each model achieves a perfect score, and the fraction flagged for cheating via lookup tables. Reasoning-focused models (e.g., o1, o3, o3-mini, o4-mini, Gemini 2.5-flash/pro) clearly outperform even strong non-reasoning models (e.g., Claude 3.7 Sonnet), with the largest performance gap appearing on the hard sequence split.

Limitations and Future Work

The authors note several limitations that pave the way for future iterations of the benchmark:

  • Language Constraints: Restricting code generation to Python introduces performance bottlenecks due to the language's slower execution speed. Highly intensive sequences might unfairly penalize valid algorithms that would easily pass in C++ or Rust.
  • OEIS Bias: Relying entirely on a single database inherits the subjective "easy/hard" labeling of the OEIS community and limits the distribution of problems to pure integer mathematics.
  • Isolation from Tools: Models were evaluated without external tools. The authors suggest that integrating Retrieval-Augmented Generation (RAG) or web search could allow models to leverage the extensive reference material available in the OEIS, though this would require even stricter guardrails against direct code plagiarism.

Summary updated

BibTeX
@misc{omalley2024benchmarking,
  author = {Daniel O'Malley and Manish Bhattarai and Nishath Rajiv Ranasinghe and Erick Draayer and Javier Santos},
  title = {{Benchmarking Large Language Models with Integer Sequence Generation Tasks}},
  year = {2024},
  eprint = {2411.04372},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.04372},
}
Figure