🤖 AI Summary
This study investigates whether large language models (LLMs) implicitly encode domain-specific semantics during the prefill phase. To address this, we analyze the dynamic trajectories of hidden states across model layers and propose a zero-shot domain identification and model selection method: without fine-tuning, domain identity—down to fine-grained distinctions (e.g., “machine learning” vs. “statistics”)—is inferred solely from implicit representations in the initial generation stage, enabling automatic selection of the optimal LLM. Experiments span multiple models, diverse domains, and varied prompt styles, demonstrating strong robustness of domain-specific trajectories; notably, certain unmodified base models outperform their domain-fine-tuned counterparts on specific queries. Our key contribution is the first empirical revelation of separable, domain-discriminative trajectories emerging in the feedforward process of LLMs, coupled with a general-purpose, representation-driven model selection framework applicable to both open- and closed-generation tasks.
📝 Abstract
We study whether Large Language Models (LLMs) inherently capture domain-specific nuances in natural language. Our experiments probe the domain sensitivity of LLMs by examining their ability to distinguish queries from different domains using hidden states generated during the prefill phase. We reveal latent domain-related trajectories that indicate the model's internal recognition of query domains. We also study the robustness of these domain representations to variations in prompt styles and sources. Our approach leverages these representations for model selection, mapping the LLM that best matches the domain trace of the input query (i.e., the model with the highest performance on similar traces). Our findings show that LLMs can differentiate queries for related domains, and that the fine-tuned model is not always the most accurate. Unlike previous work, our interpretations apply to both closed and open-ended generative tasks