Abstract
In recent years, large pre-trained language models (LLMs) have demonstrated the ability to follow instructions and perform novel tasks from a few examples. The possibility to parameterise an LLM through such in-context examples widens their capability at a much lower cost than finetuning. We extend this line of reasoning and present a method which further expands the capabilities of an LLM by embedding it within an algorithm or program. To demonstrate the benefits of this approach, we present an illustrative example of evidence-supported question-answering. We obtain a 6.4% improvement over the chain of thought baseline through a more algorithmic approach without any finetuning. Furthermore, we highlight recent work from this perspective and discuss the advantages and disadvantages in comparison to the standard approaches.
Introduction: The Limits of Standalone LLMs
While Large Language Models (LLMs) like GPT-3 and OPT are remarkably capable, they face significant hurdles when used as standalone "black boxes." First, context constraints limit their "memory," where cramming too much information into a prompt leads to interference and performance degradation. Second, LLMs often exhibit algorithmic weakness, struggling with rigid logic such as sorting or maintaining state over long sequences. Finally, the fine-tuning trap makes adapting models to specific procedures computationally expensive and often brittle.
This research proposes a shift in paradigm: instead of treating the LLM as the entire system, we treat it as a specialized module within a traditional computer program. By delegating control flow and state management to a classical algorithm (e.g., Python), we can leverage the LLM's strengths while mitigating its structural weaknesses.
Methodology: LLM Programs for Evidence-Supported QA
The core idea of an "LLM Program" is to use a classical programming language to handle high-level logic—loops, branching, and memory—while calling the LLM only for specific, narrow tasks. To demonstrate this, we developed an LLM program for evidence-supported question answering using the OPT-175B model.
The program employs two primary algorithmic strategies:
- Likelihood-based Filtering: Rather than asking the LLM to judge relevance via text (which is often unreliable), the program calculates the average negative log-likelihood (NLL) of the question given a paragraph. This uses the model's internal probability distribution to rank evidence.
- Guided Tree Search: The program generates reasoning chains step-by-step. For each step, it performs a search over different evidence paragraphs, ranking them using a "Delta Ranking" strategy. This ensures the reasoning remains grounded in provided facts by measuring how much a specific paragraph improves the likelihood of a reasoning step.
We evaluated this approach on StrategyQA, a benchmark requiring multi-step implicit reasoning. We focused on a subset of 918 questions with annotated evidence to ensure the tasks were solvable given the correct information.
Key Results and Insights
The LLM program approach yielded significant performance gains without any additional training or fine-tuning of the underlying model.
- Superior Filtering: NLL-based ranking achieved a Top-1 accuracy of 79% in identifying relevant paragraphs, significantly outperforming standard zero-shot prompting.
- Reasoning Performance: The full LLM program reached 66.41% accuracy on the StrategyQA subset, a 6.4% improvement over the standard Chain-of-Thought (CoT) baseline (60.11%).
- The "Golden" Fact Ceiling: When provided with "golden" facts (perfect evidence), the model reached ~81% accuracy. This suggests that the current bottleneck in reasoning tasks is retrieval and filtering rather than the model's inherent reasoning capacity.
A key insight is that context isolation is vital. By providing the LLM with only the specific paragraph needed for a single step, we eliminate the "noise" of long-context prompts. Furthermore, the model's internal token probabilities (likelihood) provide a much cleaner signal for relevance than its generated text responses.
Discussion and Future Work
Embedding LLMs within recurrent algorithms with external memory effectively makes the system "Turing complete," overcoming theoretical limitations of decoder-only Transformer architectures. However, this approach comes with trade-offs. The primary drawback is inference cost, as tree search requires multiple LLM calls per question. Additionally, current LLM programs often require human-designed "scaffolds."
Future work should explore LLMs that can help generate their own wrapper programs and deeper integration with external tools like calculators or specialized databases. This framework represents a step toward more systematic, reliable, and powerful AI systems that combine the flexibility of neural models with the rigor of classical computation.
Summary updated