Papers
Topics
Authors
Recent
Search
2000 character limit reached

CARA: Cross-Attention Routing Adapter

Updated 12 December 2025
  • CARA is a cost-aware LLM selection framework that uses a single-head cross-attention mechanism to model fine-grained query–model interactions.
  • It jointly predicts response quality and generation cost through dual prediction branches with an exponential reward mechanism, improving efficiency and performance.
  • Empirical evaluations on RouterBench show CARA outperforms baseline routers by up to 6.6% in quality improvements while retaining a lightweight design.

The Cross-Attention Routing Adapter (CARA) is a unified framework for the cost-aware selection of LLMs that employs a single-head cross-attention architecture to model fine-grained query–model interactions. CARA is designed to dynamically select the most appropriate LLM for each user prompt by jointly predicting response quality and generation cost, balancing these factors through an exponential reward mechanism. The resulting router is lightweight, generalizes across domains, and demonstrates efficiency and performance improvements over established baselines on the RouterBench benchmark (Pulishetty et al., 11 Sep 2025).

1. Architectural Overview

CARA is positioned as an intermediary in front of a candidate pool of KK LLMs. For each incoming prompt, the system undertakes the following process:

  • Prompt Embedding: Each prompt is embedded with a fixed sentence encoder (DistilBERT), generating q∈R768q \in \mathbb{R}^{768}.
  • Model Embeddings: Each LLM jj is represented by a pre-computed embedding mj∈RCm_j \in \mathbb{R}^C, where C=20C = 20 corresponds to prompt clusters, with mj[k]m_j[k] reflecting the model's average performance on cluster kk.
  • Cross-Attention Block: CARA uses a single-head cross-attention mechanism parameterized by three learnable projection matrices: WQ∈RdĂ—768W^Q \in \mathbb{R}^{d \times 768} (query), WK∈RdĂ—CW^K \in \mathbb{R}^{d \times C} (key), and WV∈RdĂ—CW^V \in \mathbb{R}^{d \times C} (value), where q∈R768q \in \mathbb{R}^{768}0 is the internal dimension (e.g., q∈R768q \in \mathbb{R}^{768}1).
  • Batch Processing: For a batch of q∈R768q \in \mathbb{R}^{768}2 prompts, queries q∈R768q \in \mathbb{R}^{768}3, keys q∈R768q \in \mathbb{R}^{768}4, and values q∈R768q \in \mathbb{R}^{768}5 are computed, with q∈R768q \in \mathbb{R}^{768}6 stacking the q∈R768q \in \mathbb{R}^{768}7 model embeddings.
  • Attention Computation: Each prompt produces a q∈R768q \in \mathbb{R}^{768}8-length weight vector q∈R768q \in \mathbb{R}^{768}9 via cross-attention, which is used to aggregate information from the model embeddings.

This unified architectural design enables a "query-to-models" interaction that captures both prompt-specific and model-specific characteristics relevant for routing decisions.

2. Mathematical Formulation

Given a prompt embedding jj0 and stacked model embeddings jj1:

  • Projection:
    • jj2
    • jj3
    • jj4
  • Attention Output:
    • jj5
    • jj6

For model jj7:

jj8

CARA maintains two identical attention branches with separate projection matrices for quality and cost prediction:

  • Quality Branch: Generates a summary vector jj9 mapped by head mj∈RCm_j \in \mathbb{R}^C0 to predicted quality scores mj∈RCm_j \in \mathbb{R}^C1 for each model.
  • Cost Branch: Generates a summary vector mj∈RCm_j \in \mathbb{R}^C2 mapped by mj∈RCm_j \in \mathbb{R}^C3 to predicted cost scores mj∈RCm_j \in \mathbb{R}^C4.

In implementation, mj∈RCm_j \in \mathbb{R}^C5 is passed through a small linear layer for each branch to output the mj∈RCm_j \in \mathbb{R}^C6-dimensional prediction vectors.

3. Joint Prediction and Exponential Reward

CARA produces model-wise predictions for:

  • Response Quality (mj∈RCm_j \in \mathbb{R}^C7): An estimate of the true task metric (e.g., accuracy, exact match) for model mj∈RCm_j \in \mathbb{R}^C8 on the prompt.
  • Generation Cost (mj∈RCm_j \in \mathbb{R}^C9): The predicted per-token API cost for using model C=20C = 200.

At selection time, a user specifies willingness-to-pay parameter C=20C = 201. For each model C=20C = 202, CARA computes the exponential trade-off reward:

C=20C = 203

Model selection is performed by

C=20C = 204

Unlike the linear alternative C=20C = 205, the exponential reward C=20C = 206 is bounded in C=20C = 207 and exhibits reduced sensitivity to small variations in C=20C = 208, as empirically validated.

4. Training Objectives and Optimization

Separate mean squared error (MSE) losses are used for each prediction branch:

  • Quality Loss:

C=20C = 209

  • Cost Loss:

mj[k]m_j[k]0

Both branches are trained with the Adam optimizer, weight decay, and a CosineAnnealingLR schedule. Experimentally:

  • Quality: learning rate mj[k]m_j[k]1, weight decay mj[k]m_j[k]2, 1000 epochs, batch size 1024.
  • Cost: learning rate mj[k]m_j[k]3, weight decay mj[k]m_j[k]4, hidden dimension mj[k]m_j[k]5.

Each model embedding mj[k]m_j[k]6 is only recomputed when models change, not retrained.

5. Empirical Evaluation on RouterBench

RouterBench spans 11 LLMs across 8 benchmarks: MMLU, GSM8K, HellaSwag, ARC, Winogrande, MBPP, MT-Bench, and RAG; each sample is annotated with ground-truth response quality per LLM and corresponding API cost.

CARA's performance is compared with KNN, MLP, SVM-based routers, and the LLM-Blender ensemble. An oracle using ground-truth mj[k]m_j[k]7 establishes the upper bound.

  • Primary Metric: Average Improvement in Quality (AIQ), defined as area under the cost–quality Pareto frontier (normalized).
  • Maximum Quality across mj[k]m_j[k]8 is also reported.

Notable empirical findings:

Router AIQ (Pool 1) Max Perf (Pool 1)
CARA 0.7274 0.7808
KNN 0.7061 —
MLP 0.6760 —
SVM 0.7022 —
  • CARA achieves up to mj[k]m_j[k]9 AIQ and kk0 in maximum quality (over best predictive baseline).
  • On Pools 2–4, CARA improves AIQ by kk1 over KNN and kk2 over SVM.
  • The system consistently sits at the upper (cost-effective) region of cost–performance plots across domains.

6. Efficiency, Lightweight Design, and Generalization

CARA introduces minimal overhead:

  • Architecture adds only a single-head cross-attention block and two linear prediction heads.
  • End-to-end code occupies less than 1 GB GPU memory; training completes in kk330 minutes (NVIDIA A100), with inference requiring kk410 minutes per 10,000 prompts.
  • Model embeddings are fixed; adding or removing LLMs requires only recomputation of kk5 for new models, not router retraining.
  • In cross-domain and dataset-wise generalization (MMLU subdomains, ARC challenge), CARA matches or exceeds the cost–quality trade-off relative to all baselines.

A plausible implication is that CARA's modular design and reliance on stable embeddings contribute to robust transfer performance and scalability, supporting "train-and-forget" deployment across evolving LLM landscapes.

7. Summary and Context

The Cross-Attention Routing Adapter (CARA) addresses cost-aware LLM selection by leveraging a unified single-head cross-attention mechanism, explicit prediction of both model quality and generation cost, and an exponential routing reward for stability with respect to cost–quality trade-off preferences. On the RouterBench benchmark, CARA surpasses existing routers in both efficiency and empirical performance. The architectural simplicity, compatibility with fixed and extensible LLM pools, and robust generalization establish CARA as a new standard for scalable LLM routing in heterogeneous, cost-constrained environments (Pulishetty et al., 11 Sep 2025).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Cross-Attention Routing Adapter (CARA).