Embedding Geometry Shapes LLM Routing: Tracing Failure Modes and Improving Generalization
Leonardo Torti, Emanuele Rimoldi, Tomer Galanti, Tomaso Poggio, Pierfrancesco Beneventano
Abstract
With the growing number of LLMs available, selecting which one to use for a prompt has become a key question. A large part of the routing literature relies on semantically embedding prompts into a vector space and then applying a lightweight classifier to the embedded representations. These methods perform robustly in-distribution but they struggle to generalize to unseen tasks. By studying the geometry of semantic embeddings, we trace a clear failure mode: features that determine the neighbors of unseen prompts are an unreliable proxy for LLM selection. We therefore replace the semantic embedding with the following map: we run a partial forward pass of Qwen2.5-7B-Instruct on the prompt and use the hidden state of its last token at a deep layer as the representation. When applying kNN and other simple classifiers to this new representation, we obtain a clear result in generalization: on average across cost penalties, their performance improves. Moreover, kNN and another simple classifier that we propose outperform every evaluated semantic-embedding baseline. Our two simple methods also beat a recent SoTA hidden-states based router on RouterBench.
Create a lesson
Metadata
- Categories
- cs.AI, cs.LG, stat.ML
- Comments
- 50 pages, 7 figure, 45 tables
Related papers
When Reasoning Traces Conflict with Evidence: How Answer Configuration Shapes Evidence Following
Shared title terminologycs.AIShaoang Li, Yanhang Shi, Jian Li
Fin-RSI: A Unified Library of Financial Skills, Checks, and Self-Improvement for LLM Agents
Shared title terminologycs.AIWanghao Ye, Shwai He, Sihan Chen et al.
Do You Even Know What I Want? Improving LLMs Ability to Detect Hidden User Intent
Shared title terminologycs.AIKelsey Sikes, Sarath Sreedharan
When Wrong Answers Remain Unsettled: Failure Dynamics in Recurrent Reasoners
Shared title terminologycs.AIJiucheng Zang, Congkai Peng, Yankai Wei
Improving semantic equivalence in research-level math formalization
Shared title terminologycs.AIAyush Khaitan, Liam Fowl, Tomàs Ortega et al.
Improving the Improver: Semantic PID Control for Medical Agent Self-Improvement
Shared title terminologycs.AIDexia Chen, YiLong Hu, Wenqi Zhong et al.