EmbedLLM: Learning Compact Representations of Large Language Models

Richard Zhuang, Tianhao Wu, Zhaojin Wen, Andrew Li, Jiantao Jiao, Kannan Ramchandran

TL;DR

EmbedLLM introduces a novel framework that condenses entire Large Language Models (LLMs) into compact, low-dimensional vector embeddings. By framing model evaluation as a matrix factorization problem, this unified representation enables ultra-fast model routing and accurate benchmark performance forecasting with minimal computational overhead.

What Problem Does This Paper Address?

With hundreds of thousands of open-source LLMs available on platforms like Hugging Face, selecting the right model for a specific task has become a massive headache. Traditional approaches rely on extensive benchmarking (running models on massive test suites) or predictive model routing (dynamically directing queries to the best-suited model).

However, these workflows are incredibly compute-intensive and time-consuming. Existing routing systems often repeatedly learn task-specific representations for each downstream application, incurring high inference latencies and substantial retraining costs. EmbedLLM addresses this inefficiency by asking a fundamental question: What if we could directly work with a single, unified, and compact representation of an LLM?

Methods

The authors propose EmbedLLM, an encoder-decoder framework inspired by image reconstruction algorithms. Instead of analyzing a model's weights directly, EmbedLLM learns embeddings based on a reconstruction system—specifically, a Matrix Factorization (MF) approach that predicts a model's binary answer correctness across a large set of questions.

Figure 1: An illustration of the EmbedLLM Pipeline. An embedder network is pretrained to convert models into vector embeddings. Downstream applications like model routing are adapted by training an additional linear layer on top of these embeddings.

The architecture consists of two main components:

  1. Encoder: Comprises a model embedding network (which maps a model's index to a latent vector $v_m$) and a question embedding network (which processes question text using a standard sentence transformer and projects it into the same latent space as $v'_q$).
  2. Decoder: A linear classifier that takes the Hadamard (element-wise) product of the model and question embeddings ($v_m \odot v'_q$) and outputs the probability that the model will answer the question correctly.

The entire system is trained end-to-end using standard Binary Cross-Entropy (BCE) loss. Once trained, the compact model embeddings can be frozen and paired with simple linear layers for various downstream tasks without needing to re-evaluate the actual LLMs.

Datasets

The authors compiled a correctness dataset by aggregating the responses of 112 open-source LLMs (ranging from general-purpose to domain-specific models) across 36,054 questions from 10 mainstream benchmarks:

  • MMLU (General knowledge)
  • GSM8K, MathQA, ASDiv (Mathematics)
  • LogiQA (Logical reasoning)
  • MedMCQA (Medical domain)
  • TruthfulQA, SocialQA, PIQA, GPQA

Text prompts were converted into initial 768-dimensional vectors using the all-mpnet-base-v2 sentence transformer before being passed to the framework.

Key Insights and Ideas

  • LLMs Cluster by Trait: Probing experiments revealed that the latent space naturally organizes models by intrinsic characteristics. Models of similar sizes (e.g., 7B vs. 70B) or domain specializations (e.g., math or coding) naturally sit closer together in $L_2$ distance, even though the network was never explicitly trained on model metadata.
  • MMLU is a Universal Contributor: Including MMLU in the embedding training significantly boosts the framework's ability to predict performance on other benchmarks, confirming its highly comprehensive nature.
  • Easy Tasks Don't Extrapolate to Hard Ones: Incorporating simpler benchmarks actually harmed the embedding's predictive power on GPQA (a notoriously difficult graduate-level benchmark). This indicates that a model's capability on easy tasks does not linearly translate to harder reasoning challenges.

Key Results

EmbedLLM was evaluated across three downstream tasks, demonstrating substantial improvements in efficiency and scalability:

  • Model Routing: The Matrix Factorization (MF) router achieved near single-best model accuracy across benchmarks while dynamically utilizing the strengths of different models.
  • Speed and Efficiency: On a single NVIDIA A100 GPU, the MF router processed 3,000 questions in 3.80 seconds. This is 15x faster than state-of-the-art causal LLM routers. Furthermore, training the router required less than 1GB of GPU memory, making it 60x cheaper than fine-tuning a Llama-3-8B model for routing.
Figure 4: Performance accuracy of MF router compared to baselines. MF router performs better across the whole test set and achieves accuracies close to the single-best model on every benchmark.
  • Benchmark Accuracy Prediction: Using a leave-one-out evaluation strategy, a simple linear regression trained on the model embeddings successfully forecasted average accuracy on unseen benchmarks. This achieved statistical significance in 7 out of 10 benchmarks, saving millions of tokens worth of inference costs.
Figure 5: Left: Sorted Kendall’s Tau test result of accuracy prediction on the benchmarks. The “Significance” column represents the number of times with significant correlation detected (at a 5% significance level) out of 100 random model splits. Right: An example comparing actual model accuracies on MathQA against model accuracies on MathQA predicted from the embeddings trained without MathQA data.

Limitations and Future Work

While promising, the authors note several limitations:

  1. Fixed Model Pool: The current matrix factorization approach requires retraining the embedding space whenever a new LLM is introduced to the pool.
  2. Small Dataset Scale: The dataset is limited to 112 models, resulting in a moderately sparse embedding space that limits deeper relational exploration.
  3. Binary Correctness Focus: The framework relies strictly on binary correctness datasets, meaning it does not yet capture the stylistic nuances, generation quality, or text embeddings of open-ended model outputs.

Future work will likely focus on making these embeddings inductive (allowing zero-shot embedding of new models) and extending the framework to handle free-form text generations.

Summary updated

BibTeX
@inproceedings{zhuang2025embedllm,
  author = {Richard Zhuang and Tianhao Wu and Zhaojin Wen and Andrew Li and Jiantao Jiao and Kannan Ramchandran},
  title = {{EmbedLLM: Learning Compact Representations of Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=Fs9EabmQrJ},
}
Figure