Can Large Language Models Reinvent Foundational Algorithms?
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.
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
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?
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
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.
PreUnlearn: Auditing Collateral Knowledge Damage Before Large Language Model Unlearning
This paper proposes PreUnlearn, a framework for auditing collateral knowledge damage in LLM unlearning before execution, using data-centric analysis to predict downstream damage across semantic layers.
Understanding Large Language Models
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.