TL;DR
This paper introduces AgentRouter, a novel framework that uses knowledge graphs to guide the selection and collaboration of multiple Large Language Model (LLM) agents for question answering. By representing queries, entities, and agents within a graph structure and employing a Graph Neural Network (GNN), AgentRouter learns to dynamically route and combine agent strengths, significantly outperforming single-agent and ensemble baselines.
What Problem Does This Paper Address?
The rapid proliferation of LLMs and agentic strategies has created a challenge for practitioners: selecting the optimal configuration for a specific task. Prior research shows that different LLMs and agent strategies have complementary strengths, and larger models aren't always superior. This heterogeneity necessitates adaptive routing mechanisms. Existing approaches often focus on cost efficiency or broad adaptability, neglecting the rich contextual and relational information crucial for complex question answering (QA) tasks. The paper aims to bridge this gap by developing a routing mechanism that leverages fine-grained contextual understanding and learns principled collaboration schemes.
Methods
AgentRouter tackles multi-agent QA by framing it as a knowledge-graph-guided routing problem. The core innovation lies in two stages:
- Knowledge Graph Construction: Each QA instance is converted into a knowledge graph. This graph includes nodes for queries, contextual entities (extracted from the text and enriched with features like NER type and frequency), and agents (defined by their LLM backbone and prompting strategy). Edges represent various relationships:
- Query-entity edges: Link queries to mentioned entities.
- Entity-entity edges: Capture semantic relationships derived from dependency parsing.
- Agent-entity edges: Indicate which entities an agent focuses on.
- Query-agent edges: These are trainable connections that carry the routing signal.
- Graph-Supervised Routing with RouterGNN: A type-aware heterogeneous Graph Neural Network (GNN) called RouterGNN is trained on this knowledge graph. The GNN propagates information across node types, learning to infer query-agent compatibility distributions. This is achieved through:
- Type-aware message passing: Nodes integrate information from neighbors based on edge types.
- Soft supervision: The GNN is trained using empirical performance signals (F1 scores) from candidate agents, transformed into a soft target distribution via a temperature-scaled softmax. This encourages learning nuanced distributions rather than hard assignments.
- KL divergence loss: Minimizing the KL divergence between the predicted and soft target distributions.
- Weighted aggregation: Final predictions are generated by aggregating agent outputs based on the learned routing distributions.
Datasets
The paper evaluates AgentRouter on four standard QA benchmarks:
- HotpotQA: A large-scale multi-hop QA dataset requiring reasoning across multiple documents.
- 2WikiMultihopQA: Another multi-hop QA dataset that spreads evidence across Wikipedia articles.
- NewsQA: A QA dataset derived from CNN news articles, emphasizing reasoning and synthesis within articles.
- TriviaQA: A QA benchmark built from trivia-style questions, known for its challenging lexical variation and indirect evidence.
Key Insights and Ideas
- Knowledge Graphs are Key for Contextual Routing: The paper strongly advocates for using knowledge graphs to represent the complex interplay between queries, entities, and agents. This structured approach allows for a deeper understanding of contextual dependencies than simpler methods.
- Adaptive Collaboration Outperforms Static Ensembling: AgentRouter demonstrates that dynamically routing and combining agents based on task-specific context leads to significantly better performance than fixed ensembles or relying on a single "best" agent.
- The Power of "Soft" Supervision: Using empirical performance signals to train a soft probability distribution over agents, rather than hard assignments, allows the router to learn more nuanced collaboration strategies and capture complementary strengths more effectively.
- Top-K Clipping Can Be Beneficial: Surprisingly, restricting the router's output to the top-K agents (especially for K=5-10) often yields better results than using the full ensemble. This suggests that pruning noisy or less effective agents can improve overall performance by reducing variance.
- Task-Specific Routing is Crucial: Transferability analysis shows that routers trained on one task don't always perform well on another, highlighting the need for task-aware routing mechanisms.
Key Results
AgentRouter consistently outperformed single-agent baselines and state-of-the-art routing methods across all four benchmarks. For instance, on HotpotQA and 2WikiMultihopQA, AgentRouter showed significant gains, particularly on the more complex multi-hop reasoning tasks. The paper reports substantial improvements in F1 and EM scores compared to baselines like LLM-Blender, HybridLLM, and GraphRouter. The "Oracle" (theoretical best agent) still represents a gap, indicating room for further improvement.
Limitations and Future Work
The authors acknowledge two main limitations:
- Cost-Performance Trade-offs: AgentRouter prioritizes performance and robustness over cost efficiency. Future work could incorporate cost-aware objectives to balance these aspects.
- Fixed Agent Pool: The framework currently operates on a predefined set of manually designed agents. Future research could explore integrating automated agent design and dynamically expanding the agent pool.
The authors suggest that future work could also focus on more flexible and scalable extensions of the framework, potentially incorporating cost-aware objectives and automated agent generation.
Summary updated