GMTRouter Selection
GMTRouter uses a heterogeneous graph neural network to learn personalized routing decisions based on multi-turn user interactions. It builds a graph capturing user-LLM-query-response relationships and learns which models work best for each user over time.
This personalized approach can achieve 0.9% - 21.6% higher accuracy and 0.006 - 0.309 higher AUC compared to non-personalized routing.
Reference: GMTRouter: Personalized LLM Router over Multi-turn User Interactions by Wang et al. Our implementation is inspired by this paper's graph-based personalization approach.
Algorithm Flow
Mathematical Foundation
Heterogeneous Graph Structure
The graph contains 4 node types to capture multi-turn interaction patterns:
G = (V, E) where V = V_user ∪ V_llm ∪ V_query ∪ V_response
Node types:
- User nodes: Represent individual users with their interaction history
- LLM nodes: Represent available language models
- Query nodes: Represent queries submitted by users
- Response nodes: Capture model outputs and quality signals
Virtual turn nodes connect sequential interactions within a conversation.
HGT Convolution Layer
The paper uses Heterogeneous Graph Transformer (HGT) convolution with layer normalization:
h_v^(l+1) = LayerNorm(h_v^(l) + HGTConv(h_v^(l), {h_u^(l) : u ∈ N(v)}))
HGTConv applies type-specific attention:
Attention(v, u) = softmax_u(W_τ(v),τ(u) · h_v · h_u^T / √d)
where τ(v) denotes the node type of v.
Cross-Attention Prediction Head
Final user-model preference score uses cross-attention:
s_{u,q,m} = f_pred(h_u^(L), h_q^(0), h_m^(L))
where:
h_u^(L) = user embedding after L layers
h_q^(0) = query embedding
h_m^(L) = model embedding after L layers