Can Large Language Models Reinvent Foundational Algorithms?

Hugging Face Daily Papers Papers

Summary

Researchers introduce 'Unlearn-and-Reinvent', a pipeline that removes knowledge of foundational algorithms (e.g., Dijkstra's, Euclid's) from LLMs via unlearning, then tests whether models can independently reinvent them. Results show LLMs can reinvent algorithms with intuitive structures but struggle with those requiring non-obvious data structures or counterintuitive invariants.

LLMs have shown strong potential to advance scientific discovery. Whether they possess the capacity for foundational innovation, however, remains an open question. In this work, we focus on a prerequisite for foundational innovation: can LLMs reinvent foundational algorithms in computer science? Our Unlearn-and-Reinvent pipeline applies LLM unlearning to remove a specific foundational algorithm, such as Dijkstra's or Euclid's algorithm, from an LLM's pretrained knowledge, and then tests whether the model can reinvent it in a controlled environment. To enable effective unlearning, we adopt a GRPO-based, on-policy unlearning method. Across 10 target algorithms, 3 strong open-weight models, and 3 hint levels, our experiments demonstrate that (1) the strongest model Qwen3-4B-Thinking-2507 successfully reinvents 50% of the algorithms with no hint, 70% at hint level 1, and 90% at hint level 2; (2) a few high-level hints can enhance the reinvention success rate, but even step-by-step hints fail for those complicated algorithms; and (3) test-time reinforcement learning enables successful reinvention for the Strassen algorithm at hint level 2. Through analyses of output trajectories and ablation studies, we find that generative verifier in the reinvention phase plays a critical role in sustaining models' reasoning strength, helping to avoid the ``thought collapse'' phenomenon. These findings offer insights into both the potential and current limits of LLMs' innovative thinking.
Original Article
View Cached Full Text

Cached at: 04/21/26, 07:21 AM

Paper page - Can Large Language Models Reinvent Foundational Algorithms?

Source: https://huggingface.co/papers/2604.05716 Can LLMs reinvent foundational algorithms — after we make them “forget”? We loosely adapt Hassabis’s “Einstein Test” to the algorithmic domain: for each target algorithm (Dijkstra’s, Euclid’s, etc.), we remove it from an LLM via unlearning, then test whether the model can reinvent it from scratch.

Recent work shows LLMs can discover new algorithms and do advanced scientific research. But can they go further — invent foundational algorithms that seem to require more creative leaps? We introduce Unlearn-and-Reinvent, a pipeline to study this question.

⭐ Test on 3 strong open-weight models, including Qwen3-4B-Thinking-2507, Qwen3-4B-Instruct-2507, and Ministral-3-14B-Reasoning-2512 ⭐ Models appear able to reinvent algorithms with intuitive greedy/divide-and-conquer structure (e.g., Dijkstra’s, Euclid’s) after unlearning ⭐ Algorithms requiring non-obvious data structures or counterintuitive invariants (KMP, Manacher, Strassen) remain unsolved across all models we test 📌 Further findings: Beyond the core reinvention task, we show that test-time RL can further boost reinvention performance. Separately, we identify a failure mode we term “thought collapse”, where the model’s outputs grow increasingly short across reinvention turns, and we show that generative verifiers can effectively mitigate it.

🤖 Try it yourself — chat with a model that has “forgotten” Dijkstra’s algorithm:https://huggingface.co/spaces/jzhao1122/qwen3-thinking-dijkstra 📄 Paper:https://arxiv.org/abs/2604.05716 💻 Code & Models:https://huggingface.co/algo-reinvention

Similar Articles

Natively Unlearnable Large Language Models

arXiv cs.LG

The paper proposes NULLs (Natively Unlearnable LLMs), a model class that isolates source-specific contributions in sparsely activated sinks while sharing backbone neurons, enabling clean unlearning of individual data sources without retraining and preserving general language capabilities.

Can LLMs realise we're looking at a problem the wrong way?

Reddit r/singularity

The article questions whether large language models can independently recognize and challenge foundational assumptions in science to achieve paradigm-shifting breakthroughs, drawing parallels to human innovations like Einstein's theory of gravity.

Model Unlearning Objectives Vary for Distinct Language Functions

arXiv cs.CL

The paper argues that unlearning in LLMs should be goal-dependent, proposing a cosine-based meta-learned variant of RMU for dangerous knowledge and a multi-layer objective with probe directions for toxicity, achieving strong results across four 7-8B models.

Understanding Large Language Models

arXiv cs.CL

This chapter reviews current understanding of Large Language Models, discussing their Transformer architecture, emergent capabilities resembling human cognition, and debates about whether LLMs genuinely understand or merely simulate understanding.