Abstract
Ensembling multiple Large Language Models (LLMs) offers a pathway to superior performance by leveraging the diverse strengths of different architectures. However, traditional ensembling methods—ranging from computationally expensive rankers to static heuristic-based token weighting—often fail to adapt to the context-specific expertise of individual models. This paper introduces RLAE (Reinforcement Learning-Assisted Ensemble), a framework that reformulates LLM ensembling as a Markov Decision Process (MDP). By employing a lightweight Reinforcement Learning agent to dynamically adjust model weights at the span level, RLAE achieves significant accuracy improvements (up to 3.3%) over existing baselines while maintaining lower inference latency than traditional ranker-based approaches.
1. Introduction
As the landscape of Large Language Models (LLMs) expands, it is increasingly evident that no single model dominates every domain. A model might excel at mathematical reasoning but struggle with creative synthesis, or vice versa. Ensembling provides a mechanism to combine these specialized strengths.
Existing ensembling strategies typically fall into two categories: Ranker-based methods, which generate multiple full responses and use a secondary model to select the best one, and Heuristic-based methods, which combine token-level probabilities using fixed weights. Rankers are often prohibitively slow due to their quadratic computational cost, while heuristics are too rigid to account for "domain shifts" that occur within a single generation. RLAE addresses these limitations by treating the generation process as a dynamic sequence of decisions, allowing for real-time, context-aware weight adjustments.
2. Methodology
2.1 Ensembling as a Markov Decision Process (MDP)
RLAE treats the ensembling task as an MDP, where an RL agent acts as the central controller. The components of this MDP are defined as follows:
- State: The input prompt combined with the history of previously generated text.
- Action: The specific weight distribution assigned to each base LLM for the upcoming segment of text.
- Reward: A signal derived from the final output quality (e.g., correctness in a math problem) and intermediate process rewards that provide denser feedback during the training phase.
2.2 The RL Agent and Span-Level Optimization
To ensure the system remains efficient, RLAE utilizes a relatively small model (DeBERTa-V3-Large, ~400M parameters) as the RL agent. Rather than making a decision for every individual token—which would introduce significant overhead—RLAE operates on spans. A span is a sequence of $L$ tokens (typically $L=4$). This granularity allows the agent to adapt to shifting context without the latency penalties of token-by-token processing.
2.3 Single vs. Multi-Agent Approaches
The authors explored two architectural variations:
- RLAE-PPO: A single agent manages the weight distribution for all models in the ensemble.
- RLAE-MAPPO: A multi-agent approach where each base model is paired with a dedicated RL agent that "advocates" for its model's contribution based on the current state.
3. Experimental Setup
3.1 Base Models and Benchmarks
The framework was tested using an ensemble of five prominent LLMs: Llama-3.1-8B, Qwen-2-7B, Qwen-2.5-7B, Mistral-7B, and OpenChat-3.5. To ensure the ensemble's mathematical consistency, a mapping matrix was used to align the differing vocabularies and tokenizers of these models into a unified space.
Evaluation spanned seven diverse benchmarks across three core dimensions:
- General Ability: MMLU, ARC-C, and TriviaQA.
- Math & Science: GSM8K, PIQA, and GPQA.
- Code Generation: MBPP.
4. Key Results and Insights
4.1 Performance and Accuracy
RLAE-MAPPO emerged as the strongest configuration, achieving an average score of 70.1 across all benchmarks. This represents a 3.3 percentage point improvement over existing ensemble baselines like GAC and DEEPEN. The multi-agent approach proved particularly effective for complex reasoning tasks, as individual agents could better specialize in the specific behavioral nuances of their respective base models.
4.2 Efficiency and Latency
Despite the inclusion of an RL agent in the inference loop, RLAE demonstrated superior efficiency compared to ranker-based methods like PAIRRANKER. The span-level optimization strategy successfully mitigated the computational cost, resulting in lower milliseconds-per-token (ms/token) latency than many heuristic token-level methods.
4.3 Dynamic Expertise and Generalization
Analysis of the RL agent's behavior revealed that it successfully learned to identify model strengths in real-time. For instance, the agent consistently increased weights for Qwen models during STEM-related reasoning while favoring Llama for general linguistic tasks. Furthermore, the system showed impressive zero-shot generalization; an agent trained on MMLU could be applied to ARC-C with minimal performance degradation, suggesting it had acquired high-level meta-knowledge about model reliability.
5. Conclusion and Future Work
RLAE demonstrates that reinforcement learning can effectively manage the complexities of LLM ensembling by treating generation as a dynamic, path-dependent process. While the current framework requires running multiple base models in parallel—scaling compute linearly—it sets a new standard for accuracy and context-aware generation.
Future research will focus on two primary areas: first, developing more sophisticated reward models to capture subjective generation quality beyond simple accuracy metrics; and second, implementing dynamic model selection, where the RL agent can "deactivate" unnecessary models for specific prompts to further reduce computational overhead.
Summary updated